优化使用体验

This commit is contained in:
jyuesong
2022-06-08 10:06:54 +08:00
parent b89de1414a
commit 14c3b1a965
20 changed files with 659 additions and 454 deletions

1
.gitignore vendored
View File

@@ -44,3 +44,4 @@ app.*.map.json
/android/app/debug /android/app/debug
/android/app/profile /android/app/profile
/android/app/release /android/app/release
.fvm/

View File

@@ -29,7 +29,7 @@ class _BaseStateWidgetState<T extends BaseViewModel> extends ConsumerState<BaseS
Widget build(BuildContext context) { Widget build(BuildContext context) {
var viewModel = ref.watch<T>(widget.model); var viewModel = ref.watch<T>(widget.model);
if (viewModel.failedToast != null) { if (viewModel.failedToast != null) {
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) { WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
(viewModel.failedToast ?? "").toast(); (viewModel.failedToast ?? "").toast();
viewModel.clearToast(); viewModel.clearToast();
}); });
@@ -72,7 +72,7 @@ class _BaseStateWidgetState<T extends BaseViewModel> extends ConsumerState<BaseS
@override @override
void initState() { void initState() {
super.initState(); super.initState();
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) { WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
if (widget.onReady != null && !widget.lazyLoad) { if (widget.onReady != null && !widget.lazyLoad) {
widget.onReady!(ref.read<T>(widget.model)); widget.onReady!(ref.read<T>(widget.model));
} }

View File

@@ -24,7 +24,7 @@ class ThemeViewModel extends ChangeNotifier {
ThemeViewModel() { ThemeViewModel() {
_primaryColor = Color(getIt<UserInfoViewModel>().primaryColor); _primaryColor = Color(getIt<UserInfoViewModel>().primaryColor);
primaryColor = Color(getIt<UserInfoViewModel>().primaryColor); primaryColor = Color(getIt<UserInfoViewModel>().primaryColor);
var brightness = SchedulerBinding.instance!.window.platformBrightness; var brightness = SchedulerBinding.instance.window.platformBrightness;
_isInDarkMode = brightness == Brightness.dark; _isInDarkMode = brightness == Brightness.dark;
changeThemeReal(_isInDarkMode, false); changeThemeReal(_isInDarkMode, false);
} }

View File

@@ -6,7 +6,7 @@ mixin LazyLoadState<T extends StatefulWidget> on State<T> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) { WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
var route = ModalRoute.of(context); var route = ModalRoute.of(context);
void handler(status) { void handler(status) {
if (status == AnimationStatus.completed) { if (status == AnimationStatus.completed) {

View File

@@ -62,7 +62,7 @@ class QlAppState extends ConsumerState<QlApp> {
FocusScope.of(context).requestFocus(FocusNode()); FocusScope.of(context).requestFocus(FocusNode());
}, },
child: MediaQuery( child: MediaQuery(
data: MediaQueryData.fromWindow(WidgetsBinding.instance!.window).copyWith( data: MediaQueryData.fromWindow(WidgetsBinding.instance.window).copyWith(
textScaleFactor: 1, textScaleFactor: 1,
), ),
child: MaterialApp( child: MaterialApp(

View File

@@ -33,7 +33,7 @@ class _ConfigEditPageState extends ConsumerState<ConfigEditPage> {
super.initState(); super.initState();
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) { WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
focusNode.requestFocus(); focusNode.requestFocus();
}); });
} }

View File

@@ -121,6 +121,7 @@ class _CodeWidgetState extends State<CodeWidget>
with AutomaticKeepAliveClientMixin { with AutomaticKeepAliveClientMixin {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
super.build(context);
return SelectableText.rich( return SelectableText.rich(
TextSpan( TextSpan(
style: GoogleFonts.droidSansMono(fontSize: 14).apply( style: GoogleFonts.droidSansMono(fontSize: 14).apply(

View File

@@ -35,7 +35,7 @@ class _AddEnvPageState extends ConsumerState<AddEnvPage> {
} else { } else {
envBean = EnvBean(); envBean = EnvBean();
} }
WidgetsBinding.instance?.addPostFrameCallback( WidgetsBinding.instance.addPostFrameCallback(
(timeStamp) { (timeStamp) {
focusNode.requestFocus(); focusNode.requestFocus();
}, },

View File

@@ -44,7 +44,7 @@ class _HomePageState extends ConsumerState<HomePage>
initTitles(); initTitles();
_title = titles[0].title; _title = titles[0].title;
super.initState(); super.initState();
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) { WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
getSystemBean(); getSystemBean();
}); });
} }

View File

@@ -2,6 +2,7 @@ import 'package:dio_log/dio_log.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_animator/flutter_animator.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:qinglong_app/base/http/http.dart'; import 'package:qinglong_app/base/http/http.dart';
import 'package:qinglong_app/base/routes.dart'; import 'package:qinglong_app/base/routes.dart';
@@ -62,13 +63,15 @@ class _LoginPageState extends ConsumerState<LoginPage> {
} }
} }
getIt<UserInfoViewModel>().updateToken(""); getIt<UserInfoViewModel>().updateToken("");
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) { WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
if (useSecretLogin) { if (useSecretLogin) {
cardKey.currentState?.toggleCard(); cardKey.currentState?.toggleCard();
} }
}); });
} }
GlobalKey<AnimatorWidgetState> loginKey = GlobalKey<AnimatorWidgetState>();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@@ -76,20 +79,7 @@ class _LoginPageState extends ConsumerState<LoginPage> {
value: ref.watch(themeProvider).darkMode == true ? SystemUiOverlayStyle.light : SystemUiOverlayStyle.dark, value: ref.watch(themeProvider).darkMode == true ? SystemUiOverlayStyle.light : SystemUiOverlayStyle.dark,
child: ColoredBox( child: ColoredBox(
color: ref.watch(themeProvider).themeColor.settingBgColor(), color: ref.watch(themeProvider).themeColor.settingBgColor(),
child: SizedBox( child: SingleChildScrollView(
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( child: Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
@@ -103,16 +93,20 @@ class _LoginPageState extends ConsumerState<LoginPage> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
SizedBox( SizedBox(
height: MediaQuery.of(context).size.height / 10, height: MediaQuery.of(context).size.height / 8,
), ),
Row( Row(
children: [ children: [
Expanded( Expanded(
child: Align( child: Align(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: Image.asset( child: Text(
"assets/images/login_tip.png", useSecretLogin ? "client_id登录" : "账号登录",
height: 45, style: TextStyle(
fontSize: 26,
fontWeight: FontWeight.bold,
color: ref.watch(themeProvider).themeColor.titleColor(),
),
), ),
), ),
), ),
@@ -123,7 +117,7 @@ class _LoginPageState extends ConsumerState<LoginPage> {
} else { } else {
showDebugBtn(context, btnColor: ref.watch(themeProvider).primaryColor); showDebugBtn(context, btnColor: ref.watch(themeProvider).primaryColor);
} }
WidgetsBinding.instance?.endOfFrame; WidgetsBinding.instance.endOfFrame;
}, },
child: Image.asset( child: Image.asset(
"assets/images/ql.png", "assets/images/ql.png",
@@ -135,24 +129,49 @@ class _LoginPageState extends ConsumerState<LoginPage> {
SizedBox( SizedBox(
height: MediaQuery.of(context).size.height / 15, height: MediaQuery.of(context).size.height / 15,
), ),
const Text( Row(
"域名:", children: [
const SizedBox(
width: 40,
child: Text(
"域名",
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
fontWeight: FontWeight.w600,
), ),
), ),
TextField( ),
const SizedBox(
width: 30,
),
Expanded(
child: TextField(
onChanged: (_) { onChanged: (_) {
setState(() {}); setState(() {});
}, },
controller: _hostController, controller: _hostController,
decoration: const InputDecoration( decoration: InputDecoration(
contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5), border: InputBorder.none,
enabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,
isDense: true,
contentPadding: const EdgeInsets.all(4),
hintText: "http://1.1.1.1:5700", hintText: "http://1.1.1.1:5700",
hintStyle: TextStyle(
fontSize: 16,
color: ref.watch(themeProvider).themeColor.descColor(),
),
), ),
autofocus: false, autofocus: false,
), ),
),
],
),
const Divider(
color: Color(0xff999999),
),
const SizedBox(
height: 10,
),
FlipCard( FlipCard(
key: cardKey, key: cardKey,
flipOnTouch: false, flipOnTouch: false,
@@ -162,118 +181,197 @@ class _LoginPageState extends ConsumerState<LoginPage> {
}, },
direction: FlipDirection.HORIZONTAL, direction: FlipDirection.HORIZONTAL,
front: SizedBox( front: SizedBox(
height: 200, height: 110,
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [ children: [
const SizedBox( const SizedBox(
height: 15, child: Text(
), "账户",
const Text(
"用户名:",
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
fontWeight: FontWeight.w600,
), ),
), ),
TextField( width: 40,
),
const SizedBox(
width: 30,
),
Expanded(
child: TextField(
onChanged: (_) { onChanged: (_) {
setState(() {}); setState(() {});
}, },
controller: _userNameController, controller: _userNameController,
decoration: const InputDecoration( decoration: InputDecoration(
contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5), border: InputBorder.none,
hintText: "请输入用户名", enabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,
isDense: true,
contentPadding: const EdgeInsets.all(4),
hintText: "请输入账户",
hintStyle: TextStyle(
fontSize: 16,
color: ref.watch(themeProvider).themeColor.descColor(),
),
), ),
autofocus: false, autofocus: false,
), ),
const SizedBox(
height: 15,
), ),
const Text( ],
"密码:", ),
const Divider(
color: Color(0xff999999),
),
const SizedBox(
height: 10,
),
Row(
children: [
const SizedBox(
width: 40,
child: Text(
"密码",
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
fontWeight: FontWeight.w600,
), ),
), ),
TextField( ),
const SizedBox(
width: 30,
),
Expanded(
child: TextField(
onChanged: (_) { onChanged: (_) {
setState(() {}); setState(() {});
}, },
controller: _passwordController, controller: _passwordController,
obscureText: true, obscureText: true,
decoration: const InputDecoration( decoration: InputDecoration(
contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5), border: InputBorder.none,
enabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,
isDense: true,
contentPadding: const EdgeInsets.all(4),
hintText: "请输入密码", hintText: "请输入密码",
hintStyle: TextStyle(
fontSize: 16,
color: ref.watch(themeProvider).themeColor.descColor(),
),
), ),
autofocus: false, autofocus: false,
), ),
const SizedBox( ),
height: 10, ],
),
const Divider(
color: Color(0xff999999),
), ),
], ],
), ),
), ),
back: SizedBox( back: SizedBox(
height: 200, height: 110,
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [ children: [
const SizedBox( const SizedBox(
height: 15, width: 40,
), child: Text(
const Text( "id",
"client_id:",
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
fontWeight: FontWeight.w600,
), ),
), ),
TextField( ),
const SizedBox(
width: 30,
),
Expanded(
child: TextField(
onChanged: (_) { onChanged: (_) {
setState(() {}); setState(() {});
}, },
controller: _cIdController, controller: _cIdController,
decoration: const InputDecoration( decoration: InputDecoration(
contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5), border: InputBorder.none,
enabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,
isDense: true,
contentPadding: const EdgeInsets.all(4),
hintText: "请输入client_id", hintText: "请输入client_id",
hintStyle: TextStyle(
fontSize: 16,
color: ref.watch(themeProvider).themeColor.descColor(),
),
), ),
autofocus: false, autofocus: false,
), ),
const SizedBox(
height: 15,
), ),
const Text( ],
"client_secret:", ),
const Divider(
color: Color(0xff999999),
),
const SizedBox(
height: 10,
),
Row(
children: [
const SizedBox(
width: 50,
child: Text(
"secret",
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
fontWeight: FontWeight.w600,
), ),
), ),
TextField( ),
const SizedBox(
width: 20,
),
Expanded(
child: TextField(
onChanged: (_) { onChanged: (_) {
setState(() {}); setState(() {});
}, },
controller: _cSecretController, controller: _cSecretController,
obscureText: true, obscureText: true,
decoration: const InputDecoration( decoration: InputDecoration(
contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5), border: InputBorder.none,
enabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,
isDense: true,
contentPadding: const EdgeInsets.all(4),
hintText: "请输入client_secret", hintText: "请输入client_secret",
hintStyle: TextStyle(
fontSize: 16,
color: ref.watch(themeProvider).themeColor.descColor(),
),
), ),
autofocus: false, autofocus: false,
), ),
const SizedBox( ),
height: 10, ],
),
const Divider(
color: Color(0xff999999),
), ),
], ],
), ),
), ),
), ),
const SizedBox(
height: 10,
),
], ],
), ),
), ),
@@ -291,8 +389,9 @@ class _LoginPageState extends ConsumerState<LoginPage> {
}, },
), ),
const Text( const Text(
"记住密码/client", "记住密码",
style: TextStyle( style: TextStyle(
color: Color(0xff555555),
fontSize: 14, fontSize: 14,
), ),
), ),
@@ -300,13 +399,14 @@ class _LoginPageState extends ConsumerState<LoginPage> {
GestureDetector( GestureDetector(
onTap: () { onTap: () {
cardKey.currentState?.toggleCard(); cardKey.currentState?.toggleCard();
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) { WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
setState(() {}); setState(() {});
}); });
}, },
child: Text( child: Text(
loginByUserName() ? "client_id登录" : "账号登录", loginByUserName() ? "client_id登录" : "账号登录",
style: const TextStyle( style: const TextStyle(
color: Color(0xff555555),
fontSize: 14, fontSize: 14,
), ),
), ),
@@ -320,29 +420,52 @@ class _LoginPageState extends ConsumerState<LoginPage> {
const SizedBox( const SizedBox(
height: 30, height: 30,
), ),
Container( Shake(
preferences: const AnimationPreferences(autoPlay: AnimationPlayStates.None),
key: loginKey,
child: Center(
child: Container(
alignment: Alignment.center, alignment: Alignment.center,
width: MediaQuery.of(context).size.width * 0.8,
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
horizontal: 40, horizontal: 40,
), ),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: canClickLoginBtn()
? [
const Color(0xff5DD16F),
const Color(0xff089556),
]
: [
const Color(0xff5DD16F).withOpacity(0.6),
const Color(0xff089556).withOpacity(0.6),
],
),
borderRadius: const BorderRadius.all(
Radius.circular(10),
),
),
child: SizedBox( child: SizedBox(
width: MediaQuery.of(context).size.width - 80, width: MediaQuery.of(context).size.width - 80,
child: IgnorePointer( child: IgnorePointer(
ignoring: !canClickLoginBtn(), ignoring: !canClickLoginBtn(),
child: CupertinoButton( child: Builder(
builder: (context) {
return CupertinoButton(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
vertical: 5, vertical: 5,
), ),
color: canClickLoginBtn() ? ref.watch(themeProvider).primaryColor : ref.watch(themeProvider).primaryColor.withOpacity(0.4),
child: isLoading child: isLoading
? const CupertinoActivityIndicator() ? const CupertinoActivityIndicator()
: const Text( : const Text(
"登 录", "登 录",
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 18,
color: Colors.white,
), ),
), ),
onPressed: () { onPressed: () async {
Http.pushedLoginPage = false; Http.pushedLoginPage = false;
Utils.hideKeyBoard(context); Utils.hideKeyBoard(context);
if (loginByUserName()) { if (loginByUserName()) {
@@ -351,6 +474,10 @@ class _LoginPageState extends ConsumerState<LoginPage> {
login(_cIdController.text, _cSecretController.text); login(_cIdController.text, _cSecretController.text);
} }
}, },
);
},
),
),
), ),
), ),
), ),
@@ -358,15 +485,11 @@ class _LoginPageState extends ConsumerState<LoginPage> {
const SizedBox( const SizedBox(
height: 30, height: 30,
), ),
], (getIt<UserInfoViewModel>().historyAccounts.isEmpty)
),
),
),
Positioned(
bottom: 10,
child: (getIt<UserInfoViewModel>().historyAccounts.isEmpty)
? const SizedBox.shrink() ? const SizedBox.shrink()
: SizedBox( : SafeArea(
top: false,
child: SizedBox(
width: MediaQuery.of(context).size.width, width: MediaQuery.of(context).size.width,
child: Center( child: Center(
child: Material( child: Material(
@@ -378,19 +501,34 @@ class _LoginPageState extends ConsumerState<LoginPage> {
itemBuilder: (BuildContext context) => <PopupMenuEntry<UserInfoBean>>[ itemBuilder: (BuildContext context) => <PopupMenuEntry<UserInfoBean>>[
...getIt<UserInfoViewModel>() ...getIt<UserInfoViewModel>()
.historyAccounts .historyAccounts
.map((e) => PopupMenuItem<UserInfoBean>( .map(
(e) => PopupMenuItem<UserInfoBean>(
value: e, value: e,
child: buildCell(e), child: buildCell(context, e),
)) ),
)
.toList(), .toList(),
], ],
child: Text( child: Row(
"切换账号", mainAxisSize: MainAxisSize.min,
children: [
Image.asset(
"assets/images/icon_history.png",
fit: BoxFit.cover,
width: 16,
),
const SizedBox(
width: 5,
),
const Text(
"历史账号",
style: TextStyle( style: TextStyle(
color: ref.watch(themeProvider).primaryColor, color: Color(0xff555555),
fontSize: 14, fontSize: 14,
), ),
), ),
],
),
), ),
), ),
), ),
@@ -434,6 +572,7 @@ class _LoginPageState extends ConsumerState<LoginPage> {
void loginFailed() { void loginFailed() {
isLoading = false; isLoading = false;
loginKey.currentState?.forward();
setState(() {}); setState(() {});
} }
@@ -512,7 +651,7 @@ class _LoginPageState extends ConsumerState<LoginPage> {
}); });
} }
Widget buildCell(UserInfoBean bean) { Widget buildCell(BuildContext context, UserInfoBean bean) {
return ListTile( return ListTile(
title: Text( title: Text(
bean.host ?? "", bean.host ?? "",
@@ -525,6 +664,19 @@ class _LoginPageState extends ConsumerState<LoginPage> {
bean.userName ?? "", bean.userName ?? "",
), ),
), ),
contentPadding: EdgeInsets.zero,
trailing: GestureDetector(
onTap: () {
getIt<UserInfoViewModel>().removeHistoryAccount(bean.host);
Navigator.pop(context);
setState(() {});
},
child: const Icon(
CupertinoIcons.clear_thick,
size: 20,
),
),
); );
} }
@@ -534,7 +686,7 @@ class _LoginPageState extends ConsumerState<LoginPage> {
_cIdController.text = result.userName ?? ""; _cIdController.text = result.userName ?? "";
_cSecretController.text = result.password ?? ""; _cSecretController.text = result.password ?? "";
if (cardKey.currentState?.isFront ?? false) { if (cardKey.currentState?.isFront ?? false) {
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) { WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
cardKey.currentState?.toggleCard(); cardKey.currentState?.toggleCard();
}); });
} }
@@ -542,7 +694,7 @@ class _LoginPageState extends ConsumerState<LoginPage> {
_userNameController.text = result.userName ?? ""; _userNameController.text = result.userName ?? "";
_passwordController.text = result.password ?? ""; _passwordController.text = result.password ?? "";
if (!(cardKey.currentState?.isFront ?? false)) { if (!(cardKey.currentState?.isFront ?? false)) {
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) { WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
cardKey.currentState?.toggleCard(); cardKey.currentState?.toggleCard();
}); });
} }

