-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: UUID生成
- Loading branch information
Showing
14 changed files
with
674 additions
and
286 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,154 +1,156 @@ | ||
import 'dart:ui'; | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:refreshed/refreshed.dart'; | ||
import 'package:go_router/go_router.dart'; | ||
import 'package:simple_icons/simple_icons.dart'; | ||
import 'package:tools/func_enum.dart'; | ||
import 'package:tools/global_variable.dart'; | ||
import 'package:web/web.dart' as web; | ||
|
||
// class Man | ||
|
||
class BasePage extends StatelessWidget { | ||
final Future<Widget> Function() child; | ||
final String title; | ||
final Rxn<Widget> body = Rxn<Widget>(); | ||
BasePage({super.key, required this.title, required this.child}); | ||
// final Rxn<Widget> body = Rxn<Widget>(); | ||
const BasePage({super.key, required this.title, required this.child}); | ||
|
||
// bool get isDark => Theme.of(Get.context!).brightness == Brightness.dark; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
if (body.value == null) child().then(body.call); | ||
|
||
bool isDark = Theme.of(context).brightness == Brightness.dark; | ||
|
||
return Scaffold( | ||
appBar: AppBar( | ||
title: Text(title), | ||
centerTitle: true, | ||
elevation: 0, | ||
shadowColor: Colors.transparent, | ||
backgroundColor: Colors.transparent, | ||
scrolledUnderElevation: 0, | ||
), | ||
drawer: Drawer( | ||
child: Column( | ||
children: [ | ||
DrawerHeader( | ||
decoration: const BoxDecoration( | ||
color: Color.fromARGB(255, 44, 78, 105), | ||
), | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.spaceAround, | ||
children: [ | ||
const Text( | ||
'功能列表', | ||
style: TextStyle(color: Colors.white, fontSize: 24), | ||
), | ||
appBar: AppBar( | ||
title: Text(title), | ||
centerTitle: true, | ||
elevation: 0, | ||
shadowColor: Colors.transparent, | ||
backgroundColor: Colors.transparent, | ||
scrolledUnderElevation: 0, | ||
), | ||
drawer: Drawer( | ||
child: Column( | ||
children: [ | ||
DrawerHeader( | ||
decoration: const BoxDecoration( | ||
color: Color.fromARGB(255, 44, 78, 105), | ||
), | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.spaceAround, | ||
children: [ | ||
const Text( | ||
'功能列表', | ||
style: TextStyle(color: Colors.white, fontSize: 24), | ||
), | ||
|
||
/// 搜索框 | ||
ClipRRect( | ||
borderRadius: BorderRadius.circular(20), | ||
child: BackdropFilter( | ||
filter: ImageFilter.blur(sigmaX: 10, sigmaY: 10), | ||
child: Container( | ||
decoration: BoxDecoration( | ||
color: Colors.white.withAlpha(100), | ||
borderRadius: BorderRadius.circular(20), | ||
border: | ||
Border.all(color: Colors.white.withAlpha(100)), | ||
), | ||
child: TextField( | ||
onChanged: GlobalVariable.searchRx.call, | ||
controller: TextEditingController( | ||
text: GlobalVariable.searchRx.value), | ||
decoration: const InputDecoration( | ||
hintText: "搜索工具", | ||
prefixIcon: Icon(Icons.search), | ||
border: InputBorder.none, | ||
contentPadding: EdgeInsets.symmetric( | ||
horizontal: 16, vertical: 14), | ||
), | ||
/// 搜索框 | ||
ClipRRect( | ||
borderRadius: BorderRadius.circular(20), | ||
child: BackdropFilter( | ||
filter: ImageFilter.blur(sigmaX: 10, sigmaY: 10), | ||
child: Container( | ||
decoration: BoxDecoration( | ||
color: Colors.white.withAlpha(100), | ||
borderRadius: BorderRadius.circular(20), | ||
border: | ||
Border.all(color: Colors.white.withAlpha(100)), | ||
), | ||
child: TextField( | ||
onChanged: (value) { | ||
GlobalVariable.searchNotifier.value = value; | ||
}, | ||
controller: TextEditingController( | ||
text: GlobalVariable.searchNotifier.value), | ||
decoration: const InputDecoration( | ||
hintText: "搜索工具", | ||
prefixIcon: Icon(Icons.search), | ||
border: InputBorder.none, | ||
contentPadding: EdgeInsets.symmetric( | ||
horizontal: 16, vertical: 14), | ||
), | ||
), | ||
), | ||
) | ||
], | ||
), | ||
), | ||
) | ||
], | ||
), | ||
Expanded( | ||
child: ListView( | ||
/// 内容居中 | ||
physics: const BouncingScrollPhysics(), | ||
padding: EdgeInsets.zero, | ||
children: [ | ||
ValueListenableBuilder( | ||
valueListenable: GlobalVariable.searchRx, | ||
builder: (context, value, child) { | ||
List<FunctionEnum> list = FunctionEnum.values | ||
.where((element) => (GlobalVariable | ||
.searchRx.value.isNotEmpty | ||
? element.name | ||
.contains(GlobalVariable.searchRx.value) | ||
: true)) | ||
.toList(); | ||
if (list.isEmpty) { | ||
return const ListTile( | ||
title: Text("没有找到相关工具"), | ||
); | ||
} | ||
|
||
return Column( | ||
children: (list) | ||
.map((e) => ListTile( | ||
title: Text(e.name), | ||
tileColor: e.route == Get.currentRoute | ||
? Colors.blue.withAlpha(100) | ||
: null, | ||
onTap: e.onTap)) | ||
.toList(), | ||
), | ||
Expanded( | ||
child: ListView( | ||
/// 内容居中 | ||
physics: const BouncingScrollPhysics(), | ||
padding: EdgeInsets.zero, | ||
children: [ | ||
ValueListenableBuilder( | ||
valueListenable: GlobalVariable.searchNotifier, | ||
builder: (context, value, child) { | ||
List<FunctionEnum> list = FunctionEnum.values | ||
.where((element) => | ||
(GlobalVariable.searchNotifier.value.isNotEmpty | ||
? element.name.contains( | ||
GlobalVariable.searchNotifier.value) | ||
: true)) | ||
.toList(); | ||
if (list.isEmpty) { | ||
return const ListTile( | ||
title: Text("没有找到相关工具"), | ||
); | ||
}), | ||
], | ||
), | ||
} | ||
|
||
return Column( | ||
children: (list) | ||
.map((e) => ListTile( | ||
title: Text(e.name), | ||
tileColor: e.route == | ||
GoRouter.of(context).state?.path | ||
? Colors.blue.withAlpha(100) | ||
: null, | ||
onTap: e.onTap)) | ||
.toList(), | ||
); | ||
}), | ||
], | ||
), | ||
const Divider(), | ||
Padding( | ||
padding: const EdgeInsets.all(16.0), | ||
child: Row( | ||
children: [ | ||
TextButton( | ||
), | ||
const Divider(), | ||
Padding( | ||
padding: const EdgeInsets.all(16.0), | ||
child: Row( | ||
children: [ | ||
TextButton( | ||
onPressed: () { | ||
web.window.open("https://github.com/bymoye/tools"); | ||
}, | ||
child: const Row( | ||
children: [ | ||
Icon(SimpleIcons.github, size: 20), | ||
SizedBox(width: 8), | ||
Text("bymoye/tools") | ||
], | ||
), | ||
), | ||
const Spacer(), | ||
IconButton( | ||
onPressed: () { | ||
web.window.open("https://github.com/bymoye/tools"); | ||
GlobalVariable.themeModeNotifier.value = | ||
isDark ? ThemeMode.light : ThemeMode.dark; | ||
}, | ||
child: const Row( | ||
children: [ | ||
Icon(SimpleIcons.github, size: 20), | ||
SizedBox(width: 8), | ||
Text("bymoye/tools") | ||
], | ||
), | ||
), | ||
const Spacer(), | ||
IconButton( | ||
onPressed: () { | ||
Get.changeThemeMode( | ||
isDark ? ThemeMode.light : ThemeMode.dark); | ||
}, | ||
icon: | ||
Icon(isDark ? Icons.light_mode : Icons.dark_mode)) | ||
], | ||
)) | ||
], | ||
), | ||
icon: Icon(isDark ? Icons.light_mode : Icons.dark_mode)) | ||
], | ||
)) | ||
], | ||
), | ||
body: Obx( | ||
() => | ||
body.value ?? | ||
const Center( | ||
child: CircularProgressIndicator(), | ||
), | ||
)); | ||
), | ||
body: FutureBuilder( | ||
future: child(), | ||
builder: (context, snapshot) { | ||
return snapshot.hasData | ||
? snapshot.data! | ||
: const Center( | ||
child: CircularProgressIndicator(), | ||
); | ||
}, | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import 'package:refreshed/refreshed.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class GlobalVariable { | ||
static RxString searchRx = RxString(""); | ||
static ValueNotifier<ThemeMode> themeModeNotifier = | ||
ValueNotifier(ThemeMode.system); | ||
static ValueNotifier<String> searchNotifier = ValueNotifier(""); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.