Skip to content

Commit 39d2180

Browse files
authored
Merge pull request #47 from ErfanRht/improvement/upgrade-dialog
(improve) update-dialog
2 parents 770845d + 0960c37 commit 39d2180

File tree

2 files changed

+104
-63
lines changed

2 files changed

+104
-63
lines changed

lib/constants/app.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const String appVersion = "v3.0.1";
1+
const String appVersion = "v3.0.2";
22

33
String? latestVersion;
44
List<String>? supportedVersions;

lib/pages/main/home/home_page.dart

Lines changed: 103 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import 'package:flutter/foundation.dart';
12
import 'package:flutter/material.dart';
3+
import 'package:flutter_spinkit/flutter_spinkit.dart';
24
import 'package:get/get.dart';
35
import 'package:hive_flutter/hive_flutter.dart';
46
import 'package:movielab/constants/app.dart';
@@ -7,8 +9,10 @@ import 'package:movielab/models/hive/convertor.dart';
79
import 'package:movielab/models/hive/models/show_preview.dart';
810
import 'package:movielab/modules/tools/system_ui_overlay_style.dart';
911
import 'package:movielab/pages/main/main_controller.dart';
10-
import 'package:movielab/widgets/buttons/glassmorphism_button.dart';
12+
import 'package:movielab/widgets/buttons/activeable_button.dart';
13+
import 'package:movielab/widgets/error.dart';
1114
import 'package:movielab/widgets/inefficacious_refresh_indicator.dart';
15+
import 'package:ms_undraw/ms_undraw.dart';
1216
import 'package:url_launcher/url_launcher.dart';
1317
import 'home_data_controller.dart';
1418
import 'sections/box_office/box_office.dart';
@@ -18,13 +22,18 @@ import 'sections/imdb_lists/lists.dart';
1822
import 'sections/navbar/navbar.dart';
1923
import 'sections/trendings/home_trendings.dart';
2024

