feat: 静态页面开发完成
This commit is contained in:
@@ -1,204 +1,142 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_animate/flutter_animate.dart';
|
||||
import '../theme.dart';
|
||||
import '../l10n/app_localizations.dart';
|
||||
|
||||
class AppMarketPage extends StatefulWidget {
|
||||
class AppMarketPage extends StatelessWidget {
|
||||
const AppMarketPage({super.key});
|
||||
|
||||
@override
|
||||
State<AppMarketPage> createState() => _AppMarketPageState();
|
||||
}
|
||||
|
||||
class _AppMarketPageState extends State<AppMarketPage> {
|
||||
final List<Map<String, dynamic>> _apps = [
|
||||
{
|
||||
'name': '会员管理',
|
||||
'desc': '会员积分、等级、权益管理',
|
||||
'icon': Icons.card_membership,
|
||||
'color': const Color(0xFF1A56DB),
|
||||
'installed': true,
|
||||
},
|
||||
{
|
||||
'name': '财务对账',
|
||||
'desc': '收支明细、财务报表、对账单',
|
||||
'icon': Icons.account_balance_wallet,
|
||||
'color': const Color(0xFF10B981),
|
||||
'installed': true,
|
||||
},
|
||||
{
|
||||
'name': '库存管理',
|
||||
'desc': '商品库存、出入库记录',
|
||||
'icon': Icons.inventory_2,
|
||||
'color': const Color(0xFFF59E0B),
|
||||
'installed': false,
|
||||
},
|
||||
{
|
||||
'name': '智能排班',
|
||||
'desc': '员工排班、考勤统计',
|
||||
'icon': Icons.calendar_month,
|
||||
'color': const Color(0xFF8B5CF6),
|
||||
'installed': false,
|
||||
},
|
||||
{
|
||||
'name': '客户评价',
|
||||
'desc': '收集和分析客户反馈',
|
||||
'icon': Icons.reviews,
|
||||
'color': const Color(0xFFEC4899),
|
||||
'installed': false,
|
||||
},
|
||||
{
|
||||
'name': '营销工具',
|
||||
'desc': '优惠券、拼团、秒杀活动',
|
||||
'icon': Icons.campaign,
|
||||
'color': const Color(0xFFEF4444),
|
||||
'installed': true,
|
||||
},
|
||||
];
|
||||
|
||||
void _installApp(int index) {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
setState(() {
|
||||
_apps[index]['installed'] = true;
|
||||
});
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('${_apps[index]['name']} ${l10n.installSuccess}'),
|
||||
backgroundColor: AppColors.success,
|
||||
behavior: SnackBarBehavior.floating,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _openApp(int index) {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('${l10n.opening} ${_apps[index]['name']}...'),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
final plugins = <_Plugin>[
|
||||
_Plugin(
|
||||
name: '开关房',
|
||||
desc: '管理房态、入住与退房',
|
||||
icon: Icons.meeting_room_outlined,
|
||||
color: const Color(0xFF3B82F6),
|
||||
),
|
||||
_Plugin(
|
||||
name: '下载报表',
|
||||
desc: '导出经营数据与报表文件',
|
||||
icon: Icons.file_download_outlined,
|
||||
color: const Color(0xFFF59E0B),
|
||||
),
|
||||
_Plugin(
|
||||
name: '评价管理',
|
||||
desc: '查看与回复客户评价',
|
||||
icon: Icons.rate_review_outlined,
|
||||
color: const Color(0xFFEC4899),
|
||||
),
|
||||
];
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.background,
|
||||
appBar: AppBar(title: Text(l10n.appMarket)),
|
||||
appBar: AppBar(
|
||||
title: Text(l10n.appMarket),
|
||||
backgroundColor: AppColors.surface,
|
||||
elevation: 0,
|
||||
scrolledUnderElevation: 0,
|
||||
surfaceTintColor: Colors.transparent,
|
||||
),
|
||||
body: ListView.builder(
|
||||
padding: const EdgeInsets.all(16),
|
||||
itemCount: _apps.length,
|
||||
padding: const EdgeInsets.fromLTRB(16, 16, 16, 24),
|
||||
itemCount: plugins.length,
|
||||
itemBuilder: (context, index) {
|
||||
final app = _apps[index];
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
final p = plugins[index];
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 12),
|
||||
child: Material(
|
||||
color: AppColors.surface,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withValues(alpha: 0.03),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 52,
|
||||
height: 52,
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
onTap: () => _openPlugin(context, p.name),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: (app['color'] as Color).withValues(alpha: 0.1),
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withValues(alpha: 0.03),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Icon(app['icon'] as IconData,
|
||||
color: app['color'] as Color, size: 26),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
child: Row(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
app['name'],
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColors.textPrimary,
|
||||
),
|
||||
),
|
||||
if (app['installed'] == true) ...[
|
||||
const SizedBox(width: 8),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.success.withValues(alpha: 0.1),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
Container(
|
||||
width: 48,
|
||||
height: 48,
|
||||
decoration: BoxDecoration(
|
||||
color: p.color.withValues(alpha: 0.1),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Icon(p.icon, color: p.color, size: 24),
|
||||
),
|
||||
const SizedBox(width: 14),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
p.name,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColors.textPrimary,
|
||||
),
|
||||
child: Text(
|
||||
l10n.installed,
|
||||
style: const TextStyle(
|
||||
fontSize: 10,
|
||||
color: AppColors.success,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
p.desc,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: AppColors.textSecondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
app['desc'],
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: AppColors.textSecondary,
|
||||
),
|
||||
),
|
||||
Icon(
|
||||
Icons.chevron_right,
|
||||
color: AppColors.textTertiary,
|
||||
size: 20,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
if (app['installed'] == true)
|
||||
OutlinedButton(
|
||||
onPressed: () => _openApp(index),
|
||||
style: OutlinedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16, vertical: 8),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
child: Text(l10n.open,
|
||||
style: const TextStyle(fontSize: 12)),
|
||||
)
|
||||
else
|
||||
ElevatedButton(
|
||||
onPressed: () => _installApp(index),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColors.primary,
|
||||
foregroundColor: Colors.white,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16, vertical: 8),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
child: Text(l10n.install,
|
||||
style: const TextStyle(fontSize: 12)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
).animate().fadeIn(duration: 300.ms, delay: (index * 60).ms).slideY(begin: 0.1, end: 0, duration: 300.ms);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _openPlugin(BuildContext context, String name) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('$name 即将上线'),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
duration: const Duration(seconds: 2),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _Plugin {
|
||||
final String name;
|
||||
final String desc;
|
||||
final IconData icon;
|
||||
final Color color;
|
||||
|
||||
const _Plugin({
|
||||
required this.name,
|
||||
required this.desc,
|
||||
required this.icon,
|
||||
required this.color,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user