Skip to content

Commit 17f29a9

Browse files
feature/dark_mode (ibhavikmakwana#12)
* ✨ Implemented a Dark Mode, * ✨ Adding MobX for State Management * ♻️ Added release notes .txt for codemagic.io
1 parent 953c1cf commit 17f29a9

File tree

6 files changed

+115
-12
lines changed

6 files changed

+115
-12
lines changed

lib/imports.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ export 'package:flutter_playground/ui/text/TextExamples.dart';
3939
export 'package:flutter_playground/ui/text/TextSpan.dart';
4040
export 'package:flutter_playground/ui/text/TextUnderline.dart';
4141
export 'package:flutter_playground/ui/tooltip/tooltip.dart';
42-
export 'package:flutter_playground/utils/Strings.dart';
42+
export 'package:flutter_playground/utils/Strings.dart';

lib/main.dart

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,47 @@
33
// found in the LICENSE file.
44

55
import 'package:flutter/material.dart';
6+
import 'package:flutter_mobx/flutter_mobx.dart';
7+
import 'package:flutter_playground/store/theme_store.dart';
68
import 'package:flutter_playground/ui/app_bar_bottom/appbar_bottom.dart';
79
import 'package:flutter_playground/ui/datatable/data_table_example.dart';
810
import 'package:flutter_playground/ui/expanded_example/expanded_example.dart';
911
import 'package:flutter_playground/ui/flare/flare_example.dart';
1012
import 'package:flutter_playground/ui/quick_actions/QuickActionsExample.dart';
1113
import 'package:flutter_playground/ui/transform/transform_example.dart';
1214
import 'package:flutter_playground/ui/wrap/wrap_example.dart';
15+
import 'package:google_fonts/google_fonts.dart';
16+
import 'package:provider/provider.dart';
1317

1418
import 'imports.dart';
1519

16-
void main() => runApp(MyApp());
20+
void main() =>
21+
runApp(
22+
Provider(
23+
create: (_) => ThemeStore(),
24+
child: MyApp(),
25+
),
26+
);
1727

18-
class MyApp extends StatelessWidget {
28+
class MyApp extends StatelessObserverWidget {
1929
@override
2030
Widget build(BuildContext context) {
2131
return MaterialApp(
2232
title: Strings.appName,
2333
theme: ThemeData(
24-
fontFamily: Strings.fontRobotoRegular,
34+
brightness: Brightness.light,
35+
fontFamily: GoogleFonts
36+
.poppins()
37+
.fontFamily,
38+
),
39+
themeMode: Provider
40+
.of<ThemeStore>(context)
41+
.themeMode,
42+
darkTheme: ThemeData(
43+
brightness: Brightness.dark,
44+
fontFamily: GoogleFonts
45+
.poppins()
46+
.fontFamily,
2547
),
2648
debugShowCheckedModeBanner: false,
2749
home: MyHomePage(title: Strings.appName),
@@ -160,6 +182,10 @@ class _MyHomePageState extends State<MyHomePage>
160182
@override
161183
Widget build(BuildContext context) {
162184
return Scaffold(
185+
floatingActionButton: FloatingActionButton(
186+
onPressed: onFabPressed,
187+
child: Icon(Icons.lightbulb_outline),
188+
),
163189
appBar: AppBar(
164190
title: Text(widget.title),
165191
actions: <Widget>[
@@ -210,6 +236,9 @@ class _MyHomePageState extends State<MyHomePage>
210236
);
211237
}
212238
}
239+
240+
void onFabPressed() =>
241+
Provider.of<ThemeStore>(context, listen: false).changeTheme();
213242
}
214243

215244
// The list displayed by this app.

lib/store/theme_store.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:mobx/mobx.dart';
3+
4+
part 'theme_store.g.dart';
5+
6+
class ThemeStore = _ThemeStore with _$ThemeStore;
7+
8+
abstract class _ThemeStore with Store {
9+
@observable
10+
ThemeMode themeMode = ThemeMode.light;
11+
12+
@action
13+
changeTheme() {
14+
themeMode == ThemeMode.light
15+
? themeMode = ThemeMode.dark
16+
: themeMode = ThemeMode.light;
17+
}
18+
}

lib/store/theme_store.g.dart

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pubspec.yaml

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
name: flutter_playground
22
description: A Flutter application contains a list of Flutter Examples.
3-
version: 1.2.1+4
3+
4+
# The following defines the version and build number for your application.
5+
# A version number is three numbers separated by dots, like 1.2.43
6+
# followed by an optional build number separated by a +.
7+
# Both the version and the builder number may be overridden in flutter
8+
# build by specifying --build-name and --build-number, respectively.
9+
# In Android, build-name is used as versionName while build-number used as versionCode.
10+
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
11+
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
12+
# Read more about iOS versioning at
13+
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
14+
version: 1.2.2+5
15+
16+
environment:
17+
sdk: ">=2.7.0-dev.2.1 <3.0.0"
418

519
dependencies:
620
flutter:
@@ -13,10 +27,16 @@ dependencies:
1327
flare_flutter:
1428
# firebase_admob: ^0.9.0+3
1529
quick_actions:
30+
google_fonts: ^0.3.2
31+
mobx: ^0.3.6
32+
flutter_mobx: 0.3.4
33+
provider: ^4.0.1
1634

1735
dev_dependencies:
1836
flutter_test:
1937
sdk: flutter
38+
build_runner: 1.3.1
39+
mobx_codegen: ^0.3.5
2040

2141
# For information on the generic Dart part of this file, see the
2242
# following page: https://www.dartlang.org/tools/pub/pubspec
@@ -31,10 +51,4 @@ flutter:
3151

3252
# To add assets to your application, add an assets section, like this:
3353
assets:
34-
- assets/
35-
36-
fonts:
37-
- family: Roboto
38-
fonts:
39-
- asset: assets/fonts/Roboto-Regular.ttf
40-
style: normal
54+
- assets/

release_notes.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Dark Mode
2+
- Minor bug fixes

0 commit comments

Comments
 (0)