21-
class HomePage extends StatelessWidget {
25+
class HomePage extends StatefulWidget {
2226
const HomePage({Key? key}) : super(key: key);
2327

28+
@override
29+
State<HomePage> createState() => _HomePageState();
30+
}
31+
32+
class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
2433
@override
2534
Widget build(BuildContext context) {
2635
setSystemUIOverlayStyle();
27-
checkForUpdateDialog(context);
36+
checkForUpdateDialog(context, this);
2837
return GetBuilder<MainController>(builder: (_) {
2938
return GetBuilder<HomeDataController>(builder: (__) {
3039
return ValueListenableBuilder<Box<HiveShowPreview>>(
@@ -117,77 +126,109 @@ class HomePage extends StatelessWidget {
117126
}
118127
}
119128

120-
Future checkForUpdateDialog(BuildContext context) async {
121-
print("Checking for update dialog");
122-
await Future.delayed(const Duration(milliseconds: 1750));
129+
Future checkForUpdateDialog(BuildContext context, dynamic vsync) async {
130+
if (kDebugMode) {
131+
print("Checking for update dialog");
132+
}
133+
await Future.delayed(const Duration(milliseconds: 1999));
123134
if (latestVersion != null &&
124135
latestVersion != "" &&
125136
appVersion != latestVersion) {
126-
showDialog(
137+
showModalBottomSheet(
127138
context: context,
139+
shape: const RoundedRectangleBorder(
140+
borderRadius: BorderRadius.vertical(
141+
top: Radius.circular(20),
142+
)),
143+
clipBehavior: Clip.antiAliasWithSaveLayer,
144+
backgroundColor: kSecondaryColor,
145+
transitionAnimationController: AnimationController(
146+
duration: const Duration(milliseconds: 425), vsync: vsync),
128147
builder: (context) {
129-
return AlertDialog(
130-
contentPadding: const EdgeInsets.all(5),
131-
shape: RoundedRectangleBorder(
132-
borderRadius: BorderRadius.circular(20),
133-
),
134-
content: Container(
135-
height: 190,
136-
width: 200,
137-
padding: const EdgeInsets.symmetric(horizontal: 10),
138-
decoration: BoxDecoration(
139-
borderRadius: BorderRadius.circular(15),
140-
color: kBackgroundColor),
148+
return Container(
149+
padding: const EdgeInsets.symmetric(horizontal: 15),
150+
color: kBackgroundColor,
151+
height: 425,
141152
child: Column(
142-
mainAxisAlignment: MainAxisAlignment.center,
143-
children: [
144-
const Text(
145-
"New version's available!",
146-
style: TextStyle(fontSize: 19, fontWeight: FontWeight.w700),
147-
),
148-
const SizedBox(
149-
height: 20,
150-
),
151-
Text(
152-
"MovieLab $latestVersion is available now with lots of cool changes and improvements!",
153-
textAlign: TextAlign.center,
154-
style: TextStyle(
155-
fontSize: 13.5,
156-
fontWeight: FontWeight.w700,
157-
color: Colors.white.withOpacity(0.6)),
158-
),
159-
const SizedBox(
160-
height: 20,
161-
),
162-
GmButton(
163-
text: "UPDATE NOW",
153+
crossAxisAlignment: CrossAxisAlignment.center,
154+
children: [
155+
Container(
156+
width: MediaQuery.of(context).size.width / 3,
157+
margin: const EdgeInsets.only(top: 8.5, bottom: 7.5),
158+
height: 3,
159+
color: Colors.white.withOpacity(0.4),
160+
),
161+
UnDraw(
162+
color: kAccentColor,
163+
illustration: UnDrawIllustration.upgrade,
164+
height: 150,
165+
placeholder: const Center(
166+
child: SpinKitThreeBounce(
167+
color: Colors.white,
168+
size: 30,
169+
),
170+
),
171+
errorWidget: ConnectionErrorWidget(
172+
errorText:
173+
"An unexpected error occurred while loading the illustration.",
174+
tryAgain: () {}),
175+
),
176+
const Text(
177+
"Update MovieLab",
178+
style: TextStyle(
179+
fontWeight: FontWeight.w600, fontSize: 18.5),
180+
),
181+
const SizedBox(
182+
height: 7.5,
183+
),
184+
Text(
185+
"${latestVersion!.replaceAll('v', 'Version ')} · 21.0 MB",
186+
textAlign: TextAlign.center,
187+
style: TextStyle(
188+
fontWeight: FontWeight.w600,
189+
fontSize: 15,
190+
color: Colors.white.withOpacity(0.66)),
191+
),
192+
const SizedBox(
193+
height: 20,
194+
),
195+
const Text(
196+
"Please update MovieLab to the latest version. The version you are using is out of date and may stop working soon.",
197+
textAlign: TextAlign.center,
198+
style: TextStyle(
199+
fontWeight: FontWeight.w500, fontSize: 13.5),
200+
),
201+
const SizedBox(
202+
height: 15,
203+
),
204+
ActiveableButton(
205+
isActive: true,
206+
text: "Download now!",
207+
icon: null,
164208
onTap: () {
165209
_launchUrl(secureUrl ??
166210
"https://erfanrht.github.io/MovieLab-Intro");
167211
},
168-
width: 125,
169-
backgroundColor: kPrimaryColor,
170-
color: Colors.white),
171-
const SizedBox(
172-
height: 12.5,
173-
),
174-
GestureDetector(
175-
onTap: () {
176-
Navigator.pop(context);
177-
},
178-
child: const Text(
179-
"Not now!",
180-
textAlign: TextAlign.center,
181-
style: TextStyle(
182-
fontSize: 13.5,
183-
fontWeight: FontWeight.w500,
212+
activeColor: kAccentColor,
213+
),
214+
const SizedBox(
215+
height: 10,
216+
),
217+
GestureDetector(
218+
onTap: () {
219+
Navigator.pop(context);
220+
},
221+
child: const Text(
222+
"Remind me later",
223+
textAlign: TextAlign.center,
224+
style: TextStyle(
225+
fontSize: 15,
226+
color: kAccentColor,
227+
fontWeight: FontWeight.w600,
228+
),
184229
),
185230
),
186-
),
187-
],
188-
),
189-
),
190-
);
231+
]));
191232
});
192233
}
193234
}

0 commit comments

Comments
 (0)