Skip to content

Commit cdfd420

Browse files
committed
🎨 Settings
1 parent 4ab635b commit cdfd420

File tree

13 files changed

+377
-13
lines changed

13 files changed

+377
-13
lines changed

‎.dart_tool/package_config.json‎

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@
5555
"packageUri": "lib/",
5656
"languageVersion": "2.0"
5757
},
58+
{
59+
"name": "day_night_switch",
60+
"rootUri": "file:///Users/parthmaniar/development/flutter/.pub-cache/hosted/pub.dartlang.org/day_night_switch-0.0.2+1",
61+
"packageUri": "lib/",
62+
"languageVersion": "2.1"
63+
},
5864
{
5965
"name": "flutter",
6066
"rootUri": "file:///Users/parthmaniar/development/flutter/packages/flutter",
@@ -67,6 +73,12 @@
6773
"packageUri": "lib/",
6874
"languageVersion": "2.2"
6975
},
76+
{
77+
"name": "flutter_web_plugins",
78+
"rootUri": "file:///Users/parthmaniar/development/flutter/packages/flutter_web_plugins",
79+
"packageUri": "lib/",
80+
"languageVersion": "2.0"
81+
},
7082
{
7183
"name": "image",
7284
"rootUri": "file:///Users/parthmaniar/development/flutter/.pub-cache/hosted/pub.dartlang.org/image-2.1.12",
@@ -85,6 +97,12 @@
8597
"packageUri": "lib/",
8698
"languageVersion": "1.12"
8799
},
100+
{
101+
"name": "nested",
102+
"rootUri": "file:///Users/parthmaniar/development/flutter/.pub-cache/hosted/pub.dartlang.org/nested-0.0.4",
103+
"packageUri": "lib/",
104+
"languageVersion": "2.2"
105+
},
88106
{
89107
"name": "path",
90108
"rootUri": "file:///Users/parthmaniar/development/flutter/.pub-cache/hosted/pub.dartlang.org/path-1.6.4",
@@ -97,12 +115,42 @@
97115
"packageUri": "lib/",
98116
"languageVersion": "2.4"
99117
},
118+
{
119+
"name": "provider",
120+
"rootUri": "file:///Users/parthmaniar/development/flutter/.pub-cache/hosted/pub.dartlang.org/provider-4.1.0",
121+
"packageUri": "lib/",
122+
"languageVersion": "2.7"
123+
},
100124
{
101125
"name": "quiver",
102126
"rootUri": "file:///Users/parthmaniar/development/flutter/.pub-cache/hosted/pub.dartlang.org/quiver-2.1.3",
103127
"packageUri": "lib/",
104128
"languageVersion": "2.0"
105129
},
130+
{
131+
"name": "shared_preferences",
132+
"rootUri": "file:///Users/parthmaniar/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.7+1",
133+
"packageUri": "lib/",
134+
"languageVersion": "2.0"
135+
},
136+
{
137+
"name": "shared_preferences_macos",
138+
"rootUri": "file:///Users/parthmaniar/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_macos-0.0.1+8",
139+
"packageUri": "lib/",
140+
"languageVersion": "2.1"
141+
},
142+
{
143+
"name": "shared_preferences_platform_interface",
144+
"rootUri": "file:///Users/parthmaniar/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_platform_interface-1.0.3",
145+
"packageUri": "lib/",
146+
"languageVersion": "2.0"
147+
},
148+
{
149+
"name": "shared_preferences_web",
150+
"rootUri": "file:///Users/parthmaniar/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_web-0.1.2+5",
151+
"packageUri": "lib/",
152+
"languageVersion": "2.0"
153+
},
106154
{
107155
"name": "sky_engine",
108156
"rootUri": "file:///Users/parthmaniar/development/flutter/bin/cache/pkg/sky_engine",
@@ -170,7 +218,7 @@
170218
"languageVersion": "2.7"
171219
}
172220
],
173-
"generated": "2020-05-07T22:37:38.724793Z",
221+
"generated": "2020-05-08T09:57:38.974801Z",
174222
"generator": "pub",
175223
"generatorVersion": "2.8.1"
176224
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"shared_preferences","path":"/Users/parthmaniar/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.7+1/","dependencies":[]}],"android":[{"name":"shared_preferences","path":"/Users/parthmaniar/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.7+1/","dependencies":[]}],"macos":[{"name":"shared_preferences_macos","path":"/Users/parthmaniar/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_macos-0.0.1+8/","dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"shared_preferences_web","path":"/Users/parthmaniar/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_web-0.1.2+5/","dependencies":[]}]},"dependencyGraph":[{"name":"shared_preferences","dependencies":["shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]}],"date_created":"2020-05-08 15:38:46.475248","version":"1.17.0"}

