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

25
lib/fluent/app.dart Normal file
View 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
View 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
View 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
View 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();
})
],
);
}

25
lib/main.dart Normal file
View File

@ -0,0 +1,25 @@
import 'dart:io';
import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:momo/fluent/app.dart';
import 'package:momo/material/app.dart';
void main() {
print(defaultTargetPlatform);
runApp(ProviderScope(child: const MyApp()));
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
if (Platform.isWindows) {
return const MyFluentApp();
} else {
return const MyMaterialApp();
}
}
}

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();
},
),
],
);
}

54
lib/models/configs.dart Normal file
View File

@ -0,0 +1,54 @@
import 'package:json_annotation/json_annotation.dart';
/// This allows the `User` class to access private members in
/// the generated file. The value for this is *.g.dart, where
/// the star denotes the source file name.
part 'configs.g.dart';
/// An annotation for the code generator to know that this class needs the
/// JSON serialization logic to be generated.
@JsonSerializable()
class Configs {
Configs(
this.port,
this.socksPort,
this.tproxyPort,
this.redirPort,
this.mixedPort,
this.authentication,
this.allowLan,
this.bindAddress,
this.mode,
this.logLevel,
this.ipv6);
int port;
@JsonKey(name: 'socks-port')
int socksPort;
@JsonKey(name: 'redir-port')
int redirPort;
@JsonKey(name: 'tproxy-port')
int tproxyPort;
@JsonKey(name: 'mixed-port')
int mixedPort;
List authentication;
@JsonKey(name: 'allow-lan')
bool allowLan;
@JsonKey(name: 'bind-address')
String bindAddress;
String mode;
@JsonKey(name: 'log-level')
String logLevel;
bool ipv6;
/// A necessary factory constructor for creating a new Configs instance
/// from a map. Pass the map to the generated `_$ConfigsFromJson()` constructor.
/// The constructor is named after the source class, in this case, Configs.
factory Configs.fromJson(Map<String, dynamic> json) =>
_$ConfigsFromJson(json);
/// `toJson` is the convention for a class to declare support for serialization
/// to JSON. The implementation simply calls the private, generated
/// helper method `_$ConfigsToJson`.
Map<String, dynamic> toJson() => _$ConfigsToJson(this);
}

35
lib/models/configs.g.dart Normal file
View File

@ -0,0 +1,35 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'configs.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
Configs _$ConfigsFromJson(Map<String, dynamic> json) => Configs(
json['port'] as int,
json['socks-port'] as int,
json['tproxy-port'] as int,
json['redir-port'] as int,
json['mixed-port'] as int,
json['authentication'] as List<dynamic>,
json['allow-lan'] as bool,
json['bind-address'] as String,
json['mode'] as String,
json['log-level'] as String,
json['ipv6'] as bool,
);
Map<String, dynamic> _$ConfigsToJson(Configs instance) => <String, dynamic>{
'port': instance.port,
'socks-port': instance.socksPort,
'redir-port': instance.redirPort,
'tproxy-port': instance.tproxyPort,
'mixed-port': instance.mixedPort,
'authentication': instance.authentication,
'allow-lan': instance.allowLan,
'bind-address': instance.bindAddress,
'mode': instance.mode,
'log-level': instance.logLevel,
'ipv6': instance.ipv6,
};

15
lib/provider/token.dart Normal file
View File

@ -0,0 +1,15 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
class TokenNotifier extends Notifier<String> {
@override
String build() {
return "";
}
setToken(String token) {
state = token;
}
}
final tokenProvider =
NotifierProvider<TokenNotifier, String>(() => TokenNotifier());

60
lib/router.dart Normal file
View File

@ -0,0 +1,60 @@
// import 'package:fluent_ui/fluent_ui.dart';
// import 'package:fluentui_system_icons/fluentui_system_icons.dart'
// as fluentui_system_icons;
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
class MyRouterConfig {
/// The route configuration.
static GoRouter router = GoRouter(
routes: <RouteBase>[
GoRoute(
path: '/',
builder: (BuildContext context, GoRouterState state) {
return Scaffold(
// drawer: Drawer(),
bottomNavigationBar: MediaQuery.of(context).size.width <= 640
? BottomNavigationBar(
items: [
BottomNavigationBarItem(
icon: Icon(Icons.add), label: "333333333"),
BottomNavigationBarItem(
icon: Icon(Icons.add), label: "333333333")
],
)
: null,
body: Row(
children: [
MediaQuery.of(context).size.width > 640
? NavigationRail(
destinations: [
NavigationRailDestination(
icon: Icon(Icons.add), label: Text("123")),
NavigationRailDestination(
icon: Icon(Icons.add), label: Text("123")),
],
extended: MediaQuery.of(context).size.width >= 1008,
backgroundColor: Colors.blueAccent,
// extended: true,
selectedIndex: 0,
)
: SizedBox(
width: 0,
),
Expanded(child: Container())
],
));
},
// routes: <RouteBase>[
// GoRoute(
// path: 'details',
// builder: (BuildContext context, GoRouterState state) {
// return const DetailsScreen();
// },
// ),
// ],
),
],
);
}

15
lib/screens/login.dart Normal file
View File

@ -0,0 +1,15 @@
import 'package:fluent_ui/fluent_ui.dart';
class Login extends StatefulWidget {
const Login({Key? key}) : super(key: key);
@override
State<Login> createState() => _LoginState();
}
class _LoginState extends State<Login> {
@override
Widget build(BuildContext context) {
return const Placeholder();
}
}

0
lib/screens/profile.dart Normal file
View File