diff --git a/lib/data/res/build_data.dart b/lib/data/res/build_data.dart index d961be6d..ad5dfc24 100644 --- a/lib/data/res/build_data.dart +++ b/lib/data/res/build_data.dart @@ -2,8 +2,8 @@ class BuildData { static const String name = "ToolBox"; - static const int build = 58; + static const int build = 59; static const String engine = "Flutter 2.5.3 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision 18116933e7 (3 weeks ago) • 2021-10-15 10:46:35 -0700\nEngine • revision d3ea636dc5\nTools • Dart 2.14.4\n"; - static const String buildAt = "2021-11-02 19:44:10.383544"; + static const String buildAt = "2021-11-02 20:31:21.141578"; static const int modifications = 4; } diff --git a/lib/view/page/setting.dart b/lib/view/page/setting.dart index e3e7272d..bed71fec 100644 --- a/lib/view/page/setting.dart +++ b/lib/view/page/setting.dart @@ -1,5 +1,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_material_color_picker/flutter_material_color_picker.dart'; +import 'package:provider/provider.dart'; +import 'package:toolbox/core/update.dart'; +import 'package:toolbox/data/provider/app.dart'; +import 'package:toolbox/data/res/build_data.dart'; import 'package:toolbox/data/res/color.dart'; import 'package:toolbox/data/store/setting.dart'; import 'package:toolbox/locator.dart'; @@ -40,56 +44,76 @@ class _SettingPageState extends State { body: ListView( padding: const EdgeInsets.all(17), children: [ - RoundRectCard(_buildAppColorPreview()), - RoundRectCard( - ExpansionTile( - tilePadding: EdgeInsets.zero, - childrenPadding: EdgeInsets.zero, - textColor: priColor, - title: const Text( - 'Server status update interval', - style: TextStyle(fontSize: 14), - textAlign: TextAlign.start, - ), - subtitle: const Text( - 'Will take effect the next time app launches.', - style: TextStyle(color: Colors.grey), - ), - trailing: Text('${_intervalValue.toInt()} s'), - children: [ - Slider( - thumbColor: priColor, - activeColor: priColor.withOpacity(0.7), - min: 0, - max: 10, - value: _intervalValue, - onChanged: (newValue) { - setState(() { - _intervalValue = newValue; - }); - }, - onChangeEnd: (val) => - _store.serverStatusUpdateInterval.put(val.toInt()), - label: '${_intervalValue.toInt()} seconds', - divisions: 10, - ), - const SizedBox( - height: 3, - ), - _intervalValue == 0.0 - ? const Text('You set to 0, will not update automatically.') - : const SizedBox(), - const SizedBox( - height: 13, - ) - ], - ), - ) - ], + _buildAppColorPreview(), + _buildUpdateInterval(), + _buildCheckUpdate() + ].map((e) => RoundRectCard(e)).toList(), ), ); } + Widget _buildCheckUpdate() { + return Consumer(builder: (_, app, __) { + String display; + if (app.newestBuild != null) { + if (app.newestBuild! > BuildData.build) { + display = '发现新版本:${app.newestBuild}'; + } else { + display = '当前版本:${BuildData.build},已是最新'; + } + } else { + display = '当前版本:${BuildData.build},点击检查更新'; + } + return ListTile( + title: Text(display), onTap: () => doUpdate(context, force: true)); + }); + } + + Widget _buildUpdateInterval() { + return ExpansionTile( + tilePadding: EdgeInsets.zero, + childrenPadding: EdgeInsets.zero, + textColor: priColor, + title: const Text( + 'Server status update interval', + style: TextStyle(fontSize: 14), + textAlign: TextAlign.start, + ), + subtitle: const Text( + 'Will take effect the next time app launches.', + style: TextStyle(color: Colors.grey), + ), + trailing: Text('${_intervalValue.toInt()} s'), + children: [ + Slider( + thumbColor: priColor, + activeColor: priColor.withOpacity(0.7), + min: 0, + max: 10, + value: _intervalValue, + onChanged: (newValue) { + setState(() { + _intervalValue = newValue; + }); + }, + onChangeEnd: (val) => + _store.serverStatusUpdateInterval.put(val.toInt()), + label: '${_intervalValue.toInt()} seconds', + divisions: 10, + ), + const SizedBox( + height: 3, + ), + _intervalValue == 0.0 + ? const Text('You set to 0, will not update automatically.') + : const SizedBox(), + const SizedBox( + height: 13, + ) + ], + ); + } + Widget _buildAppColorPreview() { return ExpansionTile( textColor: priColor, diff --git a/lib/view/page/snippet/edit.dart b/lib/view/page/snippet/edit.dart index ff86d812..6b09a206 100644 --- a/lib/view/page/snippet/edit.dart +++ b/lib/view/page/snippet/edit.dart @@ -10,6 +10,6 @@ class SnippetEditPage extends StatefulWidget { class _SnippetEditPageState extends State { @override Widget build(BuildContext context) { - return Container(); + return Scaffold(appBar: AppBar(title: const Text('Snippet Edit'),), body: const Center(child: Text('Developing'),),); } } diff --git a/lib/view/page/snippet/list.dart b/lib/view/page/snippet/list.dart index eced379f..63ede276 100644 --- a/lib/view/page/snippet/list.dart +++ b/lib/view/page/snippet/list.dart @@ -10,6 +10,6 @@ class SnippetListPage extends StatefulWidget { class _SnippetListPageState extends State { @override Widget build(BuildContext context) { - return Container(); + return Scaffold(appBar: AppBar(title: const Text('Snippet List'),), body: const Center(child: Text('Developing'),),); } }