Skip to content

Commit

Permalink
Changed title bar design & Hotfix #4
Browse files Browse the repository at this point in the history
  • Loading branch information
bostrot committed Nov 3, 2021
1 parent e62990a commit 631aa2c
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 57 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"C_Cpp.errorSquiggles": "Disabled"
}
Binary file modified build/windows/runner/Release/data/app.so
Binary file not shown.
Binary file modified build/windows/runner/Release/data/flutter_assets/NOTICES.Z
Binary file not shown.
Binary file modified build/windows/runner/Release/wsl2distromanager.exe
Binary file not shown.
154 changes: 100 additions & 54 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:desktop_window/desktop_window.dart';
import 'package:fluent_ui/fluent_ui.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:system_theme/system_theme.dart';
import 'package:bitsdojo_window/bitsdojo_window.dart';

import 'api.dart';
import 'distro_list_component.dart';
Expand All @@ -13,10 +14,21 @@ void main() async {
WidgetsFlutterBinding.ensureInitialized();
await SystemTheme.accentInstance.load();
runApp(const MyApp());
DesktopWindow.setWindowSize(const Size(650, 500));
DesktopWindow.setMinWindowSize(const Size(650, 500));
doWhenWindowReady(() {
final win = appWindow;
final initialSize = Size(650, 500);
win.minSize = initialSize;
win.size = initialSize;
win.alignment = Alignment.center;
win.title = "Custom window with Flutter";
win.show();
});
//DesktopWindow.setWindowSize(const Size(650, 500));
//DesktopWindow.setMinWindowSize(const Size(650, 500));
}

ThemeData themeData = ThemeData();

class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);

Expand All @@ -26,26 +38,27 @@ class MyApp extends StatelessWidget {
future: SystemTheme.darkMode,
builder: (BuildContext context, AsyncSnapshot<bool> darkMode) {
if (darkMode.hasData) {
ThemeData theme;
if (darkMode.data == false) {
// lightmode
theme = ThemeData(
themeData = ThemeData(
/*scaffoldBackgroundColor: const Color.fromRGBO(243, 243, 243, 1.0),*/
activeColor: Colors.black,
accentColor: SystemTheme.accentInstance.accent.toAccentColor(),
brightness: Brightness.light, // or Brightness.dark
);
} else {
// darkmode
theme = ThemeData(
themeData = ThemeData(
/*scaffoldBackgroundColor: const Color.fromRGBO(243, 243, 243, 1.0),*/
activeColor: Colors.white,
accentColor: SystemTheme.accentInstance.accent.toAccentColor(),
brightness: Brightness.dark, // or Brightness.dark
);
}
return FluentApp(
title: 'WSL2 Distro Manager by Bostrot',
theme: theme,
home: const MyHomePage(title: 'WSL2 Distro Manager by Bostrot'),
theme: themeData,
home: const MyHomePage(title: 'WSL Distro Manager by Bostrot'),
debugShowCheckedModeBanner: false,
);
} else if (darkMode.hasError) {
Expand Down Expand Up @@ -163,54 +176,87 @@ class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return ScaffoldPage(
padding: const EdgeInsets.only(top: 8.0, bottom: 8.0),
content: Padding(
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
createComponent(api, statusMsg),
DistroList(
api: api,
statusMsg: statusMsg,
padding: const EdgeInsets.only(top: 0.0, bottom: 8.0),
content: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(4.0),
child: WindowTitleBarBox(
child: Row(
children: [
Expanded(
child: MoveWindow(
child: const Padding(
padding: EdgeInsets.only(left: 20.0, top: 8.0),
child: Text('WSL Manager'),
),
),
),
MinimizeWindowButton(
colors:
WindowButtonColors(iconNormal: themeData.activeColor),
),
MaximizeWindowButton(
colors:
WindowButtonColors(iconNormal: themeData.activeColor),
),
CloseWindowButton(
colors: WindowButtonColors(
iconNormal: themeData.activeColor,
mouseOver: Colors.warningPrimaryColor),
)
],
),
),
statusBuilder(),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextButton(
onPressed: () async {
await canLaunch('https://bostrot.com')
? await launch('https://bostrot.com')
: throw 'Could not launch URL';
},
child: const Text("Created by Bostrot",
style: TextStyle(fontSize: 12.0))),
const Text('|', style: TextStyle(fontSize: 12.0)),
TextButton(
onPressed: () async {
await canLaunch(
'https://github.com/bostrot/wsl2-distro-manager')
? await launch(
'https://github.com/bostrot/wsl2-distro-manager')
: throw 'Could not launch URL';
},
child: const Text("Visit GitHub",
style: TextStyle(fontSize: 12.0))),
const Text('|', style: TextStyle(fontSize: 12.0)),
TextButton(
onPressed: () async {
await canLaunch('http://paypal.me/bostrot')
? await launch('http://paypal.me/bostrot')
: throw 'Could not launch URL';
},
child:
const Text("Donate", style: TextStyle(fontSize: 12.0))),
],
)
],
),
),
Padding(
padding: const EdgeInsets.all(10.0),
child: createComponent(api, statusMsg),
),
DistroList(
api: api,
statusMsg: statusMsg,
),
Padding(
padding: const EdgeInsets.all(15.0),
child: statusBuilder(),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextButton(
onPressed: () async {
await canLaunch('https://bostrot.com')
? await launch('https://bostrot.com')
: throw 'Could not launch URL';
},
child: const Text("Created by Bostrot",
style: TextStyle(fontSize: 12.0))),
const Text('|', style: TextStyle(fontSize: 12.0)),
TextButton(
onPressed: () async {
await canLaunch(
'https://github.com/bostrot/wsl2-distro-manager')
? await launch(
'https://github.com/bostrot/wsl2-distro-manager')
: throw 'Could not launch URL';
},
child: const Text("Visit GitHub",
style: TextStyle(fontSize: 12.0))),
const Text('|', style: TextStyle(fontSize: 12.0)),
TextButton(
onPressed: () async {
await canLaunch('http://paypal.me/bostrot')
? await launch('http://paypal.me/bostrot')
: throw 'Could not launch URL';
},
child:
const Text("Donate", style: TextStyle(fontSize: 12.0))),
],
)
],
),
);
}
Expand Down
35 changes: 35 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,41 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.8.2"
bitsdojo_window:
dependency: "direct main"
description:
name: bitsdojo_window
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.1+1"
bitsdojo_window_linux:
dependency: transitive
description:
name: bitsdojo_window_linux
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.1"
bitsdojo_window_macos:
dependency: transitive
description:
name: bitsdojo_window_macos
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.0"
bitsdojo_window_platform_interface:
dependency: transitive
description:
name: bitsdojo_window_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.0"
bitsdojo_window_windows:
dependency: transitive
description:
name: bitsdojo_window_windows
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.0"
boolean_selector:
dependency: transitive
description:
Expand Down
3 changes: 2 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 0.5.1+1 # Current version
version: 0.5.2 # Current version

