Skip to content

Commit

Permalink
#336: used base screen on screens in the app
Browse files Browse the repository at this point in the history
  • Loading branch information
jorre127 committed Oct 11, 2024
1 parent b53fccb commit 8ad0a23
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 104 deletions.
91 changes: 40 additions & 51 deletions lib/screen/login/login_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:flutter_template/di/injectable.dart';
import 'package:flutter_template/styles/theme_dimens.dart';
import 'package:flutter_template/util/keys.dart';
import 'package:flutter_template/viewmodel/login/login_viewmodel.dart';
import 'package:flutter_template/widget/general/status_bar.dart';
import 'package:flutter_template/widget/general/simple_screen/base_screen.dart';
import 'package:flutter_template/widget/general/styled/flutter_template_button.dart';
import 'package:flutter_template/widget/general/styled/flutter_template_input_field.dart';
import 'package:flutter_template/widget/general/styled/flutter_template_progress_indicator.dart';
Expand All @@ -26,57 +26,46 @@ class LoginScreenState extends State<LoginScreen> {
Widget build(BuildContext context) {
return ProviderWidget<LoginViewModel>(
create: () => getIt()..init(),
consumerWithThemeAndLocalization: (context, viewModel, child, theme, localization) => StatusBar.animated(
isDarkStyle: theme.isDarkTheme,
child: Scaffold(
backgroundColor: theme.colorsTheme.background,
body: SafeArea(
child: Container(
width: double.infinity,
padding: const EdgeInsets.all(ThemeDimens.padding16),
child: Column(
children: [
Container(height: ThemeDimens.padding16),
Text(
'Login',
style: theme.coreTextTheme.titleNormal,
textAlign: TextAlign.center,
),
Container(height: ThemeDimens.padding32),
Text(
'Just fill in some text. There is no validator for the login',
style: theme.coreTextTheme.labelButtonSmall,
),
Container(height: ThemeDimens.padding32),
FlutterTemplateInputField(
key: Keys.emailInput,
enabled: !viewModel.isLoading,
onChanged: viewModel.onEmailUpdated,
hint: 'Email',
),
Container(height: ThemeDimens.padding16),
FlutterTemplateInputField(
key: Keys.passwordInput,
enabled: !viewModel.isLoading,
onChanged: viewModel.onPasswordUpdated,
hint: 'Password',
),
Container(height: ThemeDimens.padding16),
if (viewModel.isLoading) ...[
const FlutterTemplateProgressIndicator.light(),
] else ...[
FlutterTemplateButton(
key: Keys.loginButton,
isEnabled: viewModel.isLoginEnabled,
text: 'Login',
onClick: viewModel.onLoginClicked,
),
],
],
),
),
consumerWithThemeAndLocalization: (context, viewModel, child, theme, localization) => BaseScreen(
showHeader: false,
children: [
Container(height: ThemeDimens.padding16),
Text(
'Login',
style: theme.coreTextTheme.titleNormal,
textAlign: TextAlign.center,
),
Container(height: ThemeDimens.padding32),
Text(
'Just fill in some text. There is no validator for the login',
style: theme.coreTextTheme.labelButtonSmall,
),
Container(height: ThemeDimens.padding32),
FlutterTemplateInputField(
key: Keys.emailInput,
enabled: !viewModel.isLoading,
onChanged: viewModel.onEmailUpdated,
hint: 'Email',
),
),
Container(height: ThemeDimens.padding16),
FlutterTemplateInputField(
key: Keys.passwordInput,
enabled: !viewModel.isLoading,
onChanged: viewModel.onPasswordUpdated,
hint: 'Password',
),
Container(height: ThemeDimens.padding16),
if (viewModel.isLoading) ...[
const FlutterTemplateProgressIndicator.light(),
] else ...[
FlutterTemplateButton(
key: Keys.loginButton,
isEnabled: viewModel.isLoginEnabled,
text: 'Login',
onClick: viewModel.onLoginClicked,
),
],
],
),
);
}
Expand Down
95 changes: 42 additions & 53 deletions lib/screen/permission/analytics_permission_screen.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_navigation_generator_annotations/flutter_navigation_generator_annotations.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:flutter_template/di/injectable.dart';
import 'package:flutter_template/styles/theme_assets.dart';
import 'package:flutter_template/viewmodel/permission/analytics_permission_viewmodel.dart';
import 'package:flutter_template/widget/general/simple_screen/base_screen.dart';
import 'package:flutter_template/widget/general/styled/flutter_template_button.dart';
import 'package:flutter_template/widget/provider/provider_widget.dart';

Expand All @@ -16,62 +16,51 @@ class AnalyticsPermissionScreen extends StatelessWidget {
Widget build(BuildContext context) {
return ProviderWidget<AnalyticsPermissionViewModel>(
create: () => getIt()..init(),
childBuilderWithViewModel: (context, viewModel, theme, localization) => AnnotatedRegion<SystemUiOverlayStyle>(
value: theme.isDarkTheme ? SystemUiOverlayStyle.light : SystemUiOverlayStyle.dark,
child: Scaffold(
backgroundColor: theme.colorsTheme.permissionScreenBackground,
body: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 16.0,
vertical: 32,
),
child: Column(
children: [
Expanded(
child: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Spacer(),
Expanded(
flex: 5,
child: SvgPicture.asset(
ThemeAssets.analyticsImage(context),
alignment: Alignment.center,
fit: BoxFit.scaleDown,
),
),
const Spacer(),
const SizedBox(height: 32),
Text(
localization.permissionAnalyticsTitle,
style: theme.coreTextTheme.titleNormal,
),
const SizedBox(height: 16),
Text(
localization.permissionAnalyticsDescription,
textAlign: TextAlign.center,
style: theme.coreTextTheme.bodyNormal,
),
const Spacer(),
],
childBuilderWithViewModel: (context, viewModel, theme, localization) => BaseScreen(
showHeader: false,
children: [
Expanded(
child: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Spacer(),
Expanded(
flex: 5,
child: SvgPicture.asset(
ThemeAssets.analyticsImage(context),
alignment: Alignment.center,
fit: BoxFit.scaleDown,
),
),
),
const SizedBox(height: 8),
FlutterTemplateButton(
text: localization.permissionButtonAccept,
onClick: viewModel.onAcceptClicked,
),
const SizedBox(height: 8),
FlutterTemplateButton.text(
text: localization.permissionButtonMoreInfo,
onClick: viewModel.onMoreInfoClicked,
),
],
const Spacer(),
const SizedBox(height: 32),
Text(
localization.permissionAnalyticsTitle,
style: theme.coreTextTheme.titleNormal,
),
const SizedBox(height: 16),
Text(
localization.permissionAnalyticsDescription,
textAlign: TextAlign.center,
style: theme.coreTextTheme.bodyNormal,
),
const Spacer(),
],
),
),
),
),
const SizedBox(height: 8),
FlutterTemplateButton(
text: localization.permissionButtonAccept,
onClick: viewModel.onAcceptClicked,
),
const SizedBox(height: 8),
FlutterTemplateButton.text(
text: localization.permissionButtonMoreInfo,
onClick: viewModel.onMoreInfoClicked,
),
],
),
);
}
Expand Down

0 comments on commit 8ad0a23

Please sign in to comment.