205 lines
7.0 KiB
Dart
205 lines
7.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../theme.dart';
|
|
import '../l10n/app_localizations.dart';
|
|
|
|
class AppMarketPage extends StatefulWidget {
|
|
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)!;
|
|
return Scaffold(
|
|
backgroundColor: AppColors.background,
|
|
appBar: AppBar(title: Text(l10n.appMarket)),
|
|
body: ListView.builder(
|
|
padding: const EdgeInsets.all(16),
|
|
itemCount: _apps.length,
|
|
itemBuilder: (context, index) {
|
|
final app = _apps[index];
|
|
return Container(
|
|
margin: const EdgeInsets.only(bottom: 12),
|
|
padding: const EdgeInsets.all(16),
|
|
decoration: BoxDecoration(
|
|
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,
|
|
decoration: BoxDecoration(
|
|
color: (app['color'] as Color).withValues(alpha: 0.1),
|
|
borderRadius: BorderRadius.circular(14),
|
|
),
|
|
child: Icon(app['icon'] as IconData,
|
|
color: app['color'] as Color, size: 26),
|
|
),
|
|
const SizedBox(width: 16),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
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),
|
|
),
|
|
child: Text(
|
|
l10n.installed,
|
|
style: const TextStyle(
|
|
fontSize: 10,
|
|
color: AppColors.success,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
],
|
|
),
|
|
const SizedBox(height: 6),
|
|
Text(
|
|
app['desc'],
|
|
style: const TextStyle(
|
|
fontSize: 13,
|
|
color: AppColors.textSecondary,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
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)),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|