主页添加底栏
3
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"cmake.ignoreCMakeListsMissing": true
|
||||
}
|
||||
31
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次提交
|
||||
BIN
lib/assets/add.png
Normal file
|
After Width: | Height: | Size: 191 B |
BIN
lib/assets/add_circle.png
Normal file
|
After Width: | Height: | Size: 607 B |
BIN
lib/assets/arrow_back.png
Normal file
|
After Width: | Height: | Size: 302 B |
BIN
lib/assets/arrow_back_ios.png
Normal file
|
After Width: | Height: | Size: 276 B |
BIN
lib/assets/arrow_forward.png
Normal file
|
After Width: | Height: | Size: 298 B |
BIN
lib/assets/block.png
Normal file
|
After Width: | Height: | Size: 598 B |
BIN
lib/assets/cancel.png
Normal file
|
After Width: | Height: | Size: 663 B |
BIN
lib/assets/chevron_right.png
Normal file
|
After Width: | Height: | Size: 226 B |
BIN
lib/assets/close.png
Normal file
|
After Width: | Height: | Size: 302 B |
BIN
lib/assets/delete.png
Normal file
|
After Width: | Height: | Size: 225 B |
BIN
lib/assets/group.png
Normal file
|
After Width: | Height: | Size: 515 B |
BIN
lib/assets/groups.png
Normal file
|
After Width: | Height: | Size: 415 B |
BIN
lib/assets/home.png
Normal file
|
After Width: | Height: | Size: 327 B |
BIN
lib/assets/menu.png
Normal file
|
After Width: | Height: | Size: 185 B |
BIN
lib/assets/person.png
Normal file
|
After Width: | Height: | Size: 423 B |
BIN
lib/assets/search.png
Normal file
|
After Width: | Height: | Size: 451 B |
BIN
lib/assets/settings.png
Normal file
|
After Width: | Height: | Size: 701 B |
BIN
lib/assets/star.png
Normal file
|
After Width: | Height: | Size: 566 B |
BIN
lib/assets/thumb_up.png
Normal file
|
After Width: | Height: | Size: 395 B |
17
lib/pages/home/index.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
import "package:flutter/material.dart";
|
||||
|
||||
class HomeView extends StatefulWidget {
|
||||
const HomeView({super.key});
|
||||
|
||||
@override
|
||||
State<HomeView> createState() => _HomeViewState();
|
||||
}
|
||||
|
||||
class _HomeViewState extends State<HomeView> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Center(
|
||||
child: Text("Home View"),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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<MainPage> {
|
||||
// 定义数据 根据数据进行渲染导航键
|
||||
final List<Map<String, dynamic>> _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<BottomNavigationBarItem> _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<Widget> 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;
|
||||
});
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
17
lib/pages/myfriends/index.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MyFriendsView extends StatefulWidget {
|
||||
const MyFriendsView({super.key});
|
||||
|
||||
@override
|
||||
State<MyFriendsView> createState() => _MyFriendsViewState();
|
||||
}
|
||||
|
||||
class _MyFriendsViewState extends State<MyFriendsView> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Center(
|
||||
child: Text("MyFriends View"),
|
||||
);
|
||||
}
|
||||
}
|
||||
17
lib/pages/profile/index.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ProfileView extends StatefulWidget {
|
||||
const ProfileView({super.key});
|
||||
|
||||
@override
|
||||
State<ProfileView> createState() => _ProfileViewState();
|
||||
}
|
||||
|
||||
class _ProfileViewState extends State<ProfileView> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Center(
|
||||
child: Text("Profile View"),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||