88 lines
2.7 KiB
Dart
88 lines
2.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:maibu_satabot_v2/features/main_container/presentation/cubit/tab_config_cubit.dart';
|
|
import 'package:cc_ui_kit/cc_ui_kit.dart';
|
|
|
|
class TabSettingsPage extends StatelessWidget {
|
|
const TabSettingsPage({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text('Tab 配置'),
|
|
backgroundColor: Colors.white,
|
|
foregroundColor: Colors.black,
|
|
elevation: 0,
|
|
),
|
|
body: BlocBuilder<TabConfigCubit, TabConfigState>(
|
|
builder: (context, state) {
|
|
if (state is! TabConfigLoaded) {
|
|
return const Center(child: CircularProgressIndicator());
|
|
}
|
|
|
|
final tabs = state.config.items;
|
|
|
|
return ListView.builder(
|
|
padding: const EdgeInsets.all(16),
|
|
itemCount: tabs.length,
|
|
itemBuilder: (context, index) {
|
|
final tab = tabs[index];
|
|
|
|
return Card(
|
|
margin: const EdgeInsets.only(bottom: 8),
|
|
child: ListTile(
|
|
leading: Icon(_getIconData(tab.icon)),
|
|
title: Text(tab.name),
|
|
subtitle: Text(tab.nameEn),
|
|
trailing: Switch(
|
|
value: tab.isEnabled,
|
|
onChanged: (value) {
|
|
context.read<TabConfigCubit>().toggleTab(tab.id);
|
|
},
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
},
|
|
),
|
|
bottomNavigationBar: Padding(
|
|
padding: const EdgeInsets.all(16),
|
|
child: CCPrimaryButton(
|
|
text: '重置为默认',
|
|
onPressed: () {
|
|
context.read<TabConfigCubit>().resetToDefault();
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
const SnackBar(content: Text('已重置为默认配置')),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
IconData _getIconData(String iconName) {
|
|
switch (iconName) {
|
|
case 'home_rounded':
|
|
return Icons.home_rounded;
|
|
case 'grid_view_rounded':
|
|
return Icons.grid_view_rounded;
|
|
case 'devices_rounded':
|
|
return Icons.devices_rounded;
|
|
case 'auto_awesome_rounded':
|
|
return Icons.auto_awesome_rounded;
|
|
case 'warning_amber_rounded':
|
|
return Icons.warning_amber_rounded;
|
|
case 'assignment_rounded':
|
|
return Icons.assignment_rounded;
|
|
case 'post_add_rounded':
|
|
return Icons.post_add_rounded;
|
|
case 'person_rounded':
|
|
return Icons.person_rounded;
|
|
default:
|
|
return Icons.home_rounded;
|
|
}
|
|
}
|
|
}
|