Skip to content

Commit

Permalink
🎆Got QuickMenu ready for release.
Browse files Browse the repository at this point in the history
  • Loading branch information
Far-Se committed Jul 30, 2022
1 parent aaddc50 commit c37a3d8
Showing 23 changed files with 1,113 additions and 399 deletions.
215 changes: 112 additions & 103 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -14,10 +14,11 @@ import 'models/win32/win32.dart';
import 'pages/interface.dart';
import 'pages/quickmenu.dart';

final ValueNotifier<bool> fullLoaded = ValueNotifier<bool>(false);
Future<void> main(List<String> arguments) async {
List<String> auxArgs = <String>[...arguments];
if (auxArgs.length == 1 && auxArgs[0].contains('-wizardly')) {
auxArgs = <String>['"${auxArgs[0].replaceAll(' -wizardly', '')}\\', '-wizardly'];
if (auxArgs.length == 1 && auxArgs[0].contains('-interface')) {
auxArgs = <String>['"${auxArgs[0].replaceAll(' -interface', '')}\\', '-interface'];
}

// auxArgs.add("-strudel");
@@ -30,14 +31,14 @@ Future<void> main(List<String> arguments) async {

/// ? Window
late WindowOptions windowOptions;
if (globalSettings.args.contains("-wizardly")) {
windowOptions = const WindowOptions(
if (globalSettings.args.contains("-interface")) {
windowOptions = WindowOptions(
size: Size(700, 400),
center: true,
center: false,
backgroundColor: Colors.transparent,
skipTaskbar: false,
alwaysOnTop: false,
title: "Tabame - Wizardly",
title: globalSettings.args.contains("-wizardly") ? "Tabame - Wizardly" : "Tabame - Interface",
);
} else {
windowOptions = const WindowOptions(
@@ -55,7 +56,8 @@ Future<void> main(List<String> arguments) async {
await windowManager.focus();
await windowManager.setAsFrameless();
await windowManager.setHasShadow(false);
Win32.fetchMainWindowHandle();
await Win32.fetchMainWindowHandle();
fullLoaded.value = true;
});

await setWindowAsTransparent();
@@ -87,106 +89,113 @@ class _TabameState extends State<Tabame> {
@override
Widget build(BuildContext context) {
return ValueListenableBuilder<bool>(
valueListenable: themeChangeNotifier,
builder: (_, bool refreshed, __) {
ThemeMode scheduled = ThemeMode.system;
ThemeType themeType = globalSettings.themeType;
if (themeType.index == 3) {
scheduled = globalSettings.themeTypeMode == ThemeType.dark ? ThemeMode.dark : ThemeMode.light;
}
ThemeMode themeMode = <ThemeMode>[ThemeMode.system, ThemeMode.light, ThemeMode.dark, scheduled][themeType.index];

return MaterialApp(
scrollBehavior: MyCustomScrollBehavior(),
debugShowCheckedModeBanner: false,
title: 'Tabame - Taskbar Menu',
theme: ThemeData.light().copyWith(
splashColor: Color.fromARGB(225, 0, 0, 0),
backgroundColor: Color(globalSettings.lightTheme.background),
dialogBackgroundColor: Color(globalSettings.lightTheme.background),
cardColor: Color(globalSettings.lightTheme.background),
errorColor: Color(globalSettings.lightTheme.accentColor),
iconTheme: ThemeData.light().iconTheme.copyWith(color: Color(globalSettings.lightTheme.textColor)),
textTheme: ThemeData.light().textTheme.apply(
bodyColor: Color(globalSettings.lightTheme.textColor),
displayColor: Color(globalSettings.lightTheme.textColor),
decorationColor: Color(globalSettings.lightTheme.textColor)),
toggleableActiveColor: Color(globalSettings.lightTheme.accentColor),
checkboxTheme: ThemeData.light()
.checkboxTheme
.copyWith(visualDensity: VisualDensity.compact, checkColor: MaterialStateProperty.all(Color(globalSettings.lightTheme.background))),
tooltipTheme: ThemeData.light().tooltipTheme.copyWith(
verticalOffset: 10,
padding: EdgeInsets.symmetric(horizontal: 4, vertical: 2),
height: 0,
margin: EdgeInsets.all(0),
textStyle: TextStyle(color: Color(globalSettings.lightTheme.textColor), fontSize: 12, height: 0),
decoration: BoxDecoration(color: Color(globalSettings.lightTheme.background)),
preferBelow: false,
),
colorScheme: ThemeData.light().colorScheme.copyWith(
primary: Color(globalSettings.lightTheme.accentColor),
secondary: Color(globalSettings.lightTheme.accentColor),
),
),
darkTheme: ThemeData.dark().copyWith(
splashColor: Color.fromARGB(225, 0, 0, 0),
backgroundColor: Color(globalSettings.darkTheme.background),
dialogBackgroundColor: Color(globalSettings.darkTheme.background),
cardColor: Color(globalSettings.darkTheme.background),
errorColor: Color(globalSettings.darkTheme.accentColor),
iconTheme: ThemeData.dark().iconTheme.copyWith(color: Color(globalSettings.darkTheme.textColor)),
textTheme: ThemeData.dark().textTheme.apply(
bodyColor: Color(globalSettings.darkTheme.textColor),
displayColor: Color(globalSettings.darkTheme.textColor),
decorationColor: Color(globalSettings.darkTheme.textColor),
),
toggleableActiveColor: Color(globalSettings.darkTheme.accentColor),
checkboxTheme: ThemeData.dark()
.checkboxTheme
.copyWith(visualDensity: VisualDensity.compact, checkColor: MaterialStateProperty.all(Color(globalSettings.darkTheme.background))),
tooltipTheme: ThemeData.dark().tooltipTheme.copyWith(
verticalOffset: 10,
padding: EdgeInsets.symmetric(horizontal: 4, vertical: 2),
height: 0,
margin: EdgeInsets.all(0),
textStyle: TextStyle(color: Color(globalSettings.darkTheme.textColor), fontSize: 12, height: 0),
decoration: BoxDecoration(color: Color(globalSettings.darkTheme.background)),
preferBelow: false,
valueListenable: fullLoaded,
builder: (BuildContext context, bool value, __) {
if (value == false) return Container();
return ValueListenableBuilder<bool>(
valueListenable: themeChangeNotifier,
builder: (_, bool refreshed, __) {
ThemeMode scheduled = ThemeMode.system;
ThemeType themeType = globalSettings.themeType;
if (themeType.index == 3) {
scheduled = globalSettings.themeTypeMode == ThemeType.dark ? ThemeMode.dark : ThemeMode.light;
}
ThemeMode themeMode = <ThemeMode>[ThemeMode.system, ThemeMode.light, ThemeMode.dark, scheduled][themeType.index];

return MaterialApp(
scrollBehavior: MyCustomScrollBehavior(),
debugShowCheckedModeBanner: false,
title: 'Tabame - Taskbar Menu',
theme: ThemeData.light().copyWith(
splashColor: Color.fromARGB(225, 0, 0, 0),
backgroundColor: Color(globalSettings.lightTheme.background),
dialogBackgroundColor: Color(globalSettings.lightTheme.background),
cardColor: Color(globalSettings.lightTheme.background),
errorColor: Color(globalSettings.lightTheme.accentColor),
iconTheme: ThemeData.light().iconTheme.copyWith(color: Color(globalSettings.lightTheme.textColor)),
textTheme: ThemeData.light().textTheme.apply(
bodyColor: Color(globalSettings.lightTheme.textColor),
displayColor: Color(globalSettings.lightTheme.textColor),
decorationColor: Color(globalSettings.lightTheme.textColor)),
toggleableActiveColor: Color(globalSettings.lightTheme.accentColor),
checkboxTheme: ThemeData.light()
.checkboxTheme
.copyWith(visualDensity: VisualDensity.compact, checkColor: MaterialStateProperty.all(Color(globalSettings.lightTheme.background))),
tooltipTheme: ThemeData.light().tooltipTheme.copyWith(
verticalOffset: 10,
padding: EdgeInsets.symmetric(horizontal: 4, vertical: 2),
height: 0,
margin: EdgeInsets.all(0),
textStyle: TextStyle(color: Color(globalSettings.lightTheme.textColor), fontSize: 12, height: 0),
decoration: BoxDecoration(color: Color(globalSettings.lightTheme.background)),
preferBelow: false,
),
colorScheme: ThemeData.light().colorScheme.copyWith(
primary: Color(globalSettings.lightTheme.accentColor),
secondary: Color(globalSettings.lightTheme.accentColor),
),
),
colorScheme: ThemeData.dark().colorScheme.copyWith(
primary: Color(globalSettings.darkTheme.accentColor),
secondary: Color(globalSettings.darkTheme.accentColor),
tertiary: Color(globalSettings.darkTheme.textColor),
darkTheme: ThemeData.dark().copyWith(
splashColor: Color.fromARGB(225, 0, 0, 0),
backgroundColor: Color(globalSettings.darkTheme.background),
dialogBackgroundColor: Color(globalSettings.darkTheme.background),
cardColor: Color(globalSettings.darkTheme.background),
errorColor: Color(globalSettings.darkTheme.accentColor),
iconTheme: ThemeData.dark().iconTheme.copyWith(color: Color(globalSettings.darkTheme.textColor)),
textTheme: ThemeData.dark().textTheme.apply(
bodyColor: Color(globalSettings.darkTheme.textColor),
displayColor: Color(globalSettings.darkTheme.textColor),
decorationColor: Color(globalSettings.darkTheme.textColor),
),
toggleableActiveColor: Color(globalSettings.darkTheme.accentColor),
checkboxTheme: ThemeData.dark()
.checkboxTheme
.copyWith(visualDensity: VisualDensity.compact, checkColor: MaterialStateProperty.all(Color(globalSettings.darkTheme.background))),
tooltipTheme: ThemeData.dark().tooltipTheme.copyWith(
verticalOffset: 10,
padding: EdgeInsets.symmetric(horizontal: 4, vertical: 2),
height: 0,
margin: EdgeInsets.all(0),
textStyle: TextStyle(color: Color(globalSettings.darkTheme.textColor), fontSize: 12, height: 0),
decoration: BoxDecoration(color: Color(globalSettings.darkTheme.background)),
preferBelow: false,
),
colorScheme: ThemeData.dark().colorScheme.copyWith(
primary: Color(globalSettings.darkTheme.accentColor),
secondary: Color(globalSettings.darkTheme.accentColor),
tertiary: Color(globalSettings.darkTheme.textColor),
),
),
),
themeMode: themeMode,
// home: QuickMenu()
home: PageView.builder(
controller: mainPageViewController,
allowImplicitScrolling: false,
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (BuildContext context, int index) {
if (globalSettings.args.contains("-wizardly")) {
return FutureBuilder<int>(
future: Future<int>.delayed(Duration(milliseconds: 300), () => 1),
builder: (BuildContext context, AsyncSnapshot<Object?> snapshot) {
if (!snapshot.hasData) return Container();
return const Interface();
themeMode: themeMode,
// home: QuickMenu()
home: PageView.builder(
controller: mainPageViewController,
allowImplicitScrolling: false,
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (BuildContext context, int index) {
if (globalSettings.args.contains("-interface")) {
return const Interface();

// return FutureBuilder<int>(
// future: Future<int>.delayed(Duration(milliseconds: 300), () => 1),
// builder: (BuildContext context, AsyncSnapshot<Object?> snapshot) {
// if (!snapshot.hasData) return Container();
// return const Interface();
// },
// );
}
if (index == Pages.quickmenu.index) {
return const QuickMenu();
} else if (index == Pages.interface.index) {
return const Interface();
}
return const QuickMenu();
},
);
}
if (index == Pages.quickmenu.index) {
return const QuickMenu();
} else if (index == Pages.interface.index) {
return const Interface();
}
return const QuickMenu();
),
);
},
),
);
},
);
);
});
}
}

79 changes: 61 additions & 18 deletions lib/models/classes/boxes.dart
Original file line number Diff line number Diff line change
@@ -2,26 +2,30 @@ import 'dart:async';
import 'dart:convert';
import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:tabamewin32/tabamewin32.dart';
import '../../main.dart';
import '../settings.dart';
import 'save_settings.dart';
import 'saved_maps.dart';
import 'package:http/http.dart' as http;

import '../win32/win32.dart';

class Boxes {
// vscode-fold=2
static late SharedPreferences pref;
static late SaveSettings pref;
static List<String> mediaControls = <String>[];

Boxes();
static Future<void> registerBoxes() async {
pref = await SharedPreferences.getInstance();
static Future<void> registerBoxes({bool reload = false}) async {
if (reload) {
await pref.reload();
} else {
pref = await SaveSettings.getInstance();
}

// await pref.remove("projects");
// pref = await SharedPreferences.getInstance();
// pref = await SaveSettings.getInstance();
//? Settings
if (pref.getString("language") == null) {
await pref.setInt("taskBarAppsStyle", TaskBarAppsStyle.activeMonitorFirst.index);
@@ -63,7 +67,7 @@ class Boxes {
weekDays: <bool>[true, true, true, true, true, false, false]);
await pref.setString("reminders", jsonEncode(<Reminder>[demoReminder]));
await setStartOnSystemStartup(true);
pref = await SharedPreferences.getInstance();
pref = await SaveSettings.getInstance();
}
globalSettings
..hideTaskbarOnStartup = pref.getBool("hideTaskbarOnStartup") ?? false
@@ -96,6 +100,7 @@ class Boxes {
if (lightTheme != null) globalSettings.lightTheme = ThemeColors.fromJson(lightTheme);
if (darkTheme != null) globalSettings.darkTheme = ThemeColors.fromJson(darkTheme);
themeChangeNotifier.value = !themeChangeNotifier.value;

//? Pinned Apps
if (pref.getStringList("pinnedApps") == null) {
final List<String> pinnedApps2 = await WinUtils.getTaskbarPinnedApps();
@@ -104,28 +109,35 @@ class Boxes {
await pref.setStringList("pinnedApps", pinnedApps2);
}

//?PowerShell
if (pref.getString("powerShellScripts") == null) {
final List<String> powerShellScripts = <String>[
PowerShellScript(name: "🏠Show IP", command: "(Invoke-WebRequest -uri \"http://ifconfig.me/ip\").Content", showTerminal: true).toJson()
];
await pref.setString("powerShellScripts", jsonEncode(powerShellScripts));
}

//? Media Controls
mediaControls = pref.getStringList("mediaControls") ?? <String>["Spotify.exe", "chrome.exe", "firefox.exe", "Music.UI.exe"];

//! Startup
//? Taskbar
if (!kDebugMode) {
//if (kReleaseMode) {
if (globalSettings.args.isEmpty) {
if (globalSettings.hideTaskbarOnStartup) {
WinUtils.toggleTaskbar(visible: false);
}
}

//? Volume
globalSettings.volumeOSDStyle = VolumeOSDStyle.media;
if (globalSettings.volumeOSDStyle != VolumeOSDStyle.normal) {
WinUtils.setVolumeOSDStyle(type: globalSettings.volumeOSDStyle, applyStyle: true);
//? Volume
globalSettings.volumeOSDStyle = VolumeOSDStyle.media;
if (globalSettings.volumeOSDStyle != VolumeOSDStyle.normal) {
WinUtils.setVolumeOSDStyle(type: globalSettings.volumeOSDStyle, applyStyle: true);
}
}
if (globalSettings.args.isEmpty || globalSettings.args.contains("-restarted")) {
if (pageWatchers.where((PageWatcher element) => element.enabled).isNotEmpty) Tasks().startPageWatchers();
if (reminders.where((Reminder element) => element.enabled).isNotEmpty) Tasks().startReminders();
}
//? Media Controls
mediaControls = pref.getStringList("mediaControls") ?? <String>["Spotify.exe", "chrome.exe", "firefox.exe", "Music.UI.exe"];
if (pageWatchers.where((PageWatcher element) => element.enabled).isNotEmpty) Tasks().startPageWatchers();
if (reminders.where((Reminder element) => element.enabled).isNotEmpty) Tasks().startReminders();
}

static Future<void> updateSettings(String key, dynamic value) async {
@@ -142,7 +154,7 @@ class Boxes {
} else {
throw ("No asociated type $value");
}
pref = await SharedPreferences.getInstance();
pref = await SaveSettings.getInstance();
}

static List<T> getSavedMap<T>(T Function(String json) fromJson, String key) {
@@ -238,6 +250,37 @@ class Boxes {
static List<Reminder> _reminders = <Reminder>[];
static set reminders(List<Reminder> list) => _reminders = list;
static List<Reminder> get reminders => _reminders.isEmpty ? _reminders = getSavedMap<Reminder>(Reminder.fromJson, "reminders") : _reminders;

static List<RunAPI> _runApi = <RunAPI>[];
static set runApi(List<RunAPI> list) => _runApi = list;
static List<RunAPI> get runApi => _runApi.isEmpty ? _runApi = getSavedMap<RunAPI>(RunAPI.fromJson, "runApi") : _runApi;

void watchForSettingsChange() {
globalSettings.previewTheme = true;
String savedFileText = File(Boxes.pref.fileName).readAsStringSync();
bool updating = false;
Timer.periodic(const Duration(milliseconds: 100), (Timer timer) async {
if (updating) return;
final String x = File(Boxes.pref.fileName).readAsStringSync();
if (savedFileText != x) {
updating = true;
savedFileText = x;
await Boxes.registerBoxes(reload: true);
updating = false;
final String prevThemeLight = Boxes.pref.getString("previewThemeLight") ?? "";
if (prevThemeLight.isNotEmpty) {
globalSettings.lightTheme = ThemeColors.fromJson(prevThemeLight);
File(r"E:\l.txt").writeAsString("changed prev theme for light", mode: FileMode.append);
}
final String prevThemeDark = Boxes.pref.getString("previewThemeDark") ?? "";
if (prevThemeDark.isNotEmpty) {
globalSettings.darkTheme = ThemeColors.fromJson(prevThemeDark);
File(r"E:\l.txt").writeAsString("changed prev theme for dark", mode: FileMode.append);
}
globalSettings.settingsChanged = !globalSettings.settingsChanged;
}
});
}
}

class Tasks {
Loading

0 comments on commit c37a3d8

Please sign in to comment.