generated from dellevin/template
129 lines
4.5 KiB
Dart
129 lines
4.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import '../providers/app_provider.dart';
|
|
|
|
/// 阅读状态选择栏 - 水滴滑动动画
|
|
class BookStatusBar extends StatelessWidget {
|
|
const BookStatusBar({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Consumer<AppProvider>(
|
|
builder: (context, provider, child) {
|
|
return Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
|
decoration: const BoxDecoration(
|
|
color: Colors.white,
|
|
border: Border(
|
|
bottom: BorderSide(color: Color(0xFFE5E5E5), width: 0.5),
|
|
),
|
|
),
|
|
child: Container(
|
|
padding: const EdgeInsets.all(4),
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFFF5F5F5),
|
|
borderRadius: BorderRadius.circular(24),
|
|
),
|
|
child: LayoutBuilder(
|
|
builder: (context, constraints) {
|
|
final tabWidth = constraints.maxWidth / 3;
|
|
return SizedBox(
|
|
height: 40,
|
|
child: Stack(
|
|
children: [
|
|
AnimatedPositioned(
|
|
duration: const Duration(milliseconds: 800),
|
|
curve: Curves.elasticOut,
|
|
left: provider.bookStatusIndex * tabWidth,
|
|
top: 0,
|
|
bottom: 0,
|
|
width: tabWidth,
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(3),
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFF1A1A1A),
|
|
borderRadius: BorderRadius.circular(20),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.black.withValues(alpha: 0.1),
|
|
blurRadius: 8,
|
|
offset: const Offset(0, 2),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
Row(
|
|
children: [
|
|
_buildTab(
|
|
label: '已读',
|
|
icon: Icons.check_circle_outline,
|
|
isSelected: provider.bookStatusIndex == 0,
|
|
onTap: () => provider.setBookStatusIndex(0),
|
|
),
|
|
_buildTab(
|
|
label: '在读',
|
|
icon: Icons.menu_book_outlined,
|
|
isSelected: provider.bookStatusIndex == 1,
|
|
onTap: () => provider.setBookStatusIndex(1),
|
|
),
|
|
_buildTab(
|
|
label: '想读',
|
|
icon: Icons.bookmark_outlined,
|
|
isSelected: provider.bookStatusIndex == 2,
|
|
onTap: () => provider.setBookStatusIndex(2),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
Widget _buildTab({
|
|
required String label,
|
|
required IconData icon,
|
|
required bool isSelected,
|
|
required VoidCallback onTap,
|
|
}) {
|
|
return Expanded(
|
|
child: GestureDetector(
|
|
behavior: HitTestBehavior.opaque,
|
|
onTap: onTap,
|
|
child: Container(
|
|
height: double.infinity,
|
|
alignment: Alignment.center,
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Icon(
|
|
icon,
|
|
size: 16,
|
|
color: isSelected ? Colors.white : const Color(0xFF666666),
|
|
),
|
|
const SizedBox(width: 6),
|
|
Text(
|
|
label,
|
|
style: TextStyle(
|
|
fontSize: 13,
|
|
fontWeight: isSelected ? FontWeight.w600 : FontWeight.w500,
|
|
color: isSelected ? Colors.white : const Color(0xFF666666),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|