environment:
sdk: ">=2.12.0 <3.0.0"
Expand All @@ -40,6 +40,7 @@ dependencies:
url_launcher: ^6.0.10
dio: ^4.0.1
package_info_plus: ^1.3.0
bitsdojo_window: ^0.1.1+1

dev_dependencies:
flutter_test:
Expand Down
3 changes: 3 additions & 0 deletions windows/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@

#include "generated_plugin_registrant.h"

#include <bitsdojo_window_windows/bitsdojo_window_plugin.h>
#include <desktop_window/desktop_window_plugin.h>
#include <system_theme/system_theme_plugin.h>
#include <url_launcher_windows/url_launcher_windows.h>

void RegisterPlugins(flutter::PluginRegistry* registry) {
BitsdojoWindowPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("BitsdojoWindowPlugin"));
DesktopWindowPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("DesktopWindowPlugin"));
SystemThemePluginRegisterWithRegistrar(
Expand Down
1 change: 1 addition & 0 deletions windows/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#

list(APPEND FLUTTER_PLUGIN_LIST
bitsdojo_window_windows
desktop_window
system_theme
url_launcher_windows
Expand Down
7 changes: 5 additions & 2 deletions windows/runner/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
#include "flutter_window.h"
#include "utils.h"

#include <bitsdojo_window_windows/bitsdojo_window_plugin.h>
auto bdw = bitsdojo_window_configure(BDW_CUSTOM_FRAME | BDW_HIDE_ON_STARTUP);

int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
_In_ wchar_t *command_line, _In_ int show_command) {
// Attach to console when present (e.g., 'flutter run') or create a
Expand Down Expand Up @@ -46,8 +49,8 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,

FlutterWindow window(project);
Win32Window::Point origin(10, 10);
Win32Window::Size size(1280, 720);
if (!window.CreateAndShow(L"wsl2distromanager", origin, size)) {
Win32Window::Size size(650, 500);
if (!window.CreateAndShow(L"WSL Manager", origin, size)) {
return EXIT_FAILURE;
}
window.SetQuitOnClose(true);
Expand Down

0 comments on commit 631aa2c

Please sign in to comment.