diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..9ddf6b2 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "cmake.ignoreCMakeListsMissing": true +} \ No newline at end of file diff --git a/README.md b/README.md index 0306ea1..08df926 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,2 @@ -<<<<<<< HEAD -# mydearest - -======= -<<<<<<< HEAD -# Flutter_First_Project - -======= -# mydearest - ->>>>>>> f48a885 (第2次提交) -A new Flutter project. - -## Getting Started - -This project is a starting point for a Flutter application. - -A few resources to get you started if this is your first Flutter project: - -- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) -- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) - -For help getting started with Flutter development, view the -[online documentation](https://docs.flutter.dev/), which offers tutorials, -samples, guidance on mobile development, and a full API reference. -<<<<<<< HEAD -======= ->>>>>>> 4bb705a (第一次提交) ->>>>>>> f48a885 (第2次提交) +# 第一次Flutter项目开发 +这是第4次提交 \ No newline at end of file diff --git a/lib/assets/add.png b/lib/assets/add.png new file mode 100644 index 0000000..cde0ac7 Binary files /dev/null and b/lib/assets/add.png differ diff --git a/lib/assets/add_circle.png b/lib/assets/add_circle.png new file mode 100644 index 0000000..5543638 Binary files /dev/null and b/lib/assets/add_circle.png differ diff --git a/lib/assets/arrow_back.png b/lib/assets/arrow_back.png new file mode 100644 index 0000000..c6a7466 Binary files /dev/null and b/lib/assets/arrow_back.png differ diff --git a/lib/assets/arrow_back_ios.png b/lib/assets/arrow_back_ios.png new file mode 100644 index 0000000..726b8a0 Binary files /dev/null and b/lib/assets/arrow_back_ios.png differ diff --git a/lib/assets/arrow_forward.png b/lib/assets/arrow_forward.png new file mode 100644 index 0000000..ae7b82e Binary files /dev/null and b/lib/assets/arrow_forward.png differ diff --git a/lib/assets/block.png b/lib/assets/block.png new file mode 100644 index 0000000..817859e Binary files /dev/null and b/lib/assets/block.png differ diff --git a/lib/assets/cancel.png b/lib/assets/cancel.png new file mode 100644 index 0000000..10bc82c Binary files /dev/null and b/lib/assets/cancel.png differ diff --git a/lib/assets/chevron_right.png b/lib/assets/chevron_right.png new file mode 100644 index 0000000..7cf4760 Binary files /dev/null and b/lib/assets/chevron_right.png differ diff --git a/lib/assets/close.png b/lib/assets/close.png new file mode 100644 index 0000000..8697728 Binary files /dev/null and b/lib/assets/close.png differ diff --git a/lib/assets/delete.png b/lib/assets/delete.png new file mode 100644 index 0000000..66083c8 Binary files /dev/null and b/lib/assets/delete.png differ diff --git a/lib/assets/group.png b/lib/assets/group.png new file mode 100644 index 0000000..afdfe43 Binary files /dev/null and b/lib/assets/group.png differ diff --git a/lib/assets/groups.png b/lib/assets/groups.png new file mode 100644 index 0000000..e747a24 Binary files /dev/null and b/lib/assets/groups.png differ diff --git a/lib/assets/home.png b/lib/assets/home.png new file mode 100644 index 0000000..b42b244 Binary files /dev/null and b/lib/assets/home.png differ diff --git a/lib/assets/menu.png b/lib/assets/menu.png new file mode 100644 index 0000000..6b57acf Binary files /dev/null and b/lib/assets/menu.png differ diff --git a/lib/assets/person.png b/lib/assets/person.png new file mode 100644 index 0000000..3b8005e Binary files /dev/null and b/lib/assets/person.png differ diff --git a/lib/assets/search.png b/lib/assets/search.png new file mode 100644 index 0000000..dac61e4 Binary files /dev/null and b/lib/assets/search.png differ diff --git a/lib/assets/settings.png b/lib/assets/settings.png new file mode 100644 index 0000000..62b7f63 Binary files /dev/null and b/lib/assets/settings.png differ diff --git a/lib/assets/star.png b/lib/assets/star.png new file mode 100644 index 0000000..c95b16f Binary files /dev/null and b/lib/assets/star.png differ diff --git a/lib/assets/thumb_up.png b/lib/assets/thumb_up.png new file mode 100644 index 0000000..4c413ae Binary files /dev/null and b/lib/assets/thumb_up.png differ diff --git a/lib/pages/home/index.dart b/lib/pages/home/index.dart new file mode 100644 index 0000000..440b194 --- /dev/null +++ b/lib/pages/home/index.dart @@ -0,0 +1,17 @@ +import "package:flutter/material.dart"; + +class HomeView extends StatefulWidget { + const HomeView({super.key}); + + @override + State createState() => _HomeViewState(); +} + +class _HomeViewState extends State { + @override + Widget build(BuildContext context) { + return Center( + child: Text("Home View"), + ); + } +} \ No newline at end of file diff --git a/lib/pages/main/index.dart b/lib/pages/main/index.dart index 73f75ef..5dbb8fa 100644 --- a/lib/pages/main/index.dart +++ b/lib/pages/main/index.dart @@ -1,4 +1,7 @@ import "package:flutter/material.dart"; +import '../home/index.dart'; +import '../myfriends/index.dart'; +import '../profile/index.dart'; class MainPage extends StatefulWidget { const MainPage({super.key}); @@ -8,14 +11,64 @@ class MainPage extends StatefulWidget { } class _MainPageState extends State { + // 定义数据 根据数据进行渲染导航键 + final List> _navList = [ + { + "icon": Icons.home_outlined, + "activeIcon": Icons.home, + "label": "Home", + }, + { + "icon": Icons.face_outlined, + "activeIcon": Icons.face, + "label": "MyFriends", + }, + { + "icon": Icons.person_outlined, + "activeIcon": Icons.person, + "label": "Profile", + }, + ]; + + // 根据数据渲染导航键 + List _buildNavItems() { + return List.generate(_navList.length, (int index) { + final navItem = _navList[index]; + return BottomNavigationBarItem( + icon: Icon(navItem["icon"]), + activeIcon: Icon(navItem["activeIcon"]), + label: navItem["label"], + ); + }); + } + + int _currentIndex = 0; // 当前选中的导航键索引 + + List get _pages { + return [ + const HomeView(), + const MyFriendsView(), + const ProfileView(), + ]; // 对应导航键的页面列表 + } + + @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - title: Text("Main Page"), - ), - body: Center( - child: Text("This is the main page."), + // 避开刘海屏等特殊屏幕区域 + body: SafeArea(child: IndexedStack( + index: _currentIndex, + children: _pages, + )), // 堆叠索引组件,根据当前索引显示对应的页面 + bottomNavigationBar: BottomNavigationBar( + currentIndex: _currentIndex, + items: _buildNavItems(), + onTap: (int index) { // 点击导航键时更新当前索引 + setState(() { + _currentIndex = index; + }); + }, ), ); } diff --git a/lib/pages/myfriends/index.dart b/lib/pages/myfriends/index.dart new file mode 100644 index 0000000..e7a41a4 --- /dev/null +++ b/lib/pages/myfriends/index.dart @@ -0,0 +1,17 @@ +import 'package:flutter/material.dart'; + +class MyFriendsView extends StatefulWidget { + const MyFriendsView({super.key}); + + @override + State createState() => _MyFriendsViewState(); +} + +class _MyFriendsViewState extends State { + @override + Widget build(BuildContext context) { + return Center( + child: Text("MyFriends View"), + ); + } +} \ No newline at end of file diff --git a/lib/pages/profile/index.dart b/lib/pages/profile/index.dart new file mode 100644 index 0000000..9ab5a98 --- /dev/null +++ b/lib/pages/profile/index.dart @@ -0,0 +1,17 @@ +import 'package:flutter/material.dart'; + +class ProfileView extends StatefulWidget { + const ProfileView({super.key}); + + @override + State createState() => _ProfileViewState(); +} + +class _ProfileViewState extends State { + @override + Widget build(BuildContext context) { + return Center( + child: Text("Profile View"), + ); + } +} \ No newline at end of file diff --git a/pubspec.yaml b/pubspec.yaml index af3d70e..121c081 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -61,6 +61,9 @@ flutter: # assets: # - images/a_dot_burr.jpeg # - images/a_dot_ham.jpeg + assets: + - lib/assets/images/ + - lib/assets/icons/ # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.dev/to/resolution-aware-images diff --git a/test/widget_test.dart b/test/widget_test.dart index 199b2d4..7f364e4 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -8,12 +8,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:mydearest/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. - await tester.pumpWidget(const MyApp()); + // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget);