Skip to content

Commit b53fccb

Browse files
committed
#336: added automatic back
1 parent 5d6614f commit b53fccb

File tree

4 files changed

+91
-105
lines changed

4 files changed

+91
-105
lines changed

lib/screen/debug/debug_screen.dart

+63-68
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import 'package:flutter/material.dart';
2-
import 'package:flutter/services.dart';
32
import 'package:flutter_navigation_generator_annotations/flutter_navigation_generator_annotations.dart';
43
import 'package:flutter_template/di/injectable.dart';
54
import 'package:flutter_template/util/keys.dart';
@@ -8,6 +7,7 @@ import 'package:flutter_template/viewmodel/global/global_viewmodel.dart';
87
import 'package:flutter_template/widget/debug/debug_row_item.dart';
98
import 'package:flutter_template/widget/debug/debug_row_title.dart';
109
import 'package:flutter_template/widget/debug/debug_switch_row_item.dart';
10+
import 'package:flutter_template/widget/general/simple_screen/base_screen.dart';
1111
import 'package:flutter_template/widget/provider/provider_widget.dart';
1212
import 'package:provider/provider.dart';
1313

@@ -25,73 +25,68 @@ class DebugScreenState extends State<DebugScreen> {
2525
Widget build(BuildContext context) {
2626
return ProviderWidget<DebugViewModel>(
2727
create: () => getIt()..init(),
28-
consumerWithThemeAndLocalization: (context, viewModel, child, theme, localization) => Scaffold(
29-
backgroundColor: theme.colorsTheme.background,
30-
appBar: AppBar(
31-
systemOverlayStyle: SystemUiOverlayStyle.light,
32-
title: Text(localization.settingsTitle),
33-
backgroundColor: theme.colorsTheme.primary,
34-
),
35-
body: ListView(
36-
children: [
37-
DebugRowTitle(title: localization.debugAnimationsTitle),
38-
DebugRowSwitchItem(
39-
key: Keys.debugSlowAnimations,
40-
title: localization.debugSlowAnimations,
41-
value: viewModel.slowAnimationsEnabled,
42-
onChanged: viewModel.onSlowAnimationsChanged,
43-
),
44-
DebugRowTitle(title: localization.debugThemeTitle),
45-
DebugRowItem(
46-
key: Keys.debugTargetPlatform,
47-
title: localization.debugTargetPlatformTitle,
48-
subTitle: localization.debugTargetPlatformSubtitle(localization.getTranslation(Provider.of<GlobalViewModel>(context).getCurrentPlatform())),
49-
onClick: viewModel.onTargetPlatformClicked,
50-
),
51-
DebugRowItem(
52-
key: Keys.debugThemeMode,
53-
title: localization.debugThemeModeTitle,
54-
subTitle: localization.debugThemeModeSubtitle,
55-
onClick: viewModel.onThemeModeClicked,
56-
),
57-
DebugRowTitle(title: localization.debugLocaleTitle),
58-
DebugRowItem(
59-
key: Keys.debugSelectLanguage,
60-
title: localization.debugLocaleSelector,
61-
subTitle: localization.debugLocaleCurrentLanguage(Provider.of<GlobalViewModel>(context).getCurrentLanguage()),
62-
onClick: viewModel.onSelectLanguageClicked,
63-
),
64-
DebugRowSwitchItem(
65-
key: Keys.debugShowTranslations,
66-
title: localization.debugShowTranslations,
67-
value: Provider.of<GlobalViewModel>(context, listen: false).showsTranslationKeys,
68-
onChanged: (_) => Provider.of<GlobalViewModel>(context, listen: false).toggleTranslationKeys(),
69-
),
70-
DebugRowTitle(title: localization.debugLicensesTitle),
71-
DebugRowItem(
72-
key: Keys.debugLicense,
73-
title: localization.debugLicensesGoTo,
74-
onClick: viewModel.onLicensesClicked,
75-
),
76-
DebugRowTitle(title: localization.debugDatabase),
77-
DebugRowItem(
78-
key: Keys.debugDatabase,
79-
title: localization.debugViewDatabase,
80-
onClick: viewModel.goToDatabase,
81-
),
82-
DebugRowTitle(title: localization.debugPermissionsTitle),
83-
DebugRowItem(
84-
key: Keys.debugPermissionAnalytics,
85-
title: localization.debugPermissionsShowAnalyticsPermission,
86-
onClick: viewModel.goToAnalyticsPermissionScreen,
87-
),
88-
DebugRowItem(
89-
key: Keys.debugPermissionAnalyticsReset,
90-
title: localization.debugPermissionResetAnalytics,
91-
onClick: viewModel.resetAnalyticsPermission,
92-
),
93-
],
94-
),
28+
consumerWithThemeAndLocalization: (context, viewModel, child, theme, localization) => BaseScreen(
29+
title: localization.settingsTitle,
30+
padding: EdgeInsets.zero,
31+
isScrollable: true,
32+
children: [
33+
DebugRowTitle(title: localization.debugAnimationsTitle),
34+
DebugRowSwitchItem(
35+
key: Keys.debugSlowAnimations,
36+
title: localization.debugSlowAnimations,
37+
value: viewModel.slowAnimationsEnabled,
38+
onChanged: viewModel.onSlowAnimationsChanged,
39+
),
40+
DebugRowTitle(title: localization.debugThemeTitle),
41+
DebugRowItem(
42+
key: Keys.debugTargetPlatform,
43+
title: localization.debugTargetPlatformTitle,
44+
subTitle: localization.debugTargetPlatformSubtitle(localization.getTranslation(Provider.of<GlobalViewModel>(context).getCurrentPlatform())),
45+
onClick: viewModel.onTargetPlatformClicked,
46+
),
47+
DebugRowItem(
48+
key: Keys.debugThemeMode,
49+
title: localization.debugThemeModeTitle,
50+
subTitle: localization.debugThemeModeSubtitle,
51+
onClick: viewModel.onThemeModeClicked,
52+
),
53+
DebugRowTitle(title: localization.debugLocaleTitle),
54+
DebugRowItem(
55+
key: Keys.debugSelectLanguage,
56+
title: localization.debugLocaleSelector,
57+
subTitle: localization.debugLocaleCurrentLanguage(Provider.of<GlobalViewModel>(context).getCurrentLanguage()),
58+
onClick: viewModel.onSelectLanguageClicked,
59+
),
60+
DebugRowSwitchItem(
61+
key: Keys.debugShowTranslations,
62+
title: localization.debugShowTranslations,
63+
value: Provider.of<GlobalViewModel>(context, listen: false).showsTranslationKeys,
64+
onChanged: (_) => Provider.of<GlobalViewModel>(context, listen: false).toggleTranslationKeys(),
65+
),
66+
DebugRowTitle(title: localization.debugLicensesTitle),
67+
DebugRowItem(
68+
key: Keys.debugLicense,
69+
title: localization.debugLicensesGoTo,
70+
onClick: viewModel.onLicensesClicked,
71+
),
72+
DebugRowTitle(title: localization.debugDatabase),
73+
DebugRowItem(
74+
key: Keys.debugDatabase,
75+
title: localization.debugViewDatabase,
76+
onClick: viewModel.goToDatabase,
77+
),
78+
DebugRowTitle(title: localization.debugPermissionsTitle),
79+
DebugRowItem(
80+
key: Keys.debugPermissionAnalytics,
81+
title: localization.debugPermissionsShowAnalyticsPermission,
82+
onClick: viewModel.goToAnalyticsPermissionScreen,
83+
),
84+
DebugRowItem(
85+
key: Keys.debugPermissionAnalyticsReset,
86+
title: localization.debugPermissionResetAnalytics,
87+
onClick: viewModel.resetAnalyticsPermission,
88+
),
89+
],
9590
),
9691
);
9792
}

lib/screen/license/license_screen.dart

+26-36
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import 'package:flutter/material.dart';
2-
import 'package:flutter/services.dart';
32
import 'package:flutter_navigation_generator_annotations/flutter_navigation_generator_annotations.dart';
43
import 'package:flutter_template/di/injectable.dart';
54
import 'package:flutter_template/styles/theme_dimens.dart';
65
import 'package:flutter_template/viewmodel/license/license_viewmodel.dart';
7-
import 'package:flutter_template/widget/general/styled/flutter_template_back_button.dart';
6+
import 'package:flutter_template/widget/general/simple_screen/base_screen.dart';
87
import 'package:flutter_template/widget/provider/provider_widget.dart';
98

109
@flutterRoute
@@ -21,41 +20,32 @@ class LicenseScreenState extends State<LicenseScreen> {
2120
Widget build(BuildContext context) {
2221
return ProviderWidget<LicenseViewModel>(
2322
create: getIt.call,
24-
consumerWithThemeAndLocalization: (context, viewModel, child, theme, localization) => Scaffold(
25-
backgroundColor: theme.colorsTheme.background,
26-
appBar: AppBar(
27-
systemOverlayStyle: SystemUiOverlayStyle.light,
28-
leading: FlutterTemplateBackButton.light(onClick: viewModel.onBackClicked),
29-
title: Text(localization.debugLicensesTitle),
30-
backgroundColor: theme.colorsTheme.primary,
31-
),
32-
body: ListView.builder(
33-
padding: const EdgeInsets.all(ThemeDimens.padding16),
34-
itemCount: viewModel.licenses.length,
35-
itemBuilder: (context, index) {
36-
final item = viewModel.licenses[index];
37-
return Card(
38-
color: theme.colorsTheme.background,
39-
child: Padding(
40-
padding: const EdgeInsets.all(ThemeDimens.padding16),
41-
child: Column(
42-
crossAxisAlignment: CrossAxisAlignment.start,
43-
children: [
44-
Text(
45-
item.name,
46-
style: theme.coreTextTheme.titleNormal,
47-
),
48-
Container(height: ThemeDimens.padding8),
49-
Text(
50-
item.license,
51-
style: theme.coreTextTheme.bodySmall,
52-
),
53-
],
54-
),
23+
consumerWithThemeAndLocalization: (context, viewModel, child, theme, localization) => BaseScreen.builder(
24+
title: localization.debugLicensesTitle,
25+
itemCount: viewModel.licenses.length,
26+
itemBuilder: (context, index) {
27+
final item = viewModel.licenses[index];
28+
return Card(
29+
color: theme.colorsTheme.background,
30+
child: Padding(
31+
padding: const EdgeInsets.all(ThemeDimens.padding16),
32+
child: Column(
33+
crossAxisAlignment: CrossAxisAlignment.start,
34+
children: [
35+
Text(
36+
item.name,
37+
style: theme.coreTextTheme.titleNormal,
38+
),
39+
Container(height: ThemeDimens.padding8),
40+
Text(
41+
item.license,
42+
style: theme.coreTextTheme.bodySmall,
43+
),
44+
],
5545
),
56-
);
57-
},
58-
),
46+
),
47+
);
48+
},
5949
),
6050
);
6151
}

lib/screen/todo/todo_list/todo_list_screen.dart

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class TodoListScreenState extends State<TodoListScreen> {
2727
consumerWithThemeAndLocalization: (context, viewModel, child, theme, localization) {
2828
final errorKey = viewModel.errorKey;
2929
return BaseScreen.child(
30+
padding: EdgeInsets.zero,
3031
title: localization.todoTitle,
3132
actions: [
3233
ActionItem(

lib/widget/general/simple_screen/base_screen_header.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class BaseScreenHeader extends StatelessWidget {
2424
childBuilder: (context, theme, localization) {
2525
final leading = [
2626
if (ModalRoute.of(context)?.impliesAppBarDismissal ?? false) ...[
27-
FlutterTemplateBackButton.light(onClick: onBackTapped),
27+
FlutterTemplateBackButton.light(onClick: onBackTapped ?? Navigator.of(context).pop),
2828
const SizedBox(width: 24),
2929
],
3030
];

0 commit comments

Comments
 (0)