Skip to content

Commit

Permalink
修复诸多问题
Browse files Browse the repository at this point in the history
  • Loading branch information
bymoye committed Jul 13, 2024
1 parent 86f3de9 commit b40d6c2
Show file tree
Hide file tree
Showing 7 changed files with 296 additions and 239 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@

- 占位.
- 待做事项:
1. UUID工具
2. markdown编写/解析工具
3. quill编辑器
4. 二维码生成/解析工具(qr_flutter),如果可以的话,调用摄像头扫描二维码
5. 条形码生成/解析工具
228 changes: 120 additions & 108 deletions lib/base_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,134 +4,146 @@ import 'package:flutter/material.dart';
import 'package:refreshed/refreshed.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 RxString searchRx = RxString("");
late final Rxn<Widget> future = Rxn<Widget>();
final Rxn<Widget> body = Rxn<Widget>();
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 (future.value == null) {
child().then((value) => future.value = value);
}
if (body.value == null) child().then(body.call);

bool isDark = Theme.of(context).brightness == Brightness.dark;

return Scaffold(
floatingActionButton: FloatingActionButton(
onPressed: () {
Get.changeThemeMode(isDark ? ThemeMode.light : ThemeMode.dark);
},
child: Icon(isDark ? Icons.light_mode : Icons.dark_mode),
),
drawer: Drawer(
child: Column(
children: [
Expanded(
child: ListView(
/// 内容居中
physics: const BouncingScrollPhysics(),
padding: EdgeInsets.zero,
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),
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.withOpacity(0.2),
borderRadius: BorderRadius.circular(20),
border:
Border.all(color: Colors.white.withOpacity(0.2)),
),
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),
),
),
),
),
)
],
),
),
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("没有找到相关工具"),
);
}

/// 搜索框
ClipRRect(
borderRadius: BorderRadius.circular(20),
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 10, sigmaY: 10),
child: Container(
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.2),
borderRadius: BorderRadius.circular(20),
border: Border.all(
color: Colors.white.withOpacity(0.2)),
),
child: TextField(
onChanged: searchRx.call,
controller: TextEditingController(
text: searchRx.value),
decoration: const InputDecoration(
hintText: "搜索工具",
prefixIcon: Icon(Icons.search),
border: InputBorder.none,
contentPadding: EdgeInsets.symmetric(
horizontal: 16, vertical: 14),
),
),
),
),
)
return Column(
children: (list)
.map((e) => ListTile(
title: Text(e.name),
tileColor: e.route == Get.currentRoute
? Colors.blue.withOpacity(0.2)
: null,
onTap: e.onTap))
.toList(),
);
}),
],
),
),
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")
],
),
),
ValueListenableBuilder(
valueListenable: searchRx,
builder: (context, value, child) {
final List<FunctionEnum> list = FunctionEnum.values
.where((element) => (searchRx.value.isNotEmpty
? element.name.contains(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.withOpacity(0.2)
: null,
onTap: e.onTap))
.toList(),
);
}),
const Spacer(),
IconButton(
onPressed: () {
Get.changeThemeMode(
isDark ? ThemeMode.light : ThemeMode.dark);
},
icon: Icon(isDark ? Icons.light_mode : Icons.dark_mode))
],
),
),
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")
]))
],
))
],
),
),
appBar: AppBar(
title: Text(title),
))
],
),
body: Obx(() => future.value == null
? const Center(child: CircularProgressIndicator())
: future.value!));
),
appBar: AppBar(
title: Text(title),
),
body: Obx(
() =>
body.value ??
const Center(
child: CircularProgressIndicator(),
),
),
);
}
}
5 changes: 5 additions & 0 deletions lib/global_variable.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import 'package:refreshed/refreshed.dart';

class GlobalVariable {
static RxString searchRx = RxString("");
}
50 changes: 29 additions & 21 deletions lib/uuid_tools/controller.dart
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
import 'package:flutter/material.dart';
import 'package:refreshed/refreshed.dart';
import 'package:tools/utils/uuid/uuid_analysis.dart';
// import 'package:flutter/material.dart';
// import 'package:refreshed/refreshed.dart';
// import 'package:tools/utils/uuid/uuid_analysis.dart';

class UuidToolsController extends GetxController {
final TextEditingController textEditingController = TextEditingController();
// class UuidToolsController extends GetxController {
// final TextEditingController textEditingController = TextEditingController();

final RxString helper = "".obs;
// final RxString helper = RxString("");

final Rx<Color> borderColor = Rx<Color>(Colors.grey);
// final Rx<Color> borderColor = Rx<Color>(Colors.grey);

void onEditingComplete() {
try {
final UuidAnalysis analysis = UuidAnalysis(textEditingController.text);
} catch (e) {
if (e is FormatException) {
borderColor.value = Colors.red;
// textEditingController.
helper.value = "UUID格式错误";
update();
}
print(e);
}
}
}
// final Rxn<UuidAnalysis> analysis = Rxn<UuidAnalysis>();

// void onEditingComplete() {
// if (textEditingController.text.isEmpty) {
// borderColor.value = Colors.red;
// helper.value = "UUID不能为空";
// return;
// }
// analysis.value = null;
// try {
// analysis.value = UuidAnalysis(textEditingController.text);
// } catch (e) {
// if (e is FormatException) {
// borderColor.value = Colors.red;
// // textEditingController.
// helper.value = "UUID格式错误";
// update();
// }
// print(e);
// }
// }
// }
Loading

0 comments on commit b40d6c2

Please sign in to comment.