-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4335eb6
commit fadf7be
Showing
5 changed files
with
205 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import 'package:Bloomee/theme_data/default.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class GradientDialog extends StatefulWidget { | ||
String message; | ||
Future<void> Function(String)? onOk; | ||
String? okText; | ||
String downloadURL = ""; | ||
GradientDialog( | ||
this.message, { | ||
this.onOk, | ||
this.okText, | ||
required this.downloadURL, | ||
super.key, | ||
}); | ||
|
||
@override | ||
State<StatefulWidget> createState() { | ||
return _GradientDialogState(); | ||
} | ||
} | ||
|
||
class _GradientDialogState extends State<GradientDialog> { | ||
@override | ||
Widget build(BuildContext context) { | ||
return AlertDialog( | ||
backgroundColor: Colors.transparent, | ||
content: ClipRRect( | ||
borderRadius: BorderRadius.circular(20.0), | ||
child: Container( | ||
height: 200.0, | ||
constraints: const BoxConstraints(), | ||
padding: const EdgeInsets.all(8.0), | ||
decoration: const BoxDecoration( | ||
gradient: LinearGradient( | ||
colors: [Colors.blue, Colors.pink], | ||
begin: Alignment.topLeft, | ||
end: Alignment.bottomCenter, | ||
// stops: [0.5, 1.9], | ||
), | ||
), | ||
child: Column( | ||
mainAxisSize: MainAxisSize.min, | ||
children: <Widget>[ | ||
Padding( | ||
padding: const EdgeInsets.only( | ||
top: 10.0, right: 8, left: 8, bottom: 10.0), | ||
child: Text( | ||
widget.message, | ||
textAlign: TextAlign.center, | ||
style: const TextStyle( | ||
color: Colors.white, | ||
fontFamily: "ReThink-Sans", | ||
fontWeight: FontWeight.bold, | ||
fontSize: 20, | ||
), | ||
), | ||
), | ||
const Spacer(), | ||
Row( | ||
mainAxisAlignment: MainAxisAlignment.end, | ||
children: [ | ||
TextButton( | ||
onPressed: () { | ||
Navigator.of(context).pop(); | ||
}, | ||
child: const Padding( | ||
padding: EdgeInsets.only(right: 5), | ||
child: Text('Cancel', | ||
style: TextStyle( | ||
color: Colors.white, | ||
fontFamily: "ReThink-Sans", | ||
fontSize: 15, | ||
fontWeight: FontWeight.w600)), | ||
), | ||
), | ||
OutlinedButton( | ||
onPressed: () { | ||
if (widget.onOk != null) { | ||
widget.onOk!(widget.downloadURL); | ||
} | ||
Navigator.of(context).pop(); | ||
}, | ||
style: OutlinedButton.styleFrom( | ||
backgroundColor: Default_Theme.accentColor1, | ||
side: const BorderSide( | ||
color: Default_Theme.accentColor1), | ||
shape: RoundedRectangleBorder( | ||
borderRadius: BorderRadius.circular(20.0)), | ||
), | ||
child: Text(widget.okText ?? "OK", | ||
style: const TextStyle( | ||
color: Colors.white, | ||
fontFamily: "ReThink-Sans", | ||
fontSize: 15, | ||
))), | ||
], | ||
) | ||
], | ||
)), | ||
), | ||
contentPadding: const EdgeInsets.all(0.0), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:Bloomee/screens/widgets/gradient_alert_widget.dart'; | ||
import 'package:Bloomee/services/bloomeeUpdaterTools.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:url_launcher/url_launcher.dart'; | ||
|
||
Future<void> updateDialog(BuildContext context) async { | ||
if (Platform.isAndroid) { | ||
Map<String, dynamic> _updateData = await getLatestVersion(); | ||
if (_updateData["results"]) { | ||
if (int.parse(_updateData["currBuild"]) < | ||
int.parse(_updateData["newBuild"])) { | ||
showDialog( | ||
context: context, | ||
builder: (BuildContext context) { | ||
return GradientDialog( | ||
"New Version of Bloomee🌸 is now available!!\n\nVersion: ${_updateData["newVer"]} + ${_updateData["newBuild"]}", | ||
onOk: openURL, | ||
okText: "Update Now!", | ||
downloadURL: _updateData["download_url"], | ||
); | ||
}, | ||
); | ||
} | ||
} | ||
} | ||
} | ||
|
||
Future<void> openURL(String url) async { | ||
launchUrl(Uri.parse(url)); | ||
} | ||
|
||
// Future<void> downloadApk(String url) async { | ||
// ReceivePort receivePort = ReceivePort(); | ||
|
||
// bool isSuccess = IsolateNameServer.registerPortWithName( | ||
// receivePort.sendPort, "update_port"); | ||
// if (!isSuccess) { | ||
// IsolateNameServer.removePortNameMapping("update_port"); | ||
// IsolateNameServer.registerPortWithName(receivePort.sendPort, "update_port"); | ||
// } | ||
// FlutterDownloader.registerCallback(callback); | ||
// final taskId = await FlutterDownloader.enqueue( | ||
// url: url, | ||
// headers: {}, // optional: header send with url (auth token etc) | ||
// savedDir: (await getExternalStorageDirectory())!.path, | ||
// saveInPublicStorage: true, | ||
// showNotification: | ||
// true, // show download progress in status bar (for Android) | ||
// openFileFromNotification: | ||
// true, // click on notification to open downloaded file (for Android) | ||
// ); | ||
|
||
// receivePort.listen((dynamic data) async { | ||
// String id = data[0]; | ||
// // DownloadTaskStatus status = DownloadTaskStatus.fromInt(data[1]); | ||
// int status = data[1]; | ||
// int progress = data[2]; | ||
// print("============================="); | ||
// if (status == 3) { | ||
// final tasks = await FlutterDownloader.loadTasksWithRawQuery( | ||
// query: "SELECT * FROM task WHERE task_id='" + taskId.toString() + "'", | ||
// ); | ||
// // print(tasks![0].filename.toString()); | ||
// String full_path = | ||
// tasks![0].savedDir.toString() + "/" + tasks[0].filename.toString(); | ||
// print(full_path); | ||
// if (Platform.isAndroid) { | ||
// await FlutterDownloader.open(taskId: taskId.toString()); | ||
// } | ||
// } | ||
// print( | ||
// 'Background Isolate Callback: task ($taskId) is in status ($status) and process ($progress)', | ||
// ); | ||
// }); | ||
// } | ||
|
||
// @pragma('vm:entry-point') | ||
// Future callback(String taskId, int status, int progress) async { | ||
// final SendPort? send = IsolateNameServer.lookupPortByName('update_port'); | ||
// send?.send([taskId, status, progress]); | ||
// } |