Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Darkmode #61

Merged
merged 25 commits into from
Jan 7, 2021
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:smooth_app/functions/launchURL.dart';
import 'package:smooth_ui_library/buttons/smooth_simple_button.dart';
import 'package:smooth_ui_library/dialogs/smooth_alert_dialog.dart';
import 'package:smooth_ui_library/dialogs/smooth_AlertDialog.dart';
M123-dev marked this conversation as resolved.
Show resolved Hide resolved
import 'package:smooth_ui_library/widgets/smooth_listTile.dart';

Launcher launcher = Launcher();
Expand All @@ -30,6 +30,7 @@ class UserContributionView extends StatelessWidget {
Widget build(BuildContext context) {
return Material(
child: Container(
color: Theme.of(context).primaryColor,
height: MediaQuery.of(context).size.height * 0.9,
child: Stack(
children: <Widget>[
Expand Down Expand Up @@ -102,7 +103,7 @@ class UserContributionView extends StatelessWidget {
context: context,
builder: (BuildContext context) {
return SmoothAlertDialog(
//context: context,
context: context,
close: false,
title: AppLocalizations.of(context).contribute_contribute_header,
body: Column(
Expand Down Expand Up @@ -163,7 +164,7 @@ class UserContributionView extends StatelessWidget {
builder: (BuildContext context) {
return SmoothAlertDialog(
title: AppLocalizations.of(context).contribute_develop,
//context: context,
context: context,
body: Column(
children: <Widget>[
Text(
Expand Down Expand Up @@ -216,7 +217,7 @@ class UserContributionView extends StatelessWidget {
builder: (BuildContext context) {
return SmoothAlertDialog(
title: AppLocalizations.of(context).contribute_translate_header,
//context: context,
context: context,
body: Column(
children: <Widget>[
Text(
Expand Down Expand Up @@ -247,7 +248,7 @@ class UserContributionView extends StatelessWidget {
context: context,
builder: (BuildContext context) {
return SmoothAlertDialog(
//context: context,
context: context,
body: Column(
children: <Widget>[
Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class UserPreferencesView extends StatelessWidget {
(screenSize.width - _TYPICAL_PADDING_OR_MARGIN * 3) / 2;
return Material(
child: Container(
color: Theme.of(context).primaryColor,
height: screenSize.height * 0.9,
child: Stack(
children: <Widget>[
Expand All @@ -62,6 +63,7 @@ class UserPreferencesView extends StatelessWidget {
),
),
_generateGroups(
context,
screenSize.width,
userPreferences,
userPreferencesModel,
Expand Down Expand Up @@ -125,6 +127,7 @@ class UserPreferencesView extends StatelessWidget {
}

Widget _generatePreferenceRow(
final BuildContext context,
final Attribute variable,
final double screenWidth,
final UserPreferences userPreferences,
Expand All @@ -144,7 +147,7 @@ class UserPreferencesView extends StatelessWidget {
margin: const EdgeInsets.all(_TYPICAL_PADDING_OR_MARGIN),
width: screenWidth,
decoration: BoxDecoration(
color: Colors.black.withAlpha(5),
color: Theme.of(context).cardColor,
borderRadius: const BorderRadius.all(Radius.circular(20.0))),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
Expand All @@ -169,10 +172,13 @@ class UserPreferencesView extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(variable.settingName),
Text(
variable.settingName,
style: TextStyle(color: Theme.of(context).accentColor),
),
SliderTheme(
data: SliderThemeData(
//thumbColor: Colors.black,
//thumbColor: Colors.red,
activeTrackColor: Colors.black54,
valueIndicatorColor: getColor(userPreferencesModel
.getAttributeValueIndex(variable.id, userPreferences)),
Expand All @@ -189,7 +195,7 @@ class UserPreferencesView extends StatelessWidget {
.toDouble(),
onChanged: (double value) => userPreferences.setImportance(
variable.id, value.toInt()),
activeColor: Colors.black,
activeColor: Theme.of(context).primaryColor,
label: importance.name,
),
),
Expand All @@ -202,6 +208,7 @@ class UserPreferencesView extends StatelessWidget {
}

Widget _generateGroups(
final BuildContext context,
final double screenWidth,
final UserPreferences userPreferences,
final UserPreferencesModel userPreferencesModel,
Expand All @@ -213,6 +220,7 @@ class UserPreferencesView extends StatelessWidget {
children: List<Widget>.generate(
groups.length,
(int index) => _generateGroup(
context,
groups[index],
screenWidth,
userPreferences,
Expand All @@ -222,22 +230,24 @@ class UserPreferencesView extends StatelessWidget {
}

Widget _generateGroup(
final BuildContext context,
final AttributeGroup group,
final double screenWidth,
final UserPreferences userPreferences,
final UserPreferencesModel userPreferencesModel,
) =>
!userPreferences.isAttributeGroupVisible(group)
? _generateGroupTitle(group, userPreferences)
? _generateGroupTitle(context, group, userPreferences)
: Column(
mainAxisSize: MainAxisSize.min,
children: List<Widget>.generate(
group.attributes.length + 2,
(int index) => index == 0
? _generateGroupTitle(group, userPreferences)
? _generateGroupTitle(context, group, userPreferences)
: index == 1
? _generateGroupWarning(group.warning)
: _generatePreferenceRow(
context,
group.attributes[index - 2],
screenWidth,
userPreferences,
Expand All @@ -247,15 +257,19 @@ class UserPreferencesView extends StatelessWidget {
);

Widget _generateGroupTitle(
final BuildContext context,
M123-dev marked this conversation as resolved.
Show resolved Hide resolved
final AttributeGroup group,
final UserPreferences userPreferences,
) =>
GestureDetector(
child: Container(
color: Colors.grey[300],
color: Theme.of(context).primaryColor,
width: double.infinity,
padding: const EdgeInsets.all(_TYPICAL_PADDING_OR_MARGIN),
child: Text(group.name),
child: Text(
group.name,
style: TextStyle(color: Theme.of(context).accentColor),
),
),
onTap: () => userPreferences.setAttributeGroupVisibility(
group, !userPreferences.isAttributeGroupVisible(group)));
Expand Down
4 changes: 3 additions & 1 deletion packages/smooth_app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,7 @@
"support": "Support",
"@support": { },
"error": "Something went wrong",
"@error": { }
"@error": { },
"darkmode": "Darkmode",
"@darkmode": { }
}
29 changes: 23 additions & 6 deletions packages/smooth_app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'package:smooth_app/pages/continuous_scan_page.dart';
import 'package:smooth_app/pages/profile_page.dart';
import 'package:smooth_app/pages/tracking_page.dart';
import 'package:smooth_app/themes/smooth_theme.dart';
import 'package:smooth_app/themes/theme_provider.dart';
import 'package:smooth_ui_library/navigation/models/smooth_navigation_action_model.dart';
import 'package:smooth_ui_library/navigation/models/smooth_navigation_layout_model.dart';
import 'package:smooth_ui_library/navigation/models/smooth_navigation_screen_model.dart';
Expand Down Expand Up @@ -42,6 +43,7 @@ class MyApp extends StatefulWidget {
}

class _MyAppState extends State<MyApp> {
final DarkThemeProvider themeChangeProvider = DarkThemeProvider();
UserPreferences userPreferences;
UserPreferencesModel userPreferencesModel;

Expand All @@ -50,6 +52,8 @@ class _MyAppState extends State<MyApp> {
userPreferencesModel =
await UserPreferencesModel.getUserPreferencesModel(context);
await userPreferences.init(userPreferencesModel);
themeChangeProvider.darkTheme =
await themeChangeProvider.userThemePreference.getTheme();
}

@override
Expand All @@ -64,12 +68,20 @@ class _MyAppState extends State<MyApp> {
value: userPreferences),
ChangeNotifierProvider<UserPreferencesModel>.value(
value: userPreferencesModel),
ChangeNotifierProvider<DarkThemeProvider>.value(
value: themeChangeProvider),
],
child: MaterialApp(
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
home: SmoothApp(),
theme: SmoothThemes.getSmoothThemeData(),
child: Consumer<DarkThemeProvider>(
builder: (BuildContext context, value, Widget child) {
return MaterialApp(
localizationsDelegates:
AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
theme: SmoothThemes.getSmoothThemeData(
themeChangeProvider.darkTheme, context),
home: SmoothApp(),
);
},
),
);
}
Expand All @@ -90,7 +102,8 @@ class SmoothApp extends StatelessWidget {
animationDuration: 300,
animationCurve: Curves.easeInOutBack,
borderRadius: 20.0,
color: Colors.white60,
color: Theme.of(context).bottomAppBarColor,
textColor: Colors.red,
classicMode: true,
);
}
Expand All @@ -113,6 +126,7 @@ class SmoothApp extends StatelessWidget {
padding: EdgeInsets.all(_navigationIconPadding),
child: SvgPicture.asset(
'assets/ikonate_thin/search.svg',
color: Theme.of(context).accentColor,
width: _navigationIconSize,
height: _navigationIconSize,
),
Expand Down Expand Up @@ -162,6 +176,7 @@ class SmoothApp extends StatelessWidget {
padding: EdgeInsets.all(_navigationIconPadding),
child: SvgPicture.asset(
'assets/ikonate_thin/add.svg',
color: Theme.of(context).accentColor,
width: _navigationIconSize,
height: _navigationIconSize,
),
Expand Down Expand Up @@ -196,6 +211,7 @@ class SmoothApp extends StatelessWidget {
padding: EdgeInsets.all(_navigationIconPadding),
child: SvgPicture.asset(
'assets/ikonate_thin/activity.svg',
color: Theme.of(context).accentColor,
width: _navigationIconSize,
height: _navigationIconSize,
),
Expand Down Expand Up @@ -230,6 +246,7 @@ class SmoothApp extends StatelessWidget {
padding: EdgeInsets.all(_navigationIconPadding),
child: SvgPicture.asset(
'assets/ikonate_thin/person.svg',
color: Theme.of(context).accentColor,
width: _navigationIconSize,
height: _navigationIconSize,
),
Expand Down
5 changes: 1 addition & 4 deletions packages/smooth_app/lib/pages/contribution_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ class CollaborationPage extends StatelessWidget {
),
Text(
AppLocalizations.of(context).featureInProgress,
style: Theme.of(context)
.textTheme
.subtitle1
.copyWith(color: Colors.black),
style: Theme.of(context).textTheme.subtitle1,
),
const SizedBox(
height: 28.0,
Expand Down
26 changes: 23 additions & 3 deletions packages/smooth_app/lib/pages/profile_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import 'package:smooth_app/bottom_sheet_views/user_preferences_view.dart';
import 'package:smooth_app/functions/launchURL.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:smooth_app/temp/user_preferences.dart';
import 'package:smooth_app/themes/theme_provider.dart';
import 'package:smooth_ui_library/widgets/smooth_toggle.dart';
import 'package:smooth_ui_library/buttons/smooth_simple_button.dart';
import 'package:smooth_ui_library/dialogs/smooth_alert_dialog.dart';
import 'package:smooth_ui_library/dialogs/smooth_AlertDialog.dart';
import 'package:smooth_ui_library/widgets/smooth_listTile.dart';

Launcher launcher = Launcher();
Expand All @@ -25,6 +26,7 @@ class ProfilePage extends StatefulWidget {
class _ProfilePageState extends State<ProfilePage> {
@override
Widget build(BuildContext context) {
final DarkThemeProvider themeChange = context.watch<DarkThemeProvider>();
final UserPreferences userPreferences = context.watch<UserPreferences>();
return Scaffold(
body: Column(
Expand Down Expand Up @@ -62,6 +64,21 @@ class _ProfilePageState extends State<ProfilePage> {
userPreferences.setMlKitState(newValue)),
),

//Darkmode
SmoothListTile(
text: AppLocalizations.of(context).darkmode,
onPressed: null,
leadingWidget: SmoothToggle(
value: themeChange.darkTheme,
width: 80.0,
height: 38.0,
textLeft: AppLocalizations.of(context).yes,
textRight: AppLocalizations.of(context).no,
onChanged: (bool newValue) async {
themeChange.darkTheme = newValue;
}),
),

//Configure Preferences
SmoothListTile(
text: AppLocalizations.of(context).configurePreferences,
Expand Down Expand Up @@ -95,7 +112,8 @@ class _ProfilePageState extends State<ProfilePage> {
//Support
SmoothListTile(
text: AppLocalizations.of(context).support,
leadingWidget: const Icon(Icons.launch),
leadingWidget:
Icon(Icons.launch, color: Theme.of(context).accentColor),
onPressed: () => launcher.launchURL(
context, 'https://openfoodfacts.uservoice.com/', false),
),
Expand All @@ -108,6 +126,7 @@ class _ProfilePageState extends State<ProfilePage> {
context: context,
builder: (BuildContext context) {
//ToDo: Show App Icon !!! 2x !!! + onTap open App in Store https://pub.dev/packages/open_appstore

return SmoothAlertDialog(
close: false,
body: Column(
Expand Down Expand Up @@ -137,7 +156,8 @@ class _ProfilePageState extends State<ProfilePage> {
return Column(
children: <Widget>[
ListTile(
leading: const Icon(Icons.no_sim_outlined),
leading: Icon(Icons.no_sim_outlined,
color: Theme.of(context).accentColor),
title: Text(
snapshot.data.appName.toString(),
style:
Expand Down
5 changes: 1 addition & 4 deletions packages/smooth_app/lib/pages/tracking_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ class TrackingPage extends StatelessWidget {
),
Text(
AppLocalizations.of(context).featureInProgress,
style: Theme.of(context)
.textTheme
.subtitle1
.copyWith(color: Colors.black),
style: Theme.of(context).textTheme.subtitle1,
),
],
),
Expand Down
Loading