v2版本的首页界面开发
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
import 'dart:ui';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:google_nav_bar/google_nav_bar.dart';
|
||||
import 'package:maibu_satabot_v2/features/main_container/presentation/cubit/tab_config_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/main_container/domain/tab_config.dart';
|
||||
import 'package:maibu_satabot_v2/features/home/presentation/pages/home_page.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/home/presentation/pages/home_v2_page.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/home/presentation/bloc/home_v2_bloc.dart';
|
||||
import 'package:maibu_satabot_v2/features/ai/presentation/pages/ai_page.dart';
|
||||
import 'package:maibu_satabot_v2/features/waring_center/presentation/pages/warning_center_page.dart';
|
||||
import 'package:maibu_satabot_v2/features/my/presentation/pages/my_page.dart';
|
||||
import 'package:maibu_satabot_v2/core/di/injection.dart';
|
||||
|
||||
class MainWrapper extends StatefulWidget {
|
||||
const MainWrapper({super.key});
|
||||
@@ -28,6 +29,8 @@ class _MainWrapperState extends State<MainWrapper> {
|
||||
|
||||
IconData _getIconData(String iconName) {
|
||||
switch (iconName) {
|
||||
case 'home_rounded':
|
||||
return Icons.home_rounded;
|
||||
case 'grid_view_rounded':
|
||||
return Icons.grid_view_rounded;
|
||||
case 'auto_awesome_rounded':
|
||||
@@ -43,6 +46,11 @@ class _MainWrapperState extends State<MainWrapper> {
|
||||
|
||||
Widget _buildCurrentPage(TabConfigItem tab) {
|
||||
switch (tab.id) {
|
||||
case 'home_v2':
|
||||
return BlocProvider(
|
||||
create: (context) => sl<HomeV2Bloc>(),
|
||||
child: const HomeV2Page(),
|
||||
);
|
||||
case 'home':
|
||||
return const HomePage();
|
||||
case 'ai':
|
||||
@@ -92,67 +100,57 @@ class _MainWrapperState extends State<MainWrapper> {
|
||||
children: enabledItems.map((tab) => _buildCurrentPage(tab)).toList(),
|
||||
),
|
||||
bottomNavigationBar: Container(
|
||||
margin: const EdgeInsets.fromLTRB(20, 0, 20, 10),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(32),
|
||||
color: Colors.white,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.12),
|
||||
blurRadius: 30,
|
||||
offset: const Offset(0, 10),
|
||||
color: Colors.black.withOpacity(0.08),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, -2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(32),
|
||||
child: BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 16, sigmaY: 16),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withOpacity(0.4),
|
||||
borderRadius: BorderRadius.circular(32),
|
||||
border: Border.all(
|
||||
color: Colors.black.withOpacity(0.08),
|
||||
width: 0.5,
|
||||
),
|
||||
),
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 10,
|
||||
vertical: 8,
|
||||
),
|
||||
child: GNav(
|
||||
rippleColor: Colors.transparent,
|
||||
hoverColor: Colors.transparent,
|
||||
gap: 10,
|
||||
activeColor: Colors.white,
|
||||
tabBackgroundColor: Colors.black,
|
||||
color: Colors.black87,
|
||||
iconSize: 24,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 18,
|
||||
vertical: 10,
|
||||
),
|
||||
duration: const Duration(milliseconds: 300),
|
||||
selectedIndex: _currentIndex,
|
||||
onTabChange: (index) {
|
||||
setState(() {
|
||||
_currentIndex = index;
|
||||
});
|
||||
_pageController.jumpToPage(index);
|
||||
},
|
||||
tabs: enabledItems.map((item) {
|
||||
return GButton(
|
||||
icon: _getIconData(item.icon),
|
||||
text: item.name,
|
||||
);
|
||||
}).toList(),
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: enabledItems.asMap().entries.map((entry) {
|
||||
final index = entry.key;
|
||||
final item = entry.value;
|
||||
final isSelected = _currentIndex == index;
|
||||
|
||||
return Expanded(
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_currentIndex = index;
|
||||
});
|
||||
_pageController.jumpToPage(index);
|
||||
},
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const SizedBox(height: 8),
|
||||
Icon(
|
||||
_getIconData(item.icon),
|
||||
size: 24,
|
||||
color: isSelected ? Colors.blue : Colors.grey,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
item.name,
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: isSelected ? Colors.blue : Colors.grey,
|
||||
fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user