‎.packages‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Generated by pub on 2020-05-08 04:07:38.705746.
1+
# Generated by pub on 2020-05-08 15:27:38.948425.
22
archive:file:///Users/parthmaniar/development/flutter/.pub-cache/hosted/pub.dartlang.org/archive-2.0.13/lib/
33
args:file:///Users/parthmaniar/development/flutter/.pub-cache/hosted/pub.dartlang.org/args-1.6.0/lib/
44
async:file:///Users/parthmaniar/development/flutter/.pub-cache/hosted/pub.dartlang.org/async-2.4.1/lib/
@@ -8,14 +8,22 @@ collection:file:///Users/parthmaniar/development/flutter/.pub-cache/hosted/pub.d
88
convert:file:///Users/parthmaniar/development/flutter/.pub-cache/hosted/pub.dartlang.org/convert-2.1.1/lib/
99
crypto:file:///Users/parthmaniar/development/flutter/.pub-cache/hosted/pub.dartlang.org/crypto-2.1.4/lib/
1010
cupertino_icons:file:///Users/parthmaniar/development/flutter/.pub-cache/hosted/pub.dartlang.org/cupertino_icons-0.1.3/lib/
11+
day_night_switch:file:///Users/parthmaniar/development/flutter/.pub-cache/hosted/pub.dartlang.org/day_night_switch-0.0.2+1/lib/
1112
flutter:file:///Users/parthmaniar/development/flutter/packages/flutter/lib/
1213
flutter_test:file:///Users/parthmaniar/development/flutter/packages/flutter_test/lib/
14+
flutter_web_plugins:file:///Users/parthmaniar/development/flutter/packages/flutter_web_plugins/lib/
1315
image:file:///Users/parthmaniar/development/flutter/.pub-cache/hosted/pub.dartlang.org/image-2.1.12/lib/
1416
matcher:file:///Users/parthmaniar/development/flutter/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.6/lib/
1517
meta:file:///Users/parthmaniar/development/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.1.8/lib/
18+
nested:file:///Users/parthmaniar/development/flutter/.pub-cache/hosted/pub.dartlang.org/nested-0.0.4/lib/
1619
path:file:///Users/parthmaniar/development/flutter/.pub-cache/hosted/pub.dartlang.org/path-1.6.4/lib/
1720
petitparser:file:///Users/parthmaniar/development/flutter/.pub-cache/hosted/pub.dartlang.org/petitparser-2.4.0/lib/
21+
provider:file:///Users/parthmaniar/development/flutter/.pub-cache/hosted/pub.dartlang.org/provider-4.1.0/lib/
1822
quiver:file:///Users/parthmaniar/development/flutter/.pub-cache/hosted/pub.dartlang.org/quiver-2.1.3/lib/
23+
shared_preferences:file:///Users/parthmaniar/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.7+1/lib/
24+
shared_preferences_macos:file:///Users/parthmaniar/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_macos-0.0.1+8/lib/
25+
shared_preferences_platform_interface:file:///Users/parthmaniar/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_platform_interface-1.0.3/lib/
26+
shared_preferences_web:file:///Users/parthmaniar/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_web-0.1.2+5/lib/
1927
sky_engine:file:///Users/parthmaniar/development/flutter/bin/cache/pkg/sky_engine/lib/
2028
source_span:file:///Users/parthmaniar/development/flutter/.pub-cache/hosted/pub.dartlang.org/source_span-1.7.0/lib/
2129
stack_trace:file:///Users/parthmaniar/development/flutter/.pub-cache/hosted/pub.dartlang.org/stack_trace-1.9.3/lib/

‎ios/Flutter/Debug.xcconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
12
#include "Generated.xcconfig"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
12
#include "Generated.xcconfig"

‎ios/Podfile‎

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Uncomment this line to define a global platform for your project
2+
# platform :ios, '9.0'
3+
4+
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
5+
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
6+
7+
project 'Runner', {
8+
'Debug' => :debug,
9+
'Profile' => :release,
10+
'Release' => :release,
11+
}
12+
13+
def parse_KV_file(file, separator='=')
14+
file_abs_path = File.expand_path(file)
15+
if !File.exists? file_abs_path
16+
return [];
17+
end
18+
generated_key_values = {}
19+
skip_line_start_symbols = ["#", "/"]
20+
File.foreach(file_abs_path) do |line|
21+
next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
22+
plugin = line.split(pattern=separator)
23+
if plugin.length == 2
24+
podname = plugin[0].strip()
25+
path = plugin[1].strip()
26+
podpath = File.expand_path("#{path}", file_abs_path)
27+
generated_key_values[podname] = podpath
28+
else
29+
puts "Invalid plugin specification: #{line}"
30+
end
31+
end
32+
generated_key_values
33+
end
34+
35+
target 'Runner' do
36+
use_frameworks!
37+
use_modular_headers!
38+
39+
# Flutter Pod
40+
41+
copied_flutter_dir = File.join(__dir__, 'Flutter')
42+
copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
43+
copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
44+
unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
45+
# Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
46+
# That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
47+
# CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.
48+
49+
generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
50+
unless File.exist?(generated_xcode_build_settings_path)
51+
raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
52+
end
53+
generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
54+
cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];
55+
56+
unless File.exist?(copied_framework_path)
57+
FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
58+
end
59+
unless File.exist?(copied_podspec_path)
60+
FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
61+
end
62+
end
63+
64+
# Keep pod path relative so it can be checked into Podfile.lock.
65+
pod 'Flutter', :path => 'Flutter'
66+
67+
# Plugin Pods
68+
69+
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
70+
# referring to absolute paths on developers' machines.
71+
system('rm -rf .symlinks')
72+
system('mkdir -p .symlinks/plugins')
73+
plugin_pods = parse_KV_file('../.flutter-plugins')
74+
plugin_pods.each do |name, path|
75+
symlink = File.join('.symlinks', 'plugins', name)
76+
File.symlink(path, symlink)
77+
pod name, :path => File.join(symlink, 'ios')
78+
end
79+
end
80+
81+
post_install do |installer|
82+
installer.pods_project.targets.each do |target|
83+
target.build_configurations.each do |config|
84+
config.build_settings['ENABLE_BITCODE'] = 'NO'
85+
end
86+
end
87+
end

