generated from dellevin/template
优化调整“我的”界面
This commit is contained in:
@@ -1,103 +1,30 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../providers/app_provider.dart';
|
||||
import 'status_bar_shell.dart';
|
||||
|
||||
/// 游戏状态选择栏 - 平滑过渡动画
|
||||
/// 游戏状态选择栏
|
||||
class GameStatusBar extends StatelessWidget {
|
||||
const GameStatusBar({super.key});
|
||||
|
||||
static const _tabs = [
|
||||
StatusBarTab(label: '已通关', icon: Icons.emoji_events_outlined),
|
||||
StatusBarTab(label: '在玩', icon: Icons.sports_esports_outlined),
|
||||
StatusBarTab(label: '想玩', icon: Icons.bookmark_outlined),
|
||||
StatusBarTab(label: '弃游', icon: Icons.cancel_outlined),
|
||||
];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
return Consumer<AppProvider>(
|
||||
builder: (context, provider, child) {
|
||||
final currentIndex = provider.gameStatusIndex;
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: colors.surface,
|
||||
),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(4),
|
||||
decoration: BoxDecoration(
|
||||
color: colors.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final tabWidth = constraints.maxWidth / 4;
|
||||
return SizedBox(
|
||||
height: 40,
|
||||
child: Stack(
|
||||
children: [
|
||||
AnimatedPositioned(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
curve: Curves.easeInOut,
|
||||
left: currentIndex * tabWidth,
|
||||
top: 0, bottom: 0, width: tabWidth,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(3),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: colors.primary,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: [
|
||||
BoxShadow(color: Colors.black.withValues(alpha: 0.1), blurRadius: 8, offset: const Offset(0, 2)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
_buildTab(colors, '已通关', Icons.emoji_events_outlined, currentIndex == 0,
|
||||
() => provider.setGameStatusIndex(0)),
|
||||
_buildTab(colors, '在玩', Icons.sports_esports_outlined, currentIndex == 1,
|
||||
() => provider.setGameStatusIndex(1)),
|
||||
_buildTab(colors, '想玩', Icons.bookmark_outlined, currentIndex == 2,
|
||||
() => provider.setGameStatusIndex(2)),
|
||||
_buildTab(colors, '弃游', Icons.cancel_outlined, currentIndex == 3,
|
||||
() => provider.setGameStatusIndex(3)),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
builder: (context, provider, _) {
|
||||
return StatusBarShell(
|
||||
tabs: _tabs,
|
||||
currentIndex: provider.gameStatusIndex,
|
||||
onChanged: provider.setGameStatusIndex,
|
||||
style: provider.gameStatusBarStyle,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTab(ColorScheme colors, String label, IconData icon, bool isSelected, VoidCallback onTap) {
|
||||
return Expanded(
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: onTap,
|
||||
child: AnimatedOpacity(
|
||||
opacity: isSelected ? 1.0 : 0.5,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
curve: Curves.easeInOut,
|
||||
child: SizedBox.expand(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(icon, size: 16, color: isSelected ? colors.onPrimary : colors.onSurface),
|
||||
const SizedBox(width: 6),
|
||||
Text(label,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: isSelected ? FontWeight.w600 : FontWeight.w500,
|
||||
color: isSelected ? colors.onPrimary : colors.onSurface,
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user