-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8e2e51c
commit 1912099
Showing
15 changed files
with
339 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,38 @@ | ||
import 'package:device_preview/device_preview.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/services.dart'; | ||
import 'package:fst_app_flutter/models/theme_model.dart'; | ||
import 'package:fst_app_flutter/routing/generate_routes.dart'; | ||
|
||
import 'package:fst_app_flutter/utils/app_theme.dart'; | ||
import 'package:provider/provider.dart'; | ||
|
||
void main() { | ||
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle( | ||
statusBarColor: AppTheme.apptheme.primaryColor, | ||
)); | ||
|
||
runApp(DevicePreview(child: FSTApp())); | ||
} | ||
|
||
class FSTApp extends StatelessWidget { | ||
// This widget is the root of the application. | ||
@override | ||
Widget build(BuildContext context) { | ||
return MaterialApp( | ||
debugShowCheckedModeBanner: false, | ||
theme: AppTheme.apptheme, | ||
title: 'FST App', | ||
builder: DevicePreview.appBuilder, | ||
onGenerateRoute: Router.generateRoute, | ||
); | ||
|
||
return ChangeNotifierProvider( | ||
create: (context) => ThemeModel(), | ||
child: Consumer<ThemeModel>( | ||
builder:(context, themeModel, child) { | ||
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle( | ||
statusBarColor: AppTheme.getTheme(themeModel.selectedTheme,MediaQuery.platformBrightnessOf(context)).primaryColor, | ||
)); | ||
return MaterialApp( | ||
debugShowCheckedModeBanner: false, | ||
theme: AppTheme.getTheme(ThemeMode.light, MediaQuery.platformBrightnessOf(context)), | ||
darkTheme: AppTheme.getTheme(ThemeMode.dark, MediaQuery.platformBrightnessOf(context)), | ||
themeMode: themeModel.selectedTheme, | ||
title: 'FST App', | ||
builder: DevicePreview.appBuilder, | ||
onGenerateRoute: Router.generateRoute, | ||
); | ||
}, | ||
)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import 'package:flutter/cupertino.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:fst_app_flutter/preferences/theme_preference.dart'; | ||
|
||
class ThemeModel with ChangeNotifier { | ||
ThemePreference themePreference = ThemePreference(); | ||
//set to system theme by default | ||
ThemeMode _currentTheme = ThemeMode.system; | ||
|
||
ThemeMode get selectedTheme => _currentTheme; | ||
|
||
set switchThemeTo(ThemeMode themeMode) { | ||
_currentTheme = themeMode; | ||
themePreference.setThemeMode(themeMode); | ||
notifyListeners(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:shared_preferences/shared_preferences.dart'; | ||
|
||
class ThemePreference { | ||
var lightThemeStatus = ThemeMode.light.toString(); | ||
var systemThemeStatus = ThemeMode.system.toString(); | ||
var darkThemeStatus = ThemeMode.dark.toString(); | ||
SharedPreferences prefs; | ||
|
||
_initializeFromDisk() async { | ||
prefs = await SharedPreferences.getInstance(); | ||
} | ||
|
||
setThemeMode(ThemeMode option) async { | ||
_initializeFromDisk(); | ||
if (option == ThemeMode.dark) { | ||
prefs.setBool(darkThemeStatus, true); | ||
prefs.setBool(lightThemeStatus, false); | ||
prefs.setBool(systemThemeStatus, false); | ||
} else if (option == ThemeMode.light) { | ||
prefs.setBool(darkThemeStatus, false); | ||
prefs.setBool(lightThemeStatus, true); | ||
prefs.setBool(systemThemeStatus, false); | ||
} else { | ||
prefs.setBool(darkThemeStatus, false); | ||
prefs.setBool(lightThemeStatus, false); | ||
prefs.setBool(systemThemeStatus, true); | ||
} | ||
} | ||
|
||
ThemeMode get mode { | ||
_initializeFromDisk(); | ||
if (prefs.getBool(darkThemeStatus) ?? false) { | ||
return ThemeMode.dark; | ||
} else if (prefs.getBool(lightThemeStatus) ?? false) { | ||
return ThemeMode.light; | ||
} else { | ||
return ThemeMode.system; | ||
} | ||
} | ||
} |
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
134 changes: 70 additions & 64 deletions
134
lib/screens/contact_screen/contact_view_mobile_state.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.