This commit is contained in:
quantulr
2023-02-06 23:45:56 +08:00
commit ac65c1dec0
147 changed files with 5605 additions and 0 deletions

14
lib/material/app.dart Normal file
View File

@ -0,0 +1,14 @@
import 'package:flutter/material.dart';
import 'package:momo/material/router.dart';
class MyMaterialApp extends StatelessWidget {
const MyMaterialApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp.router(
routerConfig: MyMaterialRouterConfig.router,
theme: ThemeData(useMaterial3: true),
);
}
}

65
lib/material/home.dart Normal file
View File

@ -0,0 +1,65 @@
import 'package:flutter/material.dart';
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(
backgroundColor: Colors.pinkAccent,
title: const Text("APP"),
),
body: Row(
children: [
MediaQuery.of(context).size.width > 640
? NavigationRail(
leading: MediaQuery.of(context).size.width >= 1008
? const Text(
"Header",
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,
)
],
),
bottomNavigationBar: MediaQuery.of(context).size.width <= 640
? BottomNavigationBar(
currentIndex: selectedIndex,
onTap: (idx) {
setState(() {
selectedIndex = idx;
});
},
items: const [
BottomNavigationBarItem(
icon: Icon(Icons.photo_album), label: "相册"),
BottomNavigationBarItem(icon: Icon(Icons.person), label: "用户")
])
: null,
);
}
}

16
lib/material/router.dart Normal file
View File

@ -0,0 +1,16 @@
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:momo/material/home.dart';
class MyMaterialRouterConfig {
static GoRouter router = GoRouter(
routes: <RouteBase>[
GoRoute(
path: '/',
builder: (BuildContext context, GoRouterState state) {
return HomePage();
},
),
],
);
}