|
| 1 | +import 'package:arabic_learning/funcs/ui.dart'; |
| 2 | +import 'package:arabic_learning/funcs/utili.dart'; |
1 | 3 | import 'package:arabic_learning/vars/global.dart'; |
2 | 4 | import 'package:arabic_learning/vars/license_storage.dart'; |
3 | 5 | import 'package:arabic_learning/vars/statics_var.dart'; |
4 | 6 | import 'package:flutter/foundation.dart'; |
5 | 7 | import 'package:flutter/material.dart'; |
6 | 8 | import 'package:convex_bottom_bar/convex_bottom_bar.dart'; |
7 | 9 | import 'package:flutter/services.dart'; |
| 10 | +import 'package:flutter_markdown_plus/flutter_markdown_plus.dart'; |
| 11 | +import 'package:http/http.dart' as http; |
8 | 12 | import 'package:window_manager/window_manager.dart'; |
9 | 13 | import 'package:provider/provider.dart'; |
10 | 14 | import 'package:url_launcher/url_launcher.dart'; |
@@ -194,7 +198,6 @@ class _MyHomePageState extends State<MyHomePage> { |
194 | 198 | Widget build(BuildContext context) { |
195 | 199 | final gob = context.watch<Global>(); |
196 | 200 | if(gob.firstStart) { |
197 | | - |
198 | 201 | return Scaffold( |
199 | 202 | body: PopScope( |
200 | 203 | canPop: false, |
@@ -293,6 +296,48 @@ class _MyHomePageState extends State<MyHomePage> { |
293 | 296 | ), |
294 | 297 | body: LayoutBuilder( |
295 | 298 | builder: (context, constraints) { |
| 299 | + if(gob.updateLogRequire) { |
| 300 | + gob.updateLogRequire = false; |
| 301 | + Future.delayed(Duration(seconds: 2), () async { |
| 302 | + late http.Response githubResponse; |
| 303 | + try { |
| 304 | + githubResponse = await http.get(Uri.parse("https://github.com/OctagonalStar/arabic_learning/raw/refs/heads/main/CHANGELOG.md")); |
| 305 | + } catch (e){ |
| 306 | + return; |
| 307 | + } |
| 308 | + if(githubResponse.statusCode == 200 && context.mounted) { |
| 309 | + showModalBottomSheet( |
| 310 | + context: context, |
| 311 | + shape: RoundedSuperellipseBorder(side: BorderSide(width: 1.0, color: Theme.of(context).colorScheme.onSurface), borderRadius: StaticsVar.br), |
| 312 | + enableDrag: true, |
| 313 | + isDismissible: false, |
| 314 | + isScrollControlled: true, |
| 315 | + builder: (context) { |
| 316 | + return Material( |
| 317 | + child: Column( |
| 318 | + children: [ |
| 319 | + TextContainer(text: "更新内容 软件版本: ${StaticsVar.appVersion.zfill(6)}"), |
| 320 | + SizedBox( |
| 321 | + height: MediaQuery.of(context).size.height * 0.8, |
| 322 | + child: Markdown(data: githubResponse.body) |
| 323 | + ), |
| 324 | + ElevatedButton( |
| 325 | + style: ElevatedButton.styleFrom( |
| 326 | + fixedSize: Size(double.infinity, MediaQuery.of(context).size.height * 0.07) |
| 327 | + ), |
| 328 | + onPressed: () { |
| 329 | + Navigator.pop(context); |
| 330 | + }, |
| 331 | + child: Text("知道了") |
| 332 | + ) |
| 333 | + ], |
| 334 | + ) |
| 335 | + ); |
| 336 | + }, |
| 337 | + ); |
| 338 | + } |
| 339 | + }); |
| 340 | + } |
296 | 341 | // 根据屏幕宽度决定使用哪种布局 |
297 | 342 | if (constraints.maxWidth > _desktopBreakpoint) { |
298 | 343 | Provider.of<Global>(context, listen: false).isWideScreen = true; |
|
0 commit comments