/
main.dart
129 lines (123 loc) · 4.12 KB
/
main.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import 'package:flutter/gestures.dart';
import 'package:flutter/services.dart';
import 'package:flutter_downloader/flutter_downloader.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_neumorphic/flutter_neumorphic.dart';
import 'package:ggsipu_notice/keys.dart';
import 'package:ggsipu_notice/ui/pages/homeScreen.dart';
import 'package:onesignal_flutter/onesignal_flutter.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:firebase_core/firebase_core.dart';
SharedPreferences prefs;
List<NeumorphicThemeData> themes = [
NeumorphicThemeData(
baseColor: Color(0xFFDDDDDD),
accentColor: Color(0x00CCCCCC),
defaultTextColor: Color(0xFF333333),
shadowLightColor: Color(0xFFFFFFFF),
shadowDarkColor: Color(0xFFAAAAAA),
intensity: 0.6,
lightSource: LightSource.topLeft,
depth: 8,
),
NeumorphicThemeData(
baseColor: Color(0xFF222222),
accentColor: Color(0x00111111),
defaultTextColor: Color(0xFFDDDDDD),
shadowLightColor: Color(0xFF444444),
shadowDarkColor: Color(0xFF000000),
intensity: 0.6,
lightSource: LightSource.topLeft,
depth: 8,
),
NeumorphicThemeData(
baseColor: Color(0xFF000000),
accentColor: Color(0x00000000),
defaultTextColor: Color(0xFFFFFFFF),
shadowLightColor: Color(0xFF181818),
shadowDarkColor: Color(0xFF080808),
intensity: 0.6,
lightSource: LightSource.topLeft,
depth: 8,
),
];
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
prefs = await SharedPreferences.getInstance();
await FlutterDownloader.initialize(debug: true);
GestureBinding.instance.resamplingEnabled = true;
runApp(new MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
Future<void> initOSN() async {
OneSignal.shared.setLogLevel(OSLogLevel.verbose, OSLogLevel.none);
OneSignal.shared.init(oneSignalAppID, iOSSettings: {
OSiOSSettings.autoPrompt: false,
OSiOSSettings.inAppLaunchUrl: false
});
OneSignal.shared
.setInFocusDisplayType(OSNotificationDisplayType.notification);
await OneSignal.shared.sendTags({
"new_notices": "true",
});
final Map<String, dynamic> tags = await OneSignal.shared.getTags();
debugPrint(tags.toString());
}
@override
void initState() {
super.initState();
initOSN();
}
@override
Widget build(BuildContext context) {
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(statusBarColor: Colors.transparent));
return CupertinoApp(
title: 'GGSIPU Notices',
theme: CupertinoThemeData(),
home: NeumorphicTheme(
usedTheme:
prefs.get('theme') == 0 ?? 0 ? UsedTheme.LIGHT : UsedTheme.DARK,
theme: NeumorphicThemeData(
baseColor: Color(0xFFDDDDDD),
accentColor: Color(0x00CCCCCC),
defaultTextColor: Color(0xFF333333),
shadowLightColor: Color(0xFFFFFFFF),
shadowDarkColor: Color(0xFFAAAAAA),
intensity: 0.6,
lightSource: LightSource.topLeft,
depth: 8,
),
darkTheme: prefs.get('theme') == 1 ?? 0
? NeumorphicThemeData(
baseColor: Color(0xFF222222),
accentColor: Color(0x00111111),
defaultTextColor: Color(0xFFDDDDDD),
shadowLightColor: Color(0xFF444444),
shadowDarkColor: Color(0xFF000000),
intensity: 0.6,
lightSource: LightSource.topLeft,
depth: 8,
)
: NeumorphicThemeData(
baseColor: Color(0xFF000000),
accentColor: Color(0x00000000),
defaultTextColor: Color(0xFFFFFFFF),
shadowLightColor: Color(0xFF181818),
shadowDarkColor: Color(0xFF080808),
intensity: 0.6,
lightSource: LightSource.topLeft,
depth: 8,
),
child: HomeScreen(),
),
debugShowCheckedModeBanner: false,
);
}
}