Skip to content

Commit

Permalink
Minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Clon1998 committed Apr 8, 2022
1 parent abc9f0d commit a0fc41f
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 92 deletions.
2 changes: 1 addition & 1 deletion assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
"language": "Language",
"companion": "Learn how to setup Mobileraker's Companion on its "
},
"imprint": "Imprint"
"imprint": "Privacy/Impressum"
},
"printer_edit": {
"title": "Edit {}",
Expand Down
4 changes: 3 additions & 1 deletion lib/ui/views/console/console_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ class ConsoleView extends ViewModelBuilderWidget<ConsoleViewModel> {
child: ActionChip(
label: Text(cmd),
backgroundColor: highlightColor,
onPressed: () => model.onSuggestionChipTap(cmd),
onPressed: () => (model.isConsoleHistoryAvailable)
? model.onSuggestionChipTap(cmd)
: null,
),
);
},
Expand Down
9 changes: 5 additions & 4 deletions lib/ui/views/files/files_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class FilesView extends ViewModelBuilderWidget<FilesViewModel> {
context,
Column(
children: [
buildBreadCrumb(context, model.requestedPath),
buildBreadCrumb(context, model, model.requestedPath),
Expanded(
child: Shimmer.fromColors(
child: ListView.builder(
Expand Down Expand Up @@ -182,7 +182,7 @@ class FilesView extends ViewModelBuilderWidget<FilesViewModel> {
context,
Column(
children: [
buildBreadCrumb(context, model.folderContent.reqPath.split('/')),
buildBreadCrumb(context, model, model.folderContent.reqPath.split('/')),
Expanded(
child: EaseIn(
duration: Duration(milliseconds: 100),
Expand Down Expand Up @@ -258,7 +258,7 @@ class FilesView extends ViewModelBuilderWidget<FilesViewModel> {
);
}

Widget buildBreadCrumb(BuildContext context, List<String> paths) {
Widget buildBreadCrumb(BuildContext context, FilesViewModel model, List<String> paths) {
ThemeData theme = Theme.of(context);
Color highlightColor = theme.brightness == Brightness.dark
? theme.colorScheme.secondary
Expand All @@ -274,12 +274,13 @@ class FilesView extends ViewModelBuilderWidget<FilesViewModel> {
itemCount: paths.length,
builder: (index) {
String p = paths[index];
List<String> fullPath = paths.sublist(0,index+1);
return BreadCrumbItem(
content: Text(
'${p.toUpperCase()}',
style: theme.textTheme.subtitle1?.copyWith(color: Colors.white),
),
onTap: () => print('TAPED$p'));
onTap: () => model.onBreadCrumbItemPressed(fullPath));
},
divider: Padding(
padding: const EdgeInsets.symmetric(horizontal: 4.0),
Expand Down
4 changes: 4 additions & 0 deletions lib/ui/views/files/files_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ class FilesViewModel extends MultipleStreamViewModel {
_busyFetchDirectoryData(newPath: newPath);
}

onBreadCrumbItemPressed(List<String> newPath) {
return _busyFetchDirectoryData(newPath: newPath);
}

Future<bool> onWillPop() async {
List<String> newPath = folderContent.reqPath.split('/');

Expand Down
173 changes: 87 additions & 86 deletions lib/ui/views/setting/setting_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,89 +23,88 @@ class SettingView extends ViewModelBuilderWidget<SettingViewModel> {
autovalidateMode: AutovalidateMode.onUserInteraction,
child: Padding(
padding: const EdgeInsets.all(10.0),
child: SingleChildScrollView(
child: Column(
children: <Widget>[
_SectionHeader(title: 'pages.setting.general.title'.tr()),
_languageSelector(context),
FormBuilderSwitch(
name: 'emsConfirmation',
title: Text('pages.setting.general.ems_confirm').tr(),
onChanged: model.onEMSChanged,
initialValue: model.emsValue,
decoration: InputDecoration(
border: InputBorder.none, isCollapsed: true),
activeColor: Theme.of(context).colorScheme.primary,
),
FormBuilderSwitch(
name: 'alwaysShowBaby',
title: Text('pages.setting.general.always_baby').tr(),
onChanged: model.onAlwaysShowBabyChanged,
initialValue: model.showBabyAlwaysValue,
decoration: InputDecoration(
border: InputBorder.none, isCollapsed: true),
activeColor: Theme.of(context).colorScheme.primary,
),
FormBuilderSwitch(
name: 'useTextInputForNum',
title: Text('pages.setting.general.num_edit').tr(),
onChanged: model.onUseTextInputForNumChanged,
initialValue: model.useTextInputForNum,
decoration: InputDecoration(
border: InputBorder.none, isCollapsed: true),
activeColor: Theme.of(context).colorScheme.primary,
),
FormBuilderSwitch(
name: 'startWithOverview',
title: Text('pages.setting.general.start_with_overview').tr(),
onChanged: model.onStartWithOverviewChanged,
initialValue: model.startWithOverview,
decoration: InputDecoration(
border: InputBorder.none, isCollapsed: true),
activeColor: Theme.of(context).colorScheme.primary,
),
Divider(),
RichText(
text: TextSpan(
text:
tr('pages.setting.general.companion'),
children: [
new TextSpan(
text: '\nOfficial GitHub ',
style: new TextStyle(color: Colors.blue),
children: [
WidgetSpan(
child:
Icon(FlutterIcons.github_alt_faw, size: 18),
),
],
recognizer: TapGestureRecognizer()
..onTap = () async {
const String url =
'https://github.com/Clon1998/mobileraker_companion';
if (await canLaunch(url)) {
//TODO Fix this... neds Android Package Visibility
await launch(url);
} else {
throw 'Could not launch $url';
}
},
),
]),
textAlign: TextAlign.center,
),
Divider(),
Text(
model.version,
textAlign: TextAlign.center,
),
TextButton(
child: Text('pages.setting.imprint').tr(),
onPressed: model.navigateToLegal,
),
// _SectionHeader(title: 'Notifications'),
],
),
child: ListView(
children: <Widget>[
_SectionHeader(title: 'pages.setting.general.title'.tr()),
_languageSelector(context),
FormBuilderSwitch(
name: 'emsConfirmation',
title: Text('pages.setting.general.ems_confirm').tr(),
onChanged: model.onEMSChanged,
initialValue: model.emsValue,
decoration: InputDecoration(
border: InputBorder.none, isCollapsed: true),
activeColor: Theme.of(context).colorScheme.primary,
),
FormBuilderSwitch(
name: 'alwaysShowBaby',
title: Text('pages.setting.general.always_baby').tr(),
onChanged: model.onAlwaysShowBabyChanged,
initialValue: model.showBabyAlwaysValue,
decoration: InputDecoration(
border: InputBorder.none, isCollapsed: true),
activeColor: Theme.of(context).colorScheme.primary,
),
FormBuilderSwitch(
name: 'useTextInputForNum',
title: Text('pages.setting.general.num_edit').tr(),
onChanged: model.onUseTextInputForNumChanged,
initialValue: model.useTextInputForNum,
decoration: InputDecoration(
border: InputBorder.none, isCollapsed: true),
activeColor: Theme.of(context).colorScheme.primary,
),
FormBuilderSwitch(
name: 'startWithOverview',
title: Text('pages.setting.general.start_with_overview').tr(),
onChanged: model.onStartWithOverviewChanged,
initialValue: model.startWithOverview,
decoration: InputDecoration(
border: InputBorder.none, isCollapsed: true),
activeColor: Theme.of(context).colorScheme.primary,
),
Divider(),
RichText(
text: TextSpan(
style: Theme.of(context).textTheme.bodyText2,
text: tr('pages.setting.general.companion'),
children: [
new TextSpan(
text: '\nOfficial GitHub ',
style: new TextStyle(color: Colors.blue),
children: [
WidgetSpan(
child:
Icon(FlutterIcons.github_alt_faw, size: 18),
),
],
recognizer: TapGestureRecognizer()
..onTap = () async {
const String url =
'https://github.com/Clon1998/mobileraker_companion';
if (await canLaunch(url)) {
//TODO Fix this... neds Android Package Visibility
await launch(url);
} else {
throw 'Could not launch $url';
}
},
),
]),
textAlign: TextAlign.center,
),
Divider(),
Text(
model.version,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.bodySmall,
),
TextButton(
child: Text('pages.setting.imprint').tr(),
onPressed: model.navigateToLegal,
),
// _SectionHeader(title: 'Notifications'),
],
),
),
),
Expand Down Expand Up @@ -144,12 +143,14 @@ Widget _languageSelector(BuildContext context) {
initialValue: context.locale,
name: 'lan',
items: supportedLocals
.map((local) =>
DropdownMenuItem(value: local, child: Text('languages.${local.languageCode}.nativeName'.tr())))
.map((local) => DropdownMenuItem(
value: local,
child: Text('languages.${local.languageCode}.nativeName'.tr())))
.toList(),
decoration: InputDecoration(
labelText: 'pages.setting.general.language'.tr(),
),
onChanged: (Locale? local) => context.setLocale(local??context.fallbackLocale!),
onChanged: (Locale? local) =>
context.setLocale(local ?? context.fallbackLocale!),
);
}

0 comments on commit a0fc41f

Please sign in to comment.