feat:初始化工程
This commit is contained in:
94
lib/main.dart
Normal file
94
lib/main.dart
Normal file
@@ -0,0 +1,94 @@
|
||||
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/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(
|
||||
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 [
|
||||
Center(child: MessagePage()),
|
||||
Center(child: ContactsPage()),
|
||||
Center(child: Text('⚙ Settings', style: TextStyle(fontSize: 26, color: Colors.white))),
|
||||
Center(child: Text('⚙ 我的', style: TextStyle(fontSize: 26, color: Colors.white))),
|
||||
];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GlassScaffold(
|
||||
background: Container(
|
||||
decoration: const BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [Color(0xFFFFFFFF), Color(0xFFF5F5F7)],
|
||||
),
|
||||
),
|
||||
),
|
||||
statusBarStyle: GlassStatusBarStyle.auto,
|
||||
bottomBar: GlassBottomBar(
|
||||
selectedIndex: _index,
|
||||
onTabSelected: (i) => setState(() => _index = i),
|
||||
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],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user