‎lib/main.dart‎

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,35 @@
1-
import 'package:flutter/material.dart';
21
import 'package:theme_provider/util/theme_notifier.dart';
2+
import 'package:theme_provider/values/theme.dart';
3+
import 'package:flutter/material.dart';
4+
import 'package:flutter/services.dart';
5+
import 'package:provider/provider.dart';
6+
import 'package:shared_preferences/shared_preferences.dart';
7+
38
import 'screens/home.dart';
9+
410
void main() {
5-
runApp(MyApp());
11+
WidgetsFlutterBinding.ensureInitialized();
12+
SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.bottom]).then((_) {
13+
SharedPreferences.getInstance().then((prefs) {
14+
var darkModeOn = prefs.getBool('darkMode') ?? true;
15+
runApp(
16+
ChangeNotifierProvider<ThemeNotifier>(
17+
create: (_) => ThemeNotifier(darkModeOn ? darkTheme : lightTheme),
18+
child: MyApp(),
19+
),
20+
);
21+
});
22+
});
623
}
724

825
class MyApp extends StatelessWidget {
926
@override
1027
Widget build(BuildContext context) {
28+
final themeNotifier = Provider.of<ThemeNotifier>(context);
1129
return MaterialApp(
1230
title: 'Theme Provider',
13-
theme: ThemeData(
14-
primarySwatch: Colors.blue,
15-
visualDensity: VisualDensity.adaptivePlatformDensity,
16-
),
31+
debugShowCheckedModeBanner: false,
32+
theme: themeNotifier.getTheme(),
1733
home: HomePage(),
1834
);
1935
}

‎lib/screens/home.dart‎

Lines changed: 65 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,31 @@
11
import 'package:flutter/material.dart';
2+
import 'package:theme_provider/screens/settings.dart';
3+
4+
5+
class HomePage extends StatefulWidget {
6+
@override
7+
_HomePageState createState() => _HomePageState();
8+
}
9+
10+
class _HomePageState extends State<HomePage> {
11+
12+
@override
13+
void initState() {
14+
super.initState();
15+
}
216

3-
class HomePage extends StatelessWidget {
417
@override
518
Widget build(BuildContext context) {
619
return Scaffold(
7-
appBar: AppBar(
8-
title: Text("Theme Provider"),
20+
appBar: PreferredSize(
21+
preferredSize: Size.fromHeight(50.0), // here the desired height
22+
child: AppBar(
23+
title: Text("Theme Provider"),
924
centerTitle: true,
10-
elevation: 0.0,
11-
),
25+
// ...
26+
)),
27+
extendBody: true,
28+
backgroundColor: Theme.of(context).backgroundColor,
1229
body: Center(
1330
child: Column(
1431
mainAxisAlignment: MainAxisAlignment.center,
@@ -21,6 +38,49 @@ class HomePage extends StatelessWidget {
2138
),
2239
),
2340
],
41+
),),
42+
floatingActionButton: Container(
43+
height: 56.0,
44+
child: Card(
45+
// height: 56.0,
46+
// decoration: BoxDecoration(
47+
// color: Theme.of(context).accentColor,
48+
// borderRadius: BorderRadius.circular(50.0),
49+
// ),
50+
shape: RoundedRectangleBorder(
51+
borderRadius: BorderRadius.circular(50.0),
52+
),
53+
color: Theme.of(context).accentColor,
54+
child: Row(
55+
mainAxisSize: MainAxisSize.min,
56+
children: <Widget>[
57+
Padding(
58+
padding: const EdgeInsets.only(top: 8.0, bottom: 8.0),
59+
child: Container(
60+
width: 1,
61+
height: double.infinity,
62+
color: Theme.of(context).dividerColor,
63+
),
64+
),
65+
Padding(
66+
padding: const EdgeInsets.all(4.0),
67+
child: IconButton(
68+
icon: Icon(
69+
Icons.settings,
70+
color: Theme.of(context).accentIconTheme.color,
71+
),
72+
onPressed: () {
73+
Navigator.push(
74+
context,
75+
MaterialPageRoute(
76+
builder: (context) => SettingsPage(),
77+
),
78+
);
79+
},
80+
),
81+
)
82+
],
83+
),
2484
),
2585
),
2686
);

0 commit comments

Comments
 (0)