-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathwelcome_page.dart
139 lines (131 loc) · 4.41 KB
/
welcome_page.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
130
131
132
133
134
135
136
137
138
139
import 'package:byr_mobile_app/customizations/theme_manager.dart';
import 'package:byr_mobile_app/nforum/nforum_service.dart';
import 'package:byr_mobile_app/pages/login_page.dart';
import 'package:byr_mobile_app/reusable_components/page_initialization.dart';
import 'package:byr_mobile_app/shared_objects/shared_objects.dart';
import 'package:byr_mobile_app/tasks/startup_tasks.dart';
import 'package:byr_mobile_app/tasks/welcome_page_tasks.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_windowmanager/flutter_windowmanager.dart';
import 'package:get/get.dart';
import 'package:transparent_image/transparent_image.dart';
class WelcomePage extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return WelcomePageState();
}
}
class WelcomePageState extends State<WelcomePage> {
InitializationStatus initializationStatus;
bool skipped = false;
Future<void> startupApp() async {
await StartupTasks.startupAll();
}
Future<void> initializePage() async {
return await WelcomePageTasks.loadWelImg().then((value) {
initializationStatus = InitializationStatus.Initialized;
if (mounted) {
setState(() {});
}
});
}
void skip() {
skipped = true;
if (NForumService.currentToken == null) {
navigator.pushReplacementNamed("login_page", arguments: LoginPageRouteArg(isAddingMoreAccount: false));
} else {
navigator.pushReplacementNamed("home_page");
}
}
@override
void initState() {
super.initState();
initializationStatus = InitializationStatus.Initializing;
if (mounted) {
setState(() {});
}
startupApp().then((value) {
if (BYRThemeManager.instance().getIsAutoSwitchDarkModel() == true) {
final Brightness brightness = MediaQuery.platformBrightnessOf(context);
BYRThemeManager.instance().autoSwitchDarkMode(brightness);
}
initializePage().then((value) {
Future.delayed(Duration(milliseconds: 1500), () {
if (skipped == false) {
if (NForumService.currentToken == null) {
navigator.pushReplacementNamed("login_page", arguments: LoginPageRouteArg(isAddingMoreAccount: false));
} else {
navigator.pushReplacementNamed("home_page");
}
}
});
});
});
}
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
image: DecorationImage(
fit: BoxFit.cover,
image: AssetImage(MediaQuery.of(Get.context).size.shortestSide > 600
? 'resources/welcome_page/ipad-2.jpg'
: 'resources/welcome_page/bbs_ipxmax.png'),
)),
child: initializationStatus == InitializationStatus.Initialized
? Stack(
children: [
Positioned(
left: 0,
top: 0,
right: 0,
bottom: 0,
child: FadeInImage(
fadeInDuration: Duration(milliseconds: 100),
fit: BoxFit.fill,
placeholder: MemoryImage(kTransparentImage),
image: SharedObjects.welImage,
),
),
Positioned(
right: 30,
bottom: 30,
child: TextButton(
onPressed: () {
skip();
},
child: Text(
"skipTrans".tr,
style: TextStyle(
fontSize: 18,
color: Colors.white,
),
),
),
),
Positioned(
right: 30,
bottom: 30,
child: TextButton(
onPressed: () {
skip();
},
child: Text(
"skipTrans".tr,
style: TextStyle(
fontSize: 18,
foreground: Paint()
..style = PaintingStyle.stroke
..strokeWidth = 0.5
..color = Colors.black,
),
),
),
),
],
)
: Container(),
);
}
}