2023-02-06 23:45:56 +08:00
|
|
|
import 'package:flutter/material.dart';
|
2023-02-07 17:28:01 +08:00
|
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
import 'package:momo/material/gallery.dart';
|
2023-02-06 23:45:56 +08:00
|
|
|
|
|
|
|
class HomePage extends StatefulWidget {
|
|
|
|
const HomePage({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<HomePage> createState() => _HomePageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _HomePageState extends State<HomePage> {
|
|
|
|
int selectedIndex = 0;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(
|
2023-02-07 17:28:01 +08:00
|
|
|
title: const Text(
|
|
|
|
"App Header",
|
|
|
|
style: TextStyle(fontWeight: FontWeight.bold),
|
|
|
|
),
|
|
|
|
elevation: 10,
|
2023-02-06 23:45:56 +08:00
|
|
|
),
|
|
|
|
body: Row(
|
|
|
|
children: [
|
|
|
|
MediaQuery.of(context).size.width > 640
|
|
|
|
? NavigationRail(
|
2023-02-07 17:28:01 +08:00
|
|
|
elevation: 10,
|
|
|
|
backgroundColor: const Color(0xffebf6f5),
|
2023-02-06 23:45:56 +08:00
|
|
|
leading: MediaQuery.of(context).size.width >= 1008
|
|
|
|
? const Text(
|
2023-02-07 17:28:01 +08:00
|
|
|
"Side Header",
|
2023-02-06 23:45:56 +08:00
|
|
|
style: TextStyle(
|
|
|
|
fontWeight: FontWeight.bold, fontSize: 36),
|
|
|
|
)
|
|
|
|
: null,
|
|
|
|
onDestinationSelected: (idx) {
|
|
|
|
setState(() {
|
|
|
|
selectedIndex = idx;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
destinations: const [
|
|
|
|
NavigationRailDestination(
|
|
|
|
icon: Icon(Icons.photo_album), label: Text("相册")),
|
|
|
|
NavigationRailDestination(
|
|
|
|
icon: Icon(Icons.person), label: Text("用户"))
|
|
|
|
],
|
|
|
|
extended: MediaQuery.of(context).size.width >= 1008,
|
|
|
|
selectedIndex: selectedIndex)
|
|
|
|
: const SizedBox(
|
|
|
|
width: 0,
|
2023-02-07 17:28:01 +08:00
|
|
|
),
|
|
|
|
Expanded(child: pageList[selectedIndex])
|
2023-02-06 23:45:56 +08:00
|
|
|
],
|
|
|
|
),
|
|
|
|
bottomNavigationBar: MediaQuery.of(context).size.width <= 640
|
|
|
|
? BottomNavigationBar(
|
2023-02-07 17:28:01 +08:00
|
|
|
elevation: 10,
|
2023-02-06 23:45:56 +08:00
|
|
|
currentIndex: selectedIndex,
|
|
|
|
onTap: (idx) {
|
|
|
|
setState(() {
|
|
|
|
selectedIndex = idx;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
items: const [
|
|
|
|
BottomNavigationBarItem(
|
|
|
|
icon: Icon(Icons.photo_album), label: "相册"),
|
|
|
|
BottomNavigationBarItem(icon: Icon(Icons.person), label: "用户")
|
|
|
|
])
|
|
|
|
: null,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2023-02-07 17:28:01 +08:00
|
|
|
|
|
|
|
List<Widget> pageList = [
|
|
|
|
Gallery(),
|
|
|
|
Scaffold(
|
|
|
|
body: Placeholder(),
|
|
|
|
)
|
|
|
|
];
|