init
This commit is contained in:
25
lib/fluent/app.dart
Normal file
25
lib/fluent/app.dart
Normal file
@ -0,0 +1,25 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:momo/fluent/login.dart';
|
||||
import 'package:momo/fluent/router.dart';
|
||||
import 'package:momo/provider/token.dart';
|
||||
|
||||
class MyFluentApp extends ConsumerWidget {
|
||||
const MyFluentApp({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final String token = ref.watch(tokenProvider);
|
||||
return token.isNotEmpty
|
||||
? FluentApp.router(
|
||||
routeInformationParser:
|
||||
MyFluentRouterConfig.router.routeInformationParser,
|
||||
routerDelegate: MyFluentRouterConfig.router.routerDelegate,
|
||||
color: Colors.blue,
|
||||
)
|
||||
: FluentApp(
|
||||
color: Colors.blue,
|
||||
home: LoginPage(),
|
||||
);
|
||||
}
|
||||
}
|
||||
156
lib/fluent/home.dart
Normal file
156
lib/fluent/home.dart
Normal file
@ -0,0 +1,156 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:fluentui_system_icons/fluentui_system_icons.dart'
|
||||
as fluentui_system_icons;
|
||||
|
||||
class HomePage extends StatefulWidget {
|
||||
const HomePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<HomePage> createState() => _HomePageState();
|
||||
}
|
||||
|
||||
class _HomePageState extends State<HomePage> {
|
||||
int _selected = 0;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MediaQuery.of(context).size.width > 640
|
||||
? NavigationView(
|
||||
appBar: NavigationAppBar(title: Text('momo')),
|
||||
pane: NavigationPane(
|
||||
displayMode: PaneDisplayMode.auto,
|
||||
selected: _selected,
|
||||
leading: const Icon(
|
||||
fluentui_system_icons.FluentIcons.backpack_12_filled),
|
||||
header: const Text("111"),
|
||||
onChanged: (idx) {
|
||||
setState(() {
|
||||
_selected = idx;
|
||||
});
|
||||
},
|
||||
autoSuggestBox: const AutoSuggestBox(
|
||||
placeholder: "查找",
|
||||
trailingIcon: Center(
|
||||
child: Icon(
|
||||
fluentui_system_icons.FluentIcons.search_12_filled),
|
||||
),
|
||||
items: [],
|
||||
),
|
||||
items: [
|
||||
PaneItem(
|
||||
icon: const Icon(fluentui_system_icons
|
||||
.FluentIcons.network_adapter_16_regular),
|
||||
title: const Text('代理'),
|
||||
// body: DeferredWidget
|
||||
body: ScaffoldPage(
|
||||
header: PageHeader(
|
||||
title: Text("213"),
|
||||
),
|
||||
)),
|
||||
PaneItem(
|
||||
icon: const Icon(fluentui_system_icons
|
||||
.FluentIcons.settings_48_regular),
|
||||
title: const Text('用户'),
|
||||
body: ScaffoldPage(
|
||||
header: const PageHeader(
|
||||
title: Text("用户"),
|
||||
),
|
||||
// bottomBar: BottomNavigationBarItem(),
|
||||
// header: HeadingElement.h1(),
|
||||
content: ListView.separated(
|
||||
itemCount: 2,
|
||||
itemBuilder: (context, index) {
|
||||
return const Card(
|
||||
margin: EdgeInsets.fromLTRB(12, 0, 12, 0),
|
||||
padding: EdgeInsets.zero,
|
||||
child: ListTile(
|
||||
// tileColor:
|
||||
// ButtonState.all(const Color(0xffeeeeee)),
|
||||
leading: Icon(fluentui_system_icons
|
||||
.FluentIcons
|
||||
.serial_port_24_regular),
|
||||
title: Text("端口"),
|
||||
trailing: SizedBox(
|
||||
width: 100,
|
||||
child: TextBox(
|
||||
placeholder: "端口",
|
||||
),
|
||||
)));
|
||||
},
|
||||
separatorBuilder: (context, index) =>
|
||||
const SizedBox(
|
||||
height: 2,
|
||||
))))
|
||||
]),
|
||||
)
|
||||
: Container(
|
||||
color: Colors.white,
|
||||
child: ScaffoldPage(
|
||||
header: PageHeader(
|
||||
leading: IconButton(
|
||||
icon: const Icon(fluentui_system_icons
|
||||
.FluentIcons.arrow_hook_up_left_28_filled),
|
||||
onPressed: () {},
|
||||
),
|
||||
title: Text("用户"),
|
||||
),
|
||||
content: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListView(),
|
||||
),
|
||||
BottomNavigation(
|
||||
index: _selected,
|
||||
onChanged: (idx) {
|
||||
setState(() {
|
||||
_selected = idx;
|
||||
});
|
||||
},
|
||||
items: const [
|
||||
BottomNavigationItem(
|
||||
title: Text("相册"),
|
||||
icon: Icon(fluentui_system_icons
|
||||
.FluentIcons.fingerprint_48_regular)),
|
||||
BottomNavigationItem(
|
||||
title: Text("用户"),
|
||||
icon: Icon(fluentui_system_icons
|
||||
.FluentIcons.person_48_regular))
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
// Column(
|
||||
// children: [
|
||||
// Expanded(
|
||||
// child: ScaffoldPage(
|
||||
// header: PageHeader(
|
||||
// title: Text("用户"),
|
||||
// ),
|
||||
// content: Container(
|
||||
// color: Colors.white,
|
||||
// ),
|
||||
// )),
|
||||
// BottomNavigation(
|
||||
// index: _selected,
|
||||
// onChanged: (idx) {
|
||||
// setState(() {
|
||||
// _selected = idx;
|
||||
// });
|
||||
// },
|
||||
// items: const [
|
||||
// BottomNavigationItem(
|
||||
// title: Text("相册"),
|
||||
// icon: Icon(fluentui_system_icons
|
||||
// .FluentIcons.fingerprint_48_regular)),
|
||||
// BottomNavigationItem(
|
||||
// title: Text("用户"),
|
||||
// icon: Icon(
|
||||
// fluentui_system_icons.FluentIcons.person_48_regular))
|
||||
// ],
|
||||
// )
|
||||
// ],
|
||||
// );
|
||||
}
|
||||
}
|
||||
33
lib/fluent/login.dart
Normal file
33
lib/fluent/login.dart
Normal file
@ -0,0 +1,33 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
|
||||
class LoginPage extends StatelessWidget {
|
||||
const LoginPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
// padding: EdgeInsets.all(100),
|
||||
color: Colors.white,
|
||||
child: ScaffoldPage(
|
||||
header: PageHeader(
|
||||
title: Text("登录"),
|
||||
),
|
||||
content: Container(
|
||||
padding: EdgeInsets.fromLTRB(50, 0, 50, 0),
|
||||
child: ListView(
|
||||
children: [
|
||||
TextBox(
|
||||
header: "账号",
|
||||
placeholder: "请输入账号",
|
||||
),
|
||||
TextBox(
|
||||
header: "密码",
|
||||
placeholder: "请输入密码",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
26
lib/fluent/router.dart
Normal file
26
lib/fluent/router.dart
Normal file
@ -0,0 +1,26 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:momo/fluent/home.dart';
|
||||
import 'package:momo/provider/token.dart';
|
||||
|
||||
class MyFluentRouterConfig {
|
||||
static GoRouter router = GoRouter(
|
||||
routes: <RouteBase>[
|
||||
GoRoute(
|
||||
path: '/',
|
||||
builder: (BuildContext context, GoRouterState state) {
|
||||
return HomePage();
|
||||
},
|
||||
redirect: (BuildContext context, GoRouterState state) {
|
||||
print(tokenProvider);
|
||||
return null;
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: "/login",
|
||||
builder: (BuildContext context, GoRouterState state) {
|
||||
return ScaffoldPage();
|
||||
})
|
||||
],
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user