This commit is contained in:
toly
2023-12-10 15:25:12 +08:00
parent 2ceed8b9b5
commit 7b16b52761
86 changed files with 3635 additions and 930 deletions

View File

@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:iroute/components/project/colors_panel.dart';
import '../../app/navigation/router/app_router_delegate.dart';
class ColorPage extends StatefulWidget {
const ColorPage({super.key});
@@ -11,10 +11,26 @@ class ColorPage extends StatefulWidget {
class _ColorPageState extends State<ColorPage> {
final List<Color> _colors = [
Colors.red, Colors.black, Colors.blue, Colors.green, Colors.orange,
Colors.pink, Colors.purple, Colors.indigo, Colors.amber, Colors.cyan,
Colors.redAccent, Colors.grey, Colors.blueAccent, Colors.greenAccent, Colors.orangeAccent,
Colors.pinkAccent, Colors.purpleAccent, Colors.indigoAccent, Colors.amberAccent, Colors.cyanAccent,
Colors.red,
Colors.black,
Colors.blue,
Colors.green,
Colors.orange,
Colors.pink,
Colors.purple,
Colors.indigo,
Colors.amber,
Colors.cyan,
Colors.redAccent,
Colors.grey,
Colors.blueAccent,
Colors.greenAccent,
Colors.orangeAccent,
Colors.pinkAccent,
Colors.purpleAccent,
Colors.indigoAccent,
Colors.amberAccent,
Colors.cyanAccent,
];
@override
@@ -47,20 +63,19 @@ class _ColorPageState extends State<ColorPage> {
);
}
void _selectColor(Color color){
void _selectColor(Color color) {
String value = color.value.toRadixString(16);
String path = '/app/color/detail?color=$value';
// router.changePath('/app/color/detail',extra: color);
router.changePath(path,recordHistory: true);
context.push('/color/detail?color=$value');
// GoRouter.of(context) .pushNamed('colorDetail', queryParameters: {'color': value});
}
void _toAddPage() async {
Color? color = await router.changePath('/app/color/add',forResult: true,recordHistory: false);
if (color != null) {
setState(() {
_colors.add(color);
});
}
Color? color = await context.push('/color/add');
if (color != null) {
setState(() {
_colors.add(color);
});
}
}
}
}

View File

@@ -1,30 +1,48 @@
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:iroute/components/components.dart';
class EmptyPage extends StatelessWidget {
const EmptyPage({super.key});
final String msg;
const EmptyPage({super.key, required this.msg});
@override
Widget build(BuildContext context) {
return Scaffold(
// appBar: AppBar(
// title: Text('界面走丢了'),
// ),
body: Scaffold(
body: Center(
child: Wrap(
spacing: 16,
crossAxisAlignment: WrapCrossAlignment.center,
direction: Axis.vertical,
return DragToMoveWrap(
child: Scaffold(
appBar: PreferredSize(
preferredSize: Size.fromHeight(46),
child: Row(
children: [
Icon(Icons.nearby_error,size: 64, color: Colors.grey),
const SizedBox(width: 20,),
Text(
'404 界面丢失',
style: TextStyle(fontSize: 24, color: Colors.grey),
style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold),
),
Spacer(),
const WindowButtons()
],
),
),
body: Center(
child: Wrap(
spacing: 16,
crossAxisAlignment: WrapCrossAlignment.center,
direction: Axis.vertical,
children: [
Icon(Icons.nearby_error,size: 64, color: Colors.redAccent),
Text(
msg,
style: TextStyle(fontSize: 24, color: Colors.grey),
),
ElevatedButton(onPressed: (){
context.go('/');
}, child: Text('返回首页'))
],
),
),
),
);
}
}

View File

@@ -0,0 +1,30 @@
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:iroute/components/components.dart';
class EmptyPanel extends StatelessWidget {
final String msg;
const EmptyPanel({super.key, required this.msg});
@override
Widget build(BuildContext context) {
return Center(
child: Wrap(
spacing: 16,
crossAxisAlignment: WrapCrossAlignment.center,
direction: Axis.vertical,
children: [
Icon(Icons.nearby_error,size: 64, color: Colors.redAccent),
Text(
msg,
style: TextStyle(fontSize: 24, color: Colors.grey),
),
ElevatedButton(onPressed: (){
context.go('/');
}, child: Text('返回首页'))
],
),
);
}
}

View File

@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import '../../app/navigation/router/app_router_delegate.dart';
import 'package:go_router/go_router.dart';
class LoginPage extends StatelessWidget {
const LoginPage({super.key});
@@ -14,7 +15,8 @@ class LoginPage extends StatelessWidget {
Text('Login Page',style: TextStyle(fontSize: 24),),
const SizedBox(height: 20,),
ElevatedButton(onPressed: (){
router.changePath('/app/color');
GoRouter.of(context).go('/color');
// router.changePath('/app/color');
}, child: Text('点击进入'))
],
),

View File

@@ -99,6 +99,7 @@ class SortStateScope extends InheritedNotifier<SortState> {
static SortState of(BuildContext context) =>
context.dependOnInheritedWidgetOfExactType<SortStateScope>()!.notifier!;
static SortState read(BuildContext context) =>
context.getInheritedWidgetOfExactType<SortStateScope>()!.notifier!;
static SortState read(BuildContext context) {
return context.getInheritedWidgetOfExactType<SortStateScope>()!.notifier!;
}
}

View File

@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import '../../provider/state.dart';
import 'color_picker.dart';
class SortSettings extends StatefulWidget {
@@ -66,8 +67,9 @@ class _SortSettingsState extends State<SortSettings> {
child: IconButton(
splashRadius: 20,
onPressed: (){
SortState state = SortStateScope.of(context);
state.config =state.config.copyWith(
SortState state = SortStateScope.read(context);
state.config = state.config.copyWith(
count: int.parse(_count.text),
duration: Duration(
microseconds: int.parse(_duration.text),
@@ -75,7 +77,8 @@ class _SortSettingsState extends State<SortSettings> {
seed: int.parse(_seed.text),
colorIndex: _colorIndex
);
Navigator.of(context).pop();
GoRouter.of(context).pop();
// Navigator.of(context).pop();
}, icon: Icon(Icons.check)),
)],
iconTheme: IconThemeData(color: Colors.black),

View File

@@ -1,8 +1,7 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../../app/navigation/router/iroute_config.dart';
import '../../../../app/navigation/router/app_router_delegate.dart';
import 'package:go_router/go_router.dart';
import 'sort_button.dart';
import '../../functions.dart';
@@ -62,7 +61,8 @@ class SortRailPanel extends StatelessWidget {
cursor: SystemMouseCursors.click,
child: GestureDetector(
onTap: () {
router.changePath('/app/sort/settings',style: RouteStyle.push);
GoRouter.of(context).push('/sort/settings');
// router.changePath('/app/sort/settings',style: RouteStyle.push);
},
child: const Icon(
CupertinoIcons.settings,
@@ -81,7 +81,7 @@ class SortRailPanel extends StatelessWidget {
options: sortNameMap.values.toList(),
onSelected: (name) {
state.selectName(name);
router.changePath('/app/sort/${name}',recordHistory: true);
GoRouter.of(context).go('/sort/player/$name');
},
),
),