Skip to content

Commit

Permalink
Suggest txt extension on file picker
Browse files Browse the repository at this point in the history
  • Loading branch information
lunacd committed Mar 4, 2024
1 parent 4129f3b commit 5e68ca5
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 40 deletions.
12 changes: 6 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ jobs:
# Steps adapted from the official flutter orb
- restore_cache:
keys:
- flutter-3.19.1-{{ arch }}
- flutter-3.19.2-{{ arch }}
- run:
name: Install Flutter SDK if not exists
command: |
if [ ! -d ~/development/flutter ]; then
mkdir -p ~/development
curl -o flutter_sdk.zip https://storage.googleapis.com/flutter_infra_release/releases/stable/macos/flutter_macos_3.19.1-stable.zip
curl -o flutter_sdk.zip https://storage.googleapis.com/flutter_infra_release/releases/stable/macos/flutter_macos_3.19.2-stable.zip
unzip -qq flutter_sdk.zip -d ~/development
rm flutter_sdk.zip
fi
echo 'export PATH=~/development/flutter/bin:$PATH' >> $BASH_ENV
- run: flutter doctor
- save_cache:
key: flutter-3.19.1-{{ arch }}
key: flutter-3.19.2-{{ arch }}
paths:
- ~/development
- restore_cache:
Expand Down Expand Up @@ -55,13 +55,13 @@ jobs:
- checkout
- restore_cache:
keys:
- flutter-3.19.1-{{ arch }}
- flutter-3.19.2-{{ arch }}
- run:
name: Install Flutter SDK if not exists
command: |
if [ ! -d ~/development/flutter ]; then
mkdir -p ~/development
curl -o flutter_sdk.zip https://storage.googleapis.com/flutter_infra_release/releases/stable/windows/flutter_windows_3.19.1-stable.zip
curl -o flutter_sdk.zip https://storage.googleapis.com/flutter_infra_release/releases/stable/windows/flutter_windows_3.19.2-stable.zip
unzip -qq flutter_sdk.zip -d ~/development
rm flutter_sdk.zip
fi
Expand All @@ -71,7 +71,7 @@ jobs:
command: flutter doctor
shell: bash.exe
- save_cache:
key: flutter-3.19.1-{{ arch }}
key: flutter-3.19.2-{{ arch }}
paths:
- ~\development
- restore_cache:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@v2
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.19.1'
flutter-version: '3.19.2'
channel: 'stable'

- name: Get dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- uses: actions/checkout@v2
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.19.1'
flutter-version: '3.19.2'
channel: 'stable'

- name: Get dependencies
Expand Down
5 changes: 4 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@ const List<Color> clusterColors = [
int colorNum = 0;

void main() async {
// Initialize widgets
WidgetsFlutterBinding.ensureInitialized();
if (!kIsWeb && (Platform.isMacOS || Platform.isLinux || Platform.isWindows)) {
await DesktopWindow.setMinWindowSize(const Size(1400, 500));
}

// Start app
runApp(const MyApp());
}

Expand All @@ -52,7 +55,7 @@ class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Omnilore Demo',
title: 'Omnilore Scheduler',
theme: ThemeData(
primarySwatch: primaryBlack,
textButtonTheme: TextButtonThemeData(
Expand Down
52 changes: 21 additions & 31 deletions lib/widgets/screen.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_menu/flutter_menu.dart';
Expand Down Expand Up @@ -161,8 +160,8 @@ class _ScreenState extends State<Screen> {
icon: Icons.open_in_new,
title: 'Import Course',
onPressed: () async {
FilePickerResult? result =
await FilePicker.platform.pickFiles();
FilePickerResult? result = await FilePicker.platform.pickFiles(
type: FileType.custom, allowedExtensions: ['txt']);

if (result != null) {
String path = result.files.single.path ?? '';
Expand All @@ -187,8 +186,8 @@ class _ScreenState extends State<Screen> {
title: 'Import People',
icon: Icons.open_in_new,
onPressed: () async {
FilePickerResult? result =
await FilePicker.platform.pickFiles();
FilePickerResult? result = await FilePicker.platform.pickFiles(
type: FileType.custom, allowedExtensions: ['txt']);

if (result != null) {
String path = result.files.single.path ?? '';
Expand All @@ -212,7 +211,8 @@ class _ScreenState extends State<Screen> {
MenuListItem(
title: 'Save',
onPressed: () async {
String? path = await FilePicker.platform.saveFile();
String? path = await FilePicker.platform.saveFile(
type: FileType.custom, allowedExtensions: ['txt']);

if (path != null) {
if (path != '') {
Expand All @@ -232,17 +232,11 @@ class _ScreenState extends State<Screen> {
title: 'Load',
shortcut: MenuShortcut(key: LogicalKeyboardKey.keyD, ctrl: true),
onPressed: () async {
FilePickerResult? result =
await FilePicker.platform.pickFiles();
if (kDebugMode) {
print('FILE PICKED');
}
FilePickerResult? result = await FilePicker.platform.pickFiles(
type: FileType.custom, allowedExtensions: ['txt']);

if (result != null) {
String path = result.files.single.path ?? '';
if (kDebugMode) {
print(path);
}
if (path != '') {
setState(() {
try {
Expand All @@ -265,7 +259,8 @@ class _ScreenState extends State<Screen> {
MenuListItem(
title: 'Export Early Roster',
onPressed: () async {
String? path = await FilePicker.platform.saveFile();
String? path = await FilePicker.platform.saveFile(
type: FileType.custom, allowedExtensions: ['txt']);

if (path != null) {
if (path != '') {
Expand All @@ -285,29 +280,24 @@ class _ScreenState extends State<Screen> {
MenuListItem(
title: 'Export Final Roster',
onPressed: () async {
String? path = await FilePicker.platform.saveFile();
if (path != null) {
if (path != '') {
try {
if (kDebugMode) {
print('name of file $path');
}
schedule.outputRosterCC(path);
} catch (e) {
if (context.mounted) {
Utils.showPopUp(context,
'Error exporting roster with CC', e.toString());
}
String? path = await FilePicker.platform.saveFile(
type: FileType.custom, allowedExtensions: ['txt']);
if (path != null && path.isNotEmpty) {
try {
schedule.outputRosterCC(path);
} catch (e) {
if (context.mounted) {
Utils.showPopUp(context,
'Error exporting roster with CC', e.toString());
}
}
} else {
//file picker canceled
}
}),
MenuListItem(
title: 'Export MailMerge',
onPressed: () async {
String? path = await FilePicker.platform.saveFile();
String? path = await FilePicker.platform.saveFile(
type: FileType.custom, allowedExtensions: ['txt']);

if (path != null) {
if (path != '') {
Expand Down

0 comments on commit 5e68ca5

Please sign in to comment.