View File

@@ -283,7 +283,7 @@ class DependencyCell extends ConsumerWidget {
} }
void showLog(WidgetRef ref, String? sId) { void showLog(WidgetRef ref, String? sId) {
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) { WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
showCupertinoDialog( showCupertinoDialog(
builder: (BuildContext context) { builder: (BuildContext context) {
return CupertinoAlertDialog( return CupertinoAlertDialog(

View File

@@ -219,7 +219,7 @@ class _ScriptDetailPageState extends ConsumerState<ScriptDetailPage>
? const Center( ? const Center(
child: CupertinoActivityIndicator(), child: CupertinoActivityIndicator(),
) )
: CodeWidget( : ScriptCodeWidget(
content: content ?? "", content: content ?? "",
), ),
); );
@@ -265,3 +265,40 @@ class _ScriptDetailPageState extends ConsumerState<ScriptDetailPage>
loadData(); loadData();
} }
} }
class ScriptCodeWidget extends StatefulWidget {
final String content;
const ScriptCodeWidget({
Key? key,
required this.content,
}) : super(key: key);
@override
State<ScriptCodeWidget> createState() => _ScriptCodeWidgetState();
}
class _ScriptCodeWidgetState extends State<ScriptCodeWidget>{
@override
Widget build(BuildContext context) {
return SelectableText.rich(
TextSpan(
style: GoogleFonts.droidSansMono(fontSize: 14).apply(
fontSizeFactor: 1,
),
children: <TextSpan>[
DartSyntaxHighlighter(SyntaxHighlighterStyle.lightThemeStyle())
.format(widget.content)
],
),
style: DefaultTextStyle.of(context).style.apply(
fontSizeFactor: 1,
),
selectionWidthStyle: BoxWidthStyle.max,
selectionHeightStyle: BoxHeightStyle.max,
autofocus: true,
);
}
}

View File

@@ -41,7 +41,7 @@ class _ScriptEditPageState extends ConsumerState<ScriptEditPage> {
super.initState(); super.initState();
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) { WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
focusNode.requestFocus(); focusNode.requestFocus();
}); });
} }
@@ -117,26 +117,12 @@ class _ScriptEditPageState extends ConsumerState<ScriptEditPage> {
), ),
body: SafeArea( body: SafeArea(
top: false, top: false,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 10,
),
child: CodeField( child: CodeField(
controller: _codeController!, controller: _codeController!,
expands: true, expands: true,
wrap: true,
lineNumberStyle: LineNumberStyle(
width: 0,
margin: 0,
textStyle: TextStyle(
color: ref.watch(themeProvider).themeColor.descColor(),
),
),
background: ref.watch(themeProvider).themeColor.tabBarColor(), background: ref.watch(themeProvider).themeColor.tabBarColor(),
), ),
), ),
),
); );
} }
} }

