This commit is contained in:
Alessandro Autiero
2024-06-01 16:26:00 +02:00
parent d478650e9b
commit efb508bd0c
243 changed files with 486662 additions and 2948 deletions

View File

@@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:io';
import 'dart:ui';
import 'package:bitsdojo_window/bitsdojo_window.dart';
@@ -10,7 +11,6 @@ import 'package:reboot_common/common.dart';
import 'package:reboot_launcher/src/controller/settings_controller.dart';
import 'package:reboot_launcher/src/controller/update_controller.dart';
import 'package:reboot_launcher/src/dialog/abstract/dialog.dart';
import 'package:reboot_launcher/src/dialog/abstract/info_bar.dart';
import 'package:reboot_launcher/src/dialog/implementation/dll.dart';
import 'package:reboot_launcher/src/page/abstract/page.dart';
import 'package:reboot_launcher/src/page/abstract/page_suggestion.dart';
@@ -18,6 +18,7 @@ import 'package:reboot_launcher/src/page/pages.dart';
import 'package:reboot_launcher/src/util/dll.dart';
import 'package:reboot_launcher/src/util/os.dart';
import 'package:reboot_launcher/src/util/translations.dart';
import 'package:reboot_launcher/src/widget/info_bar_area.dart';
import 'package:reboot_launcher/src/widget/profile_tile.dart';
import 'package:reboot_launcher/src/widget/title_bar.dart';
import 'package:window_manager/window_manager.dart';
@@ -45,13 +46,6 @@ class _HomePageState extends State<HomePage> with WindowListener, AutomaticKeepA
@override
void initState() {
windowManager.addListener(this);
var lastValue = pageIndex.value;
pageIndex.listen((value) {
WidgetsBinding.instance.addPostFrameCallback((_) {
restoreMessage(value, lastValue);
lastValue = value;
});
});
WidgetsBinding.instance.addPostFrameCallback((_) {
_updateController.update();
watchDlls().listen((filePath) => showDllDeletedDialog(() {
@@ -61,6 +55,11 @@ class _HomePageState extends State<HomePage> with WindowListener, AutomaticKeepA
super.initState();
}
@override
void onWindowClose() {
exit(0); // Force closing
}
@override
void dispose() {
_searchFocusNode.dispose();
@@ -80,6 +79,46 @@ class _HomePageState extends State<HomePage> with WindowListener, AutomaticKeepA
_focused.value = false;
}
@override
void onWindowDocked() {
_focused.value = true;
}
@override
void onWindowMaximize() {
_focused.value = true;
}
@override
void onWindowMinimize() {
_focused.value = false;
}
@override
void onWindowResize() {
_focused.value = true;
}
@override
void onWindowMove() {
_focused.value = true;
}
@override
void onWindowRestore() {
_focused.value = true;
}
@override
void onWindowUndocked() {
_focused.value = true;
}
@override
void onWindowUnmaximize() {
_focused.value = true;
}
@override
void onWindowResized() {
_settingsController.saveWindowSize(appWindow.size);
@@ -140,7 +179,7 @@ class _HomePageState extends State<HomePage> with WindowListener, AutomaticKeepA
menuButton: const SizedBox(),
displayMode: PaneDisplayMode.open,
items: _items,
customPane: _CustomPane(),
customPane: _CustomPane(_settingsController),
header: const ProfileWidget(),
autoSuggestBox: _autoSuggestBox,
indicator: const StickyNavigationIndicator(
@@ -190,43 +229,47 @@ class _HomePageState extends State<HomePage> with WindowListener, AutomaticKeepA
onVerticalDragStart: (_) => appWindow.startDragging()
);
Widget get _autoSuggestBox => Padding(
padding: const EdgeInsets.symmetric(
horizontal: 16.0,
vertical: 8.0
),
child: AutoSuggestBox<PageSuggestion>(
key: _searchKey,
controller: _searchController,
placeholder: translations.find,
focusNode: _searchFocusNode,
selectionHeightStyle: BoxHeightStyle.max,
itemBuilder: (context, item) => ListTile(
onPressed: () {
pageIndex.value = item.value.pageIndex;
_searchController.clear();
_searchFocusNode.unfocus();
},
leading: item.child,
title: Text(
item.value.name,
overflow: TextOverflow.clip,
maxLines: 1
)
Widget get _autoSuggestBox => Obx(() {
final firstRun = _settingsController.firstRun.value;
return Padding(
padding: const EdgeInsets.symmetric(
horizontal: 16.0,
vertical: 8.0
),
items: _suggestedItems,
autofocus: true,
trailingIcon: IgnorePointer(
child: IconButton(
onPressed: () {},
icon: Transform.flip(
flipX: true,
child: const Icon(FluentIcons.search)
),
)
),
)
);
child: AutoSuggestBox<PageSuggestion>(
key: _searchKey,
controller: _searchController,
enabled: !firstRun,
placeholder: translations.find,
focusNode: _searchFocusNode,
selectionHeightStyle: BoxHeightStyle.max,
itemBuilder: (context, item) => ListTile(
onPressed: () {
pageIndex.value = item.value.pageIndex;
_searchController.clear();
_searchFocusNode.unfocus();
},
leading: item.child,
title: Text(
item.value.name,
overflow: TextOverflow.clip,
maxLines: 1
)
),
items: _suggestedItems,
autofocus: true,
trailingIcon: IgnorePointer(
child: IconButton(
onPressed: () {},
icon: Transform.flip(
flipX: true,
child: const Icon(FluentIcons.search)
),
)
),
)
);
});
List<AutoSuggestBoxItem<PageSuggestion>> get _suggestedItems => pages.mapMany((page) {
final pageIcon = SizedBox.square(
@@ -369,32 +412,40 @@ class _PaneBodyState extends State<_PaneBody> with AutomaticKeepAliveClientMixin
),
const SizedBox(height: 24.0),
Expanded(
child: PageView.builder(
controller: _pageController,
itemBuilder: (context, index) => Navigator(
onPopPage: (page, data) => true,
observers: [
_NestedPageObserver(
onChanged: (routeName) {
if(routeName != null) {
pageIndex.refresh();
addSubPageToStack(routeName);
widget.controller.add(null);
}
}
)
],
pages: [
MaterialPage(
child: KeyedSubtree(
key: getPageKeyByIndex(index),
child: widget.body ?? const SizedBox.shrink()
)
)
],
),
itemCount: pages.length
),
child: Stack(
fit: StackFit.loose,
children: [
PageView.builder(
controller: _pageController,
itemBuilder: (context, index) => Navigator(
onPopPage: (page, data) => true,
observers: [
_NestedPageObserver(
onChanged: (routeName) {
if(routeName != null) {
pageIndex.refresh();
addSubPageToStack(routeName);
widget.controller.add(null);
}
}
)
],
pages: [
MaterialPage(
child: KeyedSubtree(
key: getPageKeyByIndex(index),
child: widget.body ?? const SizedBox.shrink()
)
)
],
),
itemCount: pages.length
),
InfoBarArea(
key: infoBarAreaKey
)
],
)
),
],
),
@@ -408,6 +459,9 @@ class _PaneBodyState extends State<_PaneBody> with AutomaticKeepAliveClientMixin
}
class _CustomPane extends NavigationPaneWidget {
final SettingsController settingsController;
_CustomPane(this.settingsController);
@override
Widget build(BuildContext context, NavigationPaneWidgetData data) => Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -444,33 +498,36 @@ class _CustomPane extends NavigationPaneWidget {
),
itemBuilder: (context, index) {
final item = data.pane.items[index] as PaneItem;
return HoverButton(
onPressed: () => data.pane.onChanged?.call(index),
builder: (context, states) => Container(
height: 36,
decoration: BoxDecoration(
color: ButtonThemeData.uncheckedInputColor(
FluentTheme.of(context),
item == data.pane.selectedItem ? {ButtonStates.hovering} : states,
transparentWhenNone: true,
return Obx(() {
final firstRun = settingsController.firstRun.value;
return HoverButton(
onPressed: firstRun ? null : () => data.pane.onChanged?.call(index),
builder: (context, states) => Container(
height: 36,
decoration: BoxDecoration(
color: ButtonThemeData.uncheckedInputColor(
FluentTheme.of(context),
item == data.pane.selectedItem ? {ButtonStates.hovering} : states,
transparentWhenNone: true,
),
borderRadius: BorderRadius.all(Radius.circular(6.0))
),
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 8.0
),
child: Row(
children: [
data.pane.indicator ?? const SizedBox.shrink(),
item.icon,
const SizedBox(width: 12.0),
item.title ?? const SizedBox.shrink()
],
),
borderRadius: BorderRadius.all(Radius.circular(6.0))
),
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 8.0
),
child: Row(
children: [
data.pane.indicator ?? const SizedBox.shrink(),
item.icon,
const SizedBox(width: 12.0),
item.title ?? const SizedBox.shrink()
],
),
),
),
);
);
});
},
),
),