diff --git a/CHANGELOG.md b/CHANGELOG.md index b9ec946..d234201 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## v1.0.7 +* 首页任务增加分类 +* 增加国际化相关配置 +* 登录页状态栏适配 + ## v1.0.6 * 支持切换账号功能 * 登录页青龙图标随颜色主题变换 diff --git a/lib/main.dart b/lib/main.dart index 2ace2c5..ed6988f 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -10,6 +10,7 @@ import 'package:logger/logger.dart'; import 'package:qinglong_app/base/theme.dart'; import 'package:qinglong_app/module/login/login_page.dart'; import 'package:qinglong_app/utils/sp_utils.dart'; +import 'package:flutter_localizations/flutter_localizations.dart'; import 'base/routes.dart'; import 'base/userinfo_viewmodel.dart'; @@ -34,8 +35,7 @@ void main() async { ), ); if (Platform.isAndroid) { - SystemUiOverlayStyle style = - const SystemUiOverlayStyle(statusBarColor: Colors.transparent); + SystemUiOverlayStyle style = const SystemUiOverlayStyle(statusBarColor: Colors.transparent); SystemChrome.setSystemUIOverlayStyle(style); } } @@ -56,14 +56,22 @@ class QlAppState extends ConsumerState { FocusScope.of(context).requestFocus(FocusNode()); }, child: MediaQuery( - data: - MediaQueryData.fromWindow(WidgetsBinding.instance!.window).copyWith( + data: MediaQueryData.fromWindow(WidgetsBinding.instance!.window).copyWith( textScaleFactor: 1, ), child: MaterialApp( title: "青龙", locale: const Locale('zh', 'CN'), navigatorKey: navigatorState, + localizationsDelegates: const [ + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + GlobalCupertinoLocalizations.delegate, + ], + supportedLocales: const [ + Locale('zh', 'CN'), + Locale('en', 'US'), + ], theme: ref.watch(themeProvider).currentTheme, onGenerateRoute: (setting) { return Routes.generateRoute(setting); @@ -73,9 +81,7 @@ class QlAppState extends ConsumerState { if (!kReleaseMode) { showDebugBtn(context); } - return getIt().isLogined() - ? const HomePage() - : const LoginPage(); + return getIt().isLogined() ? const HomePage() : const LoginPage(); }, ), // home: LoginPage(), diff --git a/lib/module/login/login_page.dart b/lib/module/login/login_page.dart index e3f1cd0..d932dc3 100644 --- a/lib/module/login/login_page.dart +++ b/lib/module/login/login_page.dart @@ -1,6 +1,7 @@ import 'package:dio_log/dio_log.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:qinglong_app/base/http/api.dart'; import 'package:qinglong_app/base/http/http.dart'; @@ -74,336 +75,339 @@ class _LoginPageState extends ConsumerState { @override Widget build(BuildContext context) { - return SafeArea( - child: ColoredBox( - color: ref.watch(themeProvider).themeColor.settingBgColor(), - child: SizedBox( - height: MediaQuery.of(context).size.height, - child: Stack( - children: [ - Positioned( - bottom: 0, - child: Image.asset( - "assets/images/login_bg.png", - width: MediaQuery.of(context).size.width, - ), - ), - Scaffold( - backgroundColor: Colors.transparent, - body: SingleChildScrollView( - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.symmetric( - horizontal: 40, - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: MediaQuery.of(context).size.height / 10, - ), - Row( - children: [ - Expanded( - child: Align( - alignment: Alignment.centerLeft, - child: Image.asset( - "assets/images/login_tip.png", - height: 45, - ), - ), - ), - GestureDetector( - onDoubleTap: () { - if (debugBtnIsShow()) { - dismissDebugBtn(); - } else { - showDebugBtn(context, btnColor: ref.watch(themeProvider).primaryColor); - } - WidgetsBinding.instance?.endOfFrame; - }, - child: ColorFiltered( - colorFilter: ColorFilter.mode( - ref.watch(themeProvider).primaryColor, - BlendMode.srcIn, - ), - child: Image.asset( - "assets/images/ql.png", - height: 45, - ), - ), - ), - ], - ), - SizedBox( - height: MediaQuery.of(context).size.height / 15, - ), - const Text( - "域名:", - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w600, - ), - ), - TextField( - onChanged: (_) { - setState(() {}); - }, - controller: _hostController, - decoration: const InputDecoration( - contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5), - hintText: "http://1.1.1.1:5700", - ), - autofocus: false, - ), - FlipCard( - key: cardKey, - flipOnTouch: false, - onFlipDone: (back) { - useSecretLogin = back; - setState(() {}); - }, - direction: FlipDirection.HORIZONTAL, - front: SizedBox( - height: 200, - child: Column( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const SizedBox( - height: 15, - ), - const Text( - "用户名:", - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w600, - ), - ), - TextField( - onChanged: (_) { - setState(() {}); - }, - controller: _userNameController, - decoration: const InputDecoration( - contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5), - hintText: "请输入用户名", - ), - autofocus: false, - ), - const SizedBox( - height: 15, - ), - const Text( - "密码:", - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w600, - ), - ), - TextField( - onChanged: (_) { - setState(() {}); - }, - controller: _passwordController, - obscureText: true, - decoration: const InputDecoration( - contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5), - hintText: "请输入密码", - ), - autofocus: false, - ), - const SizedBox( - height: 10, - ), - ], - ), - ), - back: SizedBox( - height: 200, - child: Column( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const SizedBox( - height: 15, - ), - const Text( - "client_id:", - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w600, - ), - ), - TextField( - onChanged: (_) { - setState(() {}); - }, - controller: _cIdController, - decoration: const InputDecoration( - contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5), - hintText: "请输入client_id", - ), - autofocus: false, - ), - const SizedBox( - height: 15, - ), - const Text( - "client_secret:", - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w600, - ), - ), - TextField( - onChanged: (_) { - setState(() {}); - }, - controller: _cSecretController, - obscureText: true, - decoration: const InputDecoration( - contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5), - hintText: "请输入client_secret", - ), - autofocus: false, - ), - const SizedBox( - height: 10, - ), - ], - ), - ), - ), - ], - ), - ), - Padding( - padding: const EdgeInsets.symmetric( - horizontal: 25, - ), - child: Row( - children: [ - Checkbox( - value: rememberPassword, - onChanged: (checked) { - rememberPassword = checked ?? false; - setState(() {}); - }, - ), - const Text( - "记住密码/client", - style: TextStyle( - fontSize: 14, - ), - ), - const Spacer(), - GestureDetector( - onTap: () { - cardKey.currentState?.toggleCard(); - WidgetsBinding.instance?.addPostFrameCallback((timeStamp) { - setState(() {}); - }); - }, - child: Text( - loginByUserName() ? "client_id登录" : "账号登录", - style: const TextStyle( - fontSize: 14, - ), - ), - ), - const SizedBox( - width: 10, - ), - ], - ), - ), - const SizedBox( - height: 30, - ), - Container( - alignment: Alignment.center, - padding: const EdgeInsets.symmetric( - horizontal: 40, - ), - child: SizedBox( - width: MediaQuery.of(context).size.width - 80, - child: IgnorePointer( - ignoring: !canClickLoginBtn(), - child: CupertinoButton( - padding: const EdgeInsets.symmetric( - vertical: 5, - ), - color: canClickLoginBtn() ? ref.watch(themeProvider).primaryColor : ref.watch(themeProvider).primaryColor.withOpacity(0.4), - child: isLoading - ? const CupertinoActivityIndicator() - : const Text( - "登 录", - style: TextStyle( - fontSize: 16, - ), - ), - onPressed: () { - Http.pushedLoginPage = false; - Utils.hideKeyBoard(context); - if (loginByUserName()) { - login(_userNameController.text, _passwordController.text); - } else { - login(_cIdController.text, _cSecretController.text); - } - }, - ), - ), - ), - ), - const SizedBox( - height: 30, - ), - ], + return Scaffold( + body: AnnotatedRegion( + value: ref.watch(themeProvider).darkMode == true ? SystemUiOverlayStyle.light : SystemUiOverlayStyle.dark, + child: ColoredBox( + color: ref.watch(themeProvider).themeColor.settingBgColor(), + child: SizedBox( + height: MediaQuery.of(context).size.height, + child: Stack( + children: [ + Positioned( + bottom: 0, + child: Image.asset( + "assets/images/login_bg.png", + width: MediaQuery.of(context).size.width, ), ), - ), - Positioned( - bottom: 10, - child: (getIt().historyAccounts.isEmpty) - ? const SizedBox.shrink() - : SizedBox( - width: MediaQuery.of(context).size.width, - child: Center( - child: Material( - color: Colors.transparent, - child: PopupMenuButton( - onSelected: (UserInfoBean result) { - selected(result); - }, - itemBuilder: (BuildContext context) => >[ - ...getIt() - .historyAccounts - .map((e) => PopupMenuItem( - value: e, - child: buildCell(e), - )) - .toList(), - ], - child: Text( - "切换账号", + Scaffold( + backgroundColor: Colors.transparent, + body: SingleChildScrollView( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 40, + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: MediaQuery.of(context).size.height / 10, + ), + Row( + children: [ + Expanded( + child: Align( + alignment: Alignment.centerLeft, + child: Image.asset( + "assets/images/login_tip.png", + height: 45, + ), + ), + ), + GestureDetector( + onDoubleTap: () { + if (debugBtnIsShow()) { + dismissDebugBtn(); + } else { + showDebugBtn(context, btnColor: ref.watch(themeProvider).primaryColor); + } + WidgetsBinding.instance?.endOfFrame; + }, + child: ColorFiltered( + colorFilter: ColorFilter.mode( + ref.watch(themeProvider).primaryColor, + BlendMode.srcIn, + ), + child: Image.asset( + "assets/images/ql.png", + height: 45, + ), + ), + ), + ], + ), + SizedBox( + height: MediaQuery.of(context).size.height / 15, + ), + const Text( + "域名:", + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + ), + ), + TextField( + onChanged: (_) { + setState(() {}); + }, + controller: _hostController, + decoration: const InputDecoration( + contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5), + hintText: "http://1.1.1.1:5700", + ), + autofocus: false, + ), + FlipCard( + key: cardKey, + flipOnTouch: false, + onFlipDone: (back) { + useSecretLogin = back; + setState(() {}); + }, + direction: FlipDirection.HORIZONTAL, + front: SizedBox( + height: 200, + child: Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const SizedBox( + height: 15, + ), + const Text( + "用户名:", + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + ), + ), + TextField( + onChanged: (_) { + setState(() {}); + }, + controller: _userNameController, + decoration: const InputDecoration( + contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5), + hintText: "请输入用户名", + ), + autofocus: false, + ), + const SizedBox( + height: 15, + ), + const Text( + "密码:", + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + ), + ), + TextField( + onChanged: (_) { + setState(() {}); + }, + controller: _passwordController, + obscureText: true, + decoration: const InputDecoration( + contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5), + hintText: "请输入密码", + ), + autofocus: false, + ), + const SizedBox( + height: 10, + ), + ], + ), + ), + back: SizedBox( + height: 200, + child: Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const SizedBox( + height: 15, + ), + const Text( + "client_id:", + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + ), + ), + TextField( + onChanged: (_) { + setState(() {}); + }, + controller: _cIdController, + decoration: const InputDecoration( + contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5), + hintText: "请输入client_id", + ), + autofocus: false, + ), + const SizedBox( + height: 15, + ), + const Text( + "client_secret:", + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + ), + ), + TextField( + onChanged: (_) { + setState(() {}); + }, + controller: _cSecretController, + obscureText: true, + decoration: const InputDecoration( + contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5), + hintText: "请输入client_secret", + ), + autofocus: false, + ), + const SizedBox( + height: 10, + ), + ], + ), + ), + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 25, + ), + child: Row( + children: [ + Checkbox( + value: rememberPassword, + onChanged: (checked) { + rememberPassword = checked ?? false; + setState(() {}); + }, + ), + const Text( + "记住密码/client", style: TextStyle( - color: ref.watch(themeProvider).primaryColor, fontSize: 14, ), ), + const Spacer(), + GestureDetector( + onTap: () { + cardKey.currentState?.toggleCard(); + WidgetsBinding.instance?.addPostFrameCallback((timeStamp) { + setState(() {}); + }); + }, + child: Text( + loginByUserName() ? "client_id登录" : "账号登录", + style: const TextStyle( + fontSize: 14, + ), + ), + ), + const SizedBox( + width: 10, + ), + ], + ), + ), + const SizedBox( + height: 30, + ), + Container( + alignment: Alignment.center, + padding: const EdgeInsets.symmetric( + horizontal: 40, + ), + child: SizedBox( + width: MediaQuery.of(context).size.width - 80, + child: IgnorePointer( + ignoring: !canClickLoginBtn(), + child: CupertinoButton( + padding: const EdgeInsets.symmetric( + vertical: 5, + ), + color: canClickLoginBtn() ? ref.watch(themeProvider).primaryColor : ref.watch(themeProvider).primaryColor.withOpacity(0.4), + child: isLoading + ? const CupertinoActivityIndicator() + : const Text( + "登 录", + style: TextStyle( + fontSize: 16, + ), + ), + onPressed: () { + Http.pushedLoginPage = false; + Utils.hideKeyBoard(context); + if (loginByUserName()) { + login(_userNameController.text, _passwordController.text); + } else { + login(_cIdController.text, _cSecretController.text); + } + }, + ), + ), + ), + ), + const SizedBox( + height: 30, + ), + ], + ), + ), + ), + Positioned( + bottom: 10, + child: (getIt().historyAccounts.isEmpty) + ? const SizedBox.shrink() + : SizedBox( + width: MediaQuery.of(context).size.width, + child: Center( + child: Material( + color: Colors.transparent, + child: PopupMenuButton( + onSelected: (UserInfoBean result) { + selected(result); + }, + itemBuilder: (BuildContext context) => >[ + ...getIt() + .historyAccounts + .map((e) => PopupMenuItem( + value: e, + child: buildCell(e), + )) + .toList(), + ], + child: Text( + "切换账号", + style: TextStyle( + color: ref.watch(themeProvider).primaryColor, + fontSize: 14, + ), + ), + ), ), ), ), - ), - ), - ], + ), + ], + ), ), ), ), diff --git a/lib/module/task/task_page.dart b/lib/module/task/task_page.dart index 8100d0b..314662a 100644 --- a/lib/module/task/task_page.dart +++ b/lib/module/task/task_page.dart @@ -57,7 +57,7 @@ class _TaskPageState extends State { text: "从未运行", ), Tab( - text: "非脚本类", + text: "拉库脚本", ), Tab( text: "已禁用", diff --git a/lib/module/task/task_viewmodel.dart b/lib/module/task/task_viewmodel.dart index 8a3e890..17ad24a 100644 --- a/lib/module/task/task_viewmodel.dart +++ b/lib/module/task/task_viewmodel.dart @@ -43,7 +43,7 @@ class TaskViewModel extends BaseViewModel { running.clear(); running.addAll(list.where((element) => element.status == 0)); neverRunning.clear(); - neverRunning.addAll(list.where((element) => element.lastRunningTime == null || element.lastRunningTime == 0)); + neverRunning.addAll(list.where((element) => element.lastRunningTime == null )); notScripts.clear(); notScripts.addAll(list.where((element) => (element.command != null && (element.command!.startsWith("ql repo") || element.command!.startsWith("ql raw"))))); disabled.clear(); diff --git a/pubspec.yaml b/pubspec.yaml index f092577..761546d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,17 +1,18 @@ name: qinglong_app description: A new Flutter project. publish_to: 'none' # Remove this line if you wish to publish to pub.dev -version: 1.0.6+8 +version: 1.0.7+9 environment: sdk: ">=2.15.1 <3.0.0" - flutter: ">=2.8.1" + flutter: ">=2.10.1" dependencies: flutter: sdk: flutter - + flutter_localizations: + sdk: flutter cupertino_icons: ^1.0.4 flutter_riverpod: ^1.0.3 shared_preferences: ^2.0.13 diff --git a/version b/version index ece61c6..f9cbc01 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.0.6 \ No newline at end of file +1.0.7 \ No newline at end of file