mirror of
https://github.com/Auties00/Reboot-Launcher.git
synced 2026-01-14 11:39:17 +01:00
Final version
This commit is contained in:
78
gui/lib/src/page/abstract/page.dart
Normal file
78
gui/lib/src/page/abstract/page.dart
Normal file
@@ -0,0 +1,78 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:reboot_launcher/src/dialog/abstract/info_bar.dart' as messenger;
|
||||
import 'package:reboot_launcher/src/page/abstract/page_setting.dart';
|
||||
import 'package:reboot_launcher/src/page/abstract/page_type.dart';
|
||||
|
||||
abstract class RebootPage extends StatefulWidget {
|
||||
const RebootPage({super.key});
|
||||
|
||||
String get name;
|
||||
|
||||
String get iconAsset;
|
||||
|
||||
RebootPageType get type;
|
||||
|
||||
int get index => type.index;
|
||||
|
||||
List<PageSetting> get settings;
|
||||
|
||||
bool get hasButton;
|
||||
|
||||
@override
|
||||
RebootPageState createState();
|
||||
}
|
||||
|
||||
abstract class RebootPageState<T extends RebootPage> extends State<T> with AutomaticKeepAliveClientMixin<T> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
var buttonWidget = button;
|
||||
if(buttonWidget == null) {
|
||||
return _listView;
|
||||
}
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: _listView,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8.0,
|
||||
),
|
||||
ConstrainedBox(
|
||||
constraints: const BoxConstraints(
|
||||
maxWidth: 1000
|
||||
),
|
||||
child: buttonWidget
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
OverlayEntry showInfoBar(dynamic text, {InfoBarSeverity severity = InfoBarSeverity.info, bool loading = false, Duration? duration = snackbarShortDuration, Widget? action}) => messenger.showInfoBar(
|
||||
text,
|
||||
pageType: widget.type,
|
||||
severity: severity,
|
||||
loading: loading,
|
||||
duration: duration,
|
||||
action: action
|
||||
);
|
||||
|
||||
ListView get _listView => ListView.builder(
|
||||
itemCount: settings.length * 2,
|
||||
itemBuilder: (context, index) => index.isEven ? Align(
|
||||
alignment: Alignment.center,
|
||||
child: settings[index ~/ 2],
|
||||
) : const SizedBox(height: 8.0),
|
||||
);
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
List<Widget> get settings;
|
||||
|
||||
Widget? get button;
|
||||
}
|
||||
|
||||
|
||||
|
||||
26
gui/lib/src/page/abstract/page_setting.dart
Normal file
26
gui/lib/src/page/abstract/page_setting.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
class PageSetting {
|
||||
final String name;
|
||||
final String description;
|
||||
final String? content;
|
||||
final List<PageSetting>? children;
|
||||
final int pageIndex;
|
||||
|
||||
PageSetting(
|
||||
{required this.name,
|
||||
required this.description,
|
||||
this.content,
|
||||
this.children,
|
||||
this.pageIndex = -1});
|
||||
|
||||
PageSetting withPageIndex(int pageIndex) => this.pageIndex != -1
|
||||
? this
|
||||
: PageSetting(
|
||||
name: name,
|
||||
description: description,
|
||||
content: content,
|
||||
children: children,
|
||||
pageIndex: pageIndex);
|
||||
|
||||
@override
|
||||
String toString() => "$name: $description";
|
||||
}
|
||||
9
gui/lib/src/page/abstract/page_type.dart
Normal file
9
gui/lib/src/page/abstract/page_type.dart
Normal file
@@ -0,0 +1,9 @@
|
||||
enum RebootPageType {
|
||||
play,
|
||||
host,
|
||||
browser,
|
||||
authenticator,
|
||||
matchmaker,
|
||||
info,
|
||||
settings
|
||||
}
|
||||
Reference in New Issue
Block a user