dual check v0.1
This commit is contained in:
1 parent
78bad1fa3d
commit
c137299016
36 files changed
+3727
-81
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import 'package:client/const/font.dart';
|
||||
import 'package:client/modules/dual_check/dual_check.dart';
|
||||
import 'package:client/modules/home/tool_card.dart';
|
||||
import 'package:client/modules/to_qrcode/to_qrcode.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -11,7 +12,30 @@ class Home extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _HomeState extends State<Home> {
|
||||
final toolsList = [ToQrcode()];
|
||||
// 所有工具注册 —— 新增工具只需在这里加一项
|
||||
// 数据驱动:页面 widget + 元信息(图标/名称/描述)分开
|
||||
final List<_ToolEntry> _tools = [
|
||||
// _ToolEntry(
|
||||
// page: const ToQrcode(),
|
||||
// meta: const ToolMeta(
|
||||
// name: '二维码生成器',
|
||||
// description: '上传文字、图片即可立即生成二维码',
|
||||
// icon: Icons.qr_code,
|
||||
// iconColor: Colors.purple,
|
||||
// bgColor: Color(0xFFF3E5F5),
|
||||
// ),
|
||||
// ),
|
||||
_ToolEntry(
|
||||
page: const DualCheck(),
|
||||
meta: const ToolMeta(
|
||||
name: 'DualCheck 双验',
|
||||
description: '两人各输入一段文字,实时比对是否一致',
|
||||
icon: Icons.verified_user,
|
||||
iconColor: Colors.teal,
|
||||
bgColor: Color(0xFFE0F2F1),
|
||||
),
|
||||
),
|
||||
];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -27,10 +51,10 @@ class _HomeState extends State<Home> {
|
||||
),
|
||||
),
|
||||
centerTitle: true,
|
||||
actions: [
|
||||
CircleAvatar(child: Text("登陆", style: TextStyle(fontSize: 12))),
|
||||
SizedBox(width: 16),
|
||||
],
|
||||
// actions: [
|
||||
// CircleAvatar(child: Text("登陆", style: TextStyle(fontSize: 12))),
|
||||
// SizedBox(width: 16),
|
||||
// ],
|
||||
),
|
||||
body: GridView.builder(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||
@@ -40,23 +64,29 @@ class _HomeState extends State<Home> {
|
||||
mainAxisSpacing: 8,
|
||||
crossAxisSpacing: 8,
|
||||
),
|
||||
itemCount: toolsList.length,
|
||||
itemCount: _tools.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
enterCard(index);
|
||||
},
|
||||
child: ToolCard(),
|
||||
onTap: () => _enterCard(index),
|
||||
child: ToolCard(meta: _tools[index].meta),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void enterCard(int index) {
|
||||
void _enterCard(int index) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: ((context) => toolsList[index])),
|
||||
MaterialPageRoute(builder: (_) => _tools[index].page),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 内部工具注册条目
|
||||
class _ToolEntry {
|
||||
final Widget page;
|
||||
final ToolMeta meta;
|
||||
|
||||
_ToolEntry({required this.page, required this.meta});
|
||||
}
|
||||
@@ -2,60 +2,70 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import '../../const/font.dart';
|
||||
|
||||
class ToolCard extends StatefulWidget {
|
||||
const ToolCard({super.key});
|
||||
/// 工具元信息 —— 数据驱动首页卡片渲染
|
||||
class ToolMeta {
|
||||
final String name;
|
||||
final String description;
|
||||
final IconData icon;
|
||||
final Color iconColor;
|
||||
final Color bgColor;
|
||||
|
||||
@override
|
||||
State<ToolCard> createState() => _ToolCardState();
|
||||
const ToolMeta({
|
||||
required this.name,
|
||||
required this.description,
|
||||
required this.icon,
|
||||
this.iconColor = Colors.blue,
|
||||
this.bgColor = const Color(0xFFF5F5F5),
|
||||
});
|
||||
}
|
||||
|
||||
class _ToolCardState extends State<ToolCard> {
|
||||
class ToolCard extends StatelessWidget {
|
||||
const ToolCard({super.key, required this.meta});
|
||||
|
||||
final ToolMeta meta;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 8),
|
||||
clipBehavior: Clip.hardEdge,
|
||||
decoration: BoxDecoration(),
|
||||
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Image.asset(
|
||||
"assets/qr_code_logo.png",
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
fit: BoxFit.cover,
|
||||
// 图标占位区
|
||||
Container(
|
||||
width: 80,
|
||||
height: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: meta.bgColor,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Icon(meta.icon, color: meta.iconColor, size: 36),
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: ClipRect(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"二维码生成器",
|
||||
style: TextStyle(
|
||||
fontSize: Font.FONT_SIZE_SUBTITLE,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
meta.name,
|
||||
style: TextStyle(
|
||||
fontSize: Font.FONT_SIZE_SUBTITLE,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
Divider(),
|
||||
SizedBox(height: 8),
|
||||
Container(
|
||||
child: Text(
|
||||
"上传文字,图片即可立即生成二维码",
|
||||
maxLines: 2,
|
||||
style: TextStyle(
|
||||
fontSize: Font.FONT_SIZE_CONTENT,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 6),
|
||||
Divider(height: 1),
|
||||
SizedBox(height: 6),
|
||||
Text(
|
||||
meta.description,
|
||||
maxLines: 2,
|
||||
style: TextStyle(
|
||||
fontSize: Font.FONT_SIZE_CONTENT,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
color: Colors.grey.shade600,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in new issue
Block a user