View File

@@ -67,7 +67,15 @@ class _ScriptPageState extends ConsumerState<ScriptPage> with LazyLoadState<Scri
? const Center( ? const Center(
child: CupertinoActivityIndicator(), child: CupertinoActivityIndicator(),
) )
: ListView.builder( : RefreshIndicator(
color: Theme.of(context).primaryColor,
onRefresh: () async {
await loadData();
return Future.value();
},
child: ListView.builder(
physics: const AlwaysScrollableScrollPhysics(),
keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
itemBuilder: (context, index) { itemBuilder: (context, index) {
if (index == 0) { if (index == 0) {
return searchCell(ref); return searchCell(ref);
@@ -162,6 +170,7 @@ class _ScriptPageState extends ConsumerState<ScriptPage> with LazyLoadState<Scri
}, },
itemCount: list.length + 1, itemCount: list.length + 1,
), ),
),
); );
} }
@@ -171,7 +180,9 @@ class _ScriptPageState extends ConsumerState<ScriptPage> with LazyLoadState<Scri
horizontal: 15, horizontal: 15,
vertical: 10, vertical: 10,
), ),
child:SearchCell(controller: _searchController,), child: SearchCell(
controller: _searchController,
),
); );
} }
@@ -220,6 +231,8 @@ class _ScriptPageState extends ConsumerState<ScriptPage> with LazyLoadState<Scri
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
vertical: 10, vertical: 10,
), ),
child: Material(
color: Colors.transparent,
child: TextField( child: TextField(
controller: _nameController, controller: _nameController,
decoration: const InputDecoration( decoration: const InputDecoration(
@@ -233,19 +246,25 @@ class _ScriptPageState extends ConsumerState<ScriptPage> with LazyLoadState<Scri
autofocus: false, autofocus: false,
), ),
), ),
),
const SizedBox( const SizedBox(
height: 10, height: 10,
), ),
const Text( const Material(
color: Colors.transparent,
child: Text(
"脚本所属文件夹:", "脚本所属文件夹:",
style: TextStyle( style: TextStyle(
fontSize: 14, fontSize: 14,
), ),
), ),
),
const SizedBox( const SizedBox(
height: 10, height: 10,
), ),
DropdownButtonFormField<String>( Material(
color: Colors.transparent,
child: DropdownButtonFormField<String>(
items: list items: list
.where((element) => element.children?.isNotEmpty ?? false) .where((element) => element.children?.isNotEmpty ?? false)
.map((e) => DropdownMenuItem( .map((e) => DropdownMenuItem(
@@ -276,6 +295,7 @@ class _ScriptPageState extends ConsumerState<ScriptPage> with LazyLoadState<Scri
scriptPath = value ?? ""; scriptPath = value ?? "";
}, },
), ),
),
], ],
), ),
actions: [ actions: [

View File

@@ -31,7 +31,7 @@ class _UpdatePasswordPageState extends ConsumerState<UpdatePasswordPage> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
WidgetsBinding.instance?.addPostFrameCallback( WidgetsBinding.instance.addPostFrameCallback(
(timeStamp) { (timeStamp) {
focusNode.requestFocus(); focusNode.requestFocus();
}, },

View File

@@ -36,7 +36,7 @@ class _AddTaskPageState extends ConsumerState<AddTaskPage> {
} else { } else {
taskBean = TaskBean(); taskBean = TaskBean();
} }
WidgetsBinding.instance?.addPostFrameCallback( WidgetsBinding.instance.addPostFrameCallback(
(timeStamp) { (timeStamp) {
focusNode.requestFocus(); focusNode.requestFocus();
}, },

View File

@@ -345,7 +345,7 @@ class _TaskDetailPageState extends ConsumerState<TaskDetailPage> {
startCron(BuildContext context, WidgetRef ref) async { startCron(BuildContext context, WidgetRef ref) async {
await ref.read(taskProvider).runCrons(widget.taskBean.sId!); await ref.read(taskProvider).runCrons(widget.taskBean.sId!);
setState(() {}); setState(() {});
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) { WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
showLog(); showLog();
}); });
} }

View File

@@ -245,7 +245,7 @@ class TaskItemCell extends StatelessWidget {
SlidableAction( SlidableAction(
backgroundColor: const Color(0xff5D5E70), backgroundColor: const Color(0xff5D5E70),
onPressed: (_) { onPressed: (_) {
WidgetsBinding.instance?.endOfFrame.then((timeStamp) { WidgetsBinding.instance.endOfFrame.then((timeStamp) {
Navigator.of(context).pushNamed(Routes.routeAddTask, arguments: bean); Navigator.of(context).pushNamed(Routes.routeAddTask, arguments: bean);
}); });
}, },

View File

@@ -42,7 +42,7 @@ packages:
name: back_button_interceptor name: back_button_interceptor
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "5.0.2" version: "6.0.0"
boolean_selector: boolean_selector:
dependency: transitive dependency: transitive
description: description:
@@ -168,7 +168,7 @@ packages:
name: collection name: collection
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.15.0" version: "1.16.0"
convert: convert:
dependency: transitive dependency: transitive
description: description:
@@ -189,7 +189,7 @@ packages:
name: cupertino_icons name: cupertino_icons
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.0.4" version: "1.0.5"
dart_style: dart_style:
dependency: transitive dependency: transitive
description: description:
@@ -224,7 +224,7 @@ packages:
name: fake_async name: fake_async
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.2.0" version: "1.3.0"
ffi: ffi:
dependency: transitive dependency: transitive
description: description:
@@ -258,6 +258,13 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
flutter_animator:
dependency: "direct main"
description:
name: flutter_animator
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.2.2"
flutter_app_name: flutter_app_name:
dependency: "direct dev" dependency: "direct dev"
description: description:
@@ -311,7 +318,7 @@ packages:
name: flutter_riverpod name: flutter_riverpod
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.0.3" version: "1.0.4"
flutter_slidable: flutter_slidable:
dependency: "direct main" dependency: "direct main"
description: description:
@@ -433,7 +440,7 @@ packages:
name: js name: js
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.6.3" version: "0.6.4"
json_annotation: json_annotation:
dependency: transitive dependency: transitive
description: description:
@@ -503,7 +510,7 @@ packages:
name: material_color_utilities name: material_color_utilities
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.1.3" version: "0.1.4"
meta: meta:
dependency: transitive dependency: transitive
description: description:
@@ -580,7 +587,7 @@ packages:
name: path name: path
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.8.0" version: "1.8.1"
path_provider: path_provider:
dependency: transitive dependency: transitive
description: description:
@@ -781,7 +788,7 @@ packages:
name: source_span name: source_span
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.8.1" version: "1.8.2"
stack_trace: stack_trace:
dependency: transitive dependency: transitive
description: description:
@@ -837,7 +844,7 @@ packages:
name: test_api name: test_api
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.4.8" version: "0.4.9"
timing: timing:
dependency: transitive dependency: transitive
description: description:
@@ -865,7 +872,7 @@ packages:
name: url_launcher name: url_launcher
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "6.1.2" version: "6.1.3"
url_launcher_android: url_launcher_android:
dependency: transitive dependency: transitive
description: description:
@@ -921,7 +928,7 @@ packages:
name: vector_math name: vector_math
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.1" version: "2.1.2"
watcher: watcher:
dependency: transitive dependency: transitive
description: description:
@@ -972,5 +979,5 @@ packages:
source: hosted source: hosted
version: "3.1.1" version: "3.1.1"
sdks: sdks:
dart: ">=2.16.0 <3.0.0" dart: ">=2.17.0-0 <3.0.0"
flutter: ">=2.10.1" flutter: ">=3.0.0"

View File

@@ -13,13 +13,13 @@ dependencies:
sdk: flutter sdk: flutter
flutter_localizations: flutter_localizations:
sdk: flutter sdk: flutter
cupertino_icons: ^1.0.4 cupertino_icons: ^1.0.5
flutter_riverpod: ^1.0.3 flutter_riverpod: ^1.0.4
shared_preferences: ^2.0.13 shared_preferences: ^2.0.15
synchronized: ^3.0.0 synchronized: ^3.0.0+2
back_button_interceptor: ^5.0.2 back_button_interceptor: ^6.0.0
flutter_slidable: ^1.2.0 flutter_slidable: ^1.3.0
dio: ^4.0.4 dio: ^4.0.6
dio_log: ^2.0.2 dio_log: ^2.0.2
json_conversion_annotation: ^0.0.4 json_conversion_annotation: ^0.0.4
logger: ^1.1.0 logger: ^1.1.0
@@ -27,14 +27,15 @@ dependencies:
get_it: ^7.2.0 get_it: ^7.2.0
highlight: ^0.7.0 highlight: ^0.7.0
drag_and_drop_lists: ^0.3.2+2 drag_and_drop_lists: ^0.3.2+2
fluttertoast: ^8.0.8 fluttertoast: ^8.0.9
move_to_background: ^1.0.2 move_to_background: ^1.0.2
flip_card: ^0.6.0 flip_card: ^0.6.0
package_info_plus: ^1.4.0 package_info_plus: ^1.4.2
url_launcher: ^6.0.20 url_launcher: ^6.1.3
flutter_colorpicker: ^1.0.3 flutter_colorpicker: ^1.0.3
widget_with_codeview: ^2.0.1+2 widget_with_codeview: ^2.0.1+2
code_text_field: ^1.0.2 code_text_field: ^1.0.2
flutter_animator: ^3.2.1
# flutter pub run build_runner build --delete-conflicting-outputs # flutter pub run build_runner build --delete-conflicting-outputs
# flutter pub run change_app_package_name:main work.master.qinglongapp # flutter pub run change_app_package_name:main work.master.qinglongapp