Files
sweet_chat_app/lib/main.dart
2026-06-17 13:24:37 +08:00

90 lines
2.5 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'package:flutter/material.dart';
import 'package:liquid_glass_widgets/liquid_glass_widgets.dart';
import 'package:sweet_chat_app/pages/contacts_page.dart';
import 'package:sweet_chat_app/pages/explore_page.dart';
import 'package:sweet_chat_app/pages/messages_page.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// 预编译 shader防止首帧白闪
await LiquidGlassWidgets.initialize();
// wrap() 安装无障碍桥接、全局主题、自适应质量
runApp(LiquidGlassWidgets.wrap(child: const MyApp()));
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
scaffoldBackgroundColor: const Color(0xFF120D25),
brightness: Brightness.light,
useMaterial3: true,
colorScheme: ColorScheme.light(
primary: Color(0xFF1C1C1E),
secondary: Color(0xFF007AFF),
surface: Colors.white,
),
),
home: const HomePage(),
);
}
}
class HomePage extends StatefulWidget {
const HomePage({super.key});
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
int _index = 0;
final _pages = const [
MessagePage(),
ContactsPage(),
ExplorePage(),
Center(child: Text('⚙ 我的', style: TextStyle(fontSize: 26))),
];
@override
Widget build(BuildContext context) {
return GlassScaffold(
statusBarStyle: GlassStatusBarStyle.auto,
bottomBar: GlassBottomBar(
selectedIndex: _index,
onTabSelected: (i) => setState(() => _index = i),
selectedIconColor: Colors.purple.shade200,
unselectedIconColor: Colors.white,
tabs: const [
GlassBottomBarTab(
icon: Icon(Icons.chat_bubble_outline),
activeIcon: Icon(Icons.chat_bubble),
label: '消息',
),
GlassBottomBarTab(
icon: Icon(Icons.contacts_outlined),
activeIcon: Icon(Icons.contacts),
label: '通讯录',
),
GlassBottomBarTab(
icon: Icon(Icons.explore_outlined),
activeIcon: Icon(Icons.explore),
label: '发现',
),
GlassBottomBarTab(
icon: Icon(Icons.person_outline),
activeIcon: Icon(Icons.person),
label: '我的',
),
],
),
body: _pages[_index],
);
}
}