Improve title on desktop

This commit is contained in:
Hillel Coren 2022-01-11 15:45:33 +02:00
parent c89c5af400
commit 77d6f50ad2
9 changed files with 122 additions and 11 deletions

View File

@ -3,6 +3,7 @@ import 'dart:async';
import 'dart:convert'; import 'dart:convert';
// Flutter imports: // Flutter imports:
import 'package:bitsdojo_window/bitsdojo_window.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -132,6 +133,16 @@ void main({bool isTesting = false}) async {
appRunner: () => runApp(InvoiceNinjaApp(store: store)), appRunner: () => runApp(InvoiceNinjaApp(store: store)),
); );
} }
doWhenWindowReady(() {
final win = appWindow;
//const initialSize = Size(600, 450);
//win.minSize = initialSize;
//win.size = initialSize;
//win.alignment = Alignment.center;
//win.maximize();
win.show();
});
} }
Future<AppState> _initialState(bool isTesting) async { Future<AppState> _initialState(bool isTesting) async {

View File

@ -1,4 +1,5 @@
// Flutter imports: // Flutter imports:
import 'package:bitsdojo_window/bitsdojo_window.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
// Package imports: // Package imports:
@ -219,6 +220,21 @@ class MainScreen extends StatelessWidget {
print('## Error: main screen route $mainRoute not defined'); print('## Error: main screen route $mainRoute not defined');
} }
final buttonColors = WindowButtonColors(
iconNormal: state.headerTextColor,
iconMouseOver: state.headerTextColor,
iconMouseDown: state.headerTextColor,
mouseOver: Color(prefState.enableDarkMode ? 0xFF222222 : 0xFFDDDDDD),
mouseDown: Color(prefState.enableDarkMode ? 0xFF333333 : 0xFFCCCCCC),
);
final closeButtonColors = WindowButtonColors(
iconNormal: state.headerTextColor,
iconMouseOver: Colors.white,
mouseOver: Color(0xFFD32F2F),
mouseDown: Color(0xFFB71C1C),
);
return WillPopScope( return WillPopScope(
onWillPop: () async { onWillPop: () async {
final state = store.state; final state = store.state;
@ -292,18 +308,54 @@ class MainScreen extends StatelessWidget {
child: SafeArea( child: SafeArea(
child: FocusTraversalGroup( child: FocusTraversalGroup(
policy: ReadingOrderTraversalPolicy(), policy: ReadingOrderTraversalPolicy(),
child: ChangeLayoutBanner( child: Column(
appLayout: prefState.appLayout, children: [
suggestedLayout: AppLayout.desktop, Material(
child: Row(children: <Widget>[ color: !prefState.enableDarkMode && state.hasAccentColor
if (prefState.showMenu) MenuDrawerBuilder(), ? state.accentColor
: null,
child: WindowTitleBarBox(
child: Row(
children: [
Expanded(
child: MoveWindow(
child: Row(
children: [
SizedBox(width: 6),
Image.asset('assets/images/icon.png',
width: 16),
SizedBox(width: 6),
Text(
'Invoice Ninja',
style:
TextStyle(color: state.headerTextColor),
),
],
),
)),
MinimizeWindowButton(colors: buttonColors),
MaximizeWindowButton(colors: buttonColors),
CloseWindowButton(colors: closeButtonColors),
],
),
),
),
Expanded( Expanded(
child: AppBorder( child: ChangeLayoutBanner(
child: screen, appLayout: prefState.appLayout,
isLeft: prefState.showMenu && suggestedLayout: AppLayout.desktop,
(!state.isFullScreen || showFilterSidebar), child: Row(children: <Widget>[
)), if (prefState.showMenu) MenuDrawerBuilder(),
]), Expanded(
child: AppBorder(
child: screen,
isLeft: prefState.showMenu &&
(!state.isFullScreen || showFilterSidebar),
)),
]),
),
),
],
), ),
), ),
), ),

View File

@ -6,10 +6,14 @@
#include "generated_plugin_registrant.h" #include "generated_plugin_registrant.h"
#include <bitsdojo_window_linux/bitsdojo_window_plugin.h>
#include <sentry_flutter/sentry_flutter_plugin.h> #include <sentry_flutter/sentry_flutter_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h> #include <url_launcher_linux/url_launcher_plugin.h>
void fl_register_plugins(FlPluginRegistry* registry) { void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) bitsdojo_window_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "BitsdojoWindowPlugin");
bitsdojo_window_plugin_register_with_registrar(bitsdojo_window_linux_registrar);
g_autoptr(FlPluginRegistrar) sentry_flutter_registrar = g_autoptr(FlPluginRegistrar) sentry_flutter_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "SentryFlutterPlugin"); fl_plugin_registry_get_registrar_for_plugin(registry, "SentryFlutterPlugin");
sentry_flutter_plugin_register_with_registrar(sentry_flutter_registrar); sentry_flutter_plugin_register_with_registrar(sentry_flutter_registrar);

View File

@ -3,6 +3,7 @@
# #
list(APPEND FLUTTER_PLUGIN_LIST list(APPEND FLUTTER_PLUGIN_LIST
bitsdojo_window_linux
sentry_flutter sentry_flutter
url_launcher_linux url_launcher_linux
) )

View File

@ -43,6 +43,41 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.8.2" 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"
boardview: boardview:
dependency: "direct main" dependency: "direct main"
description: description:

View File

@ -58,6 +58,7 @@ dependencies:
contacts_service: ^0.6.1 contacts_service: ^0.6.1
super_editor: ^0.1.0 super_editor: ^0.1.0
diacritic: ^0.1.3 diacritic: ^0.1.3
bitsdojo_window: ^0.1.1+1
# printing: ^5.6.3 # printing: ^5.6.3
# quick_actions: ^0.2.1 # quick_actions: ^0.2.1
# idb_shim: ^1.11.1+1 # idb_shim: ^1.11.1+1

View File

@ -6,11 +6,14 @@
#include "generated_plugin_registrant.h" #include "generated_plugin_registrant.h"
#include <bitsdojo_window_windows/bitsdojo_window_plugin.h>
#include <native_pdf_renderer/native_pdf_renderer_plugin.h> #include <native_pdf_renderer/native_pdf_renderer_plugin.h>
#include <sentry_flutter/sentry_flutter_plugin.h> #include <sentry_flutter/sentry_flutter_plugin.h>
#include <url_launcher_windows/url_launcher_windows.h> #include <url_launcher_windows/url_launcher_windows.h>
void RegisterPlugins(flutter::PluginRegistry* registry) { void RegisterPlugins(flutter::PluginRegistry* registry) {
BitsdojoWindowPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("BitsdojoWindowPlugin"));
NativePdfRendererPluginRegisterWithRegistrar( NativePdfRendererPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("NativePdfRendererPlugin")); registry->GetRegistrarForPlugin("NativePdfRendererPlugin"));
SentryFlutterPluginRegisterWithRegistrar( SentryFlutterPluginRegisterWithRegistrar(

View File

@ -3,6 +3,7 @@
# #
list(APPEND FLUTTER_PLUGIN_LIST list(APPEND FLUTTER_PLUGIN_LIST
bitsdojo_window_windows
native_pdf_renderer native_pdf_renderer
sentry_flutter sentry_flutter
url_launcher_windows url_launcher_windows

View File

@ -1,3 +1,6 @@
#include <bitsdojo_window_windows/bitsdojo_window_plugin.h>
auto bdw = bitsdojo_window_configure(BDW_CUSTOM_FRAME | BDW_HIDE_ON_STARTUP);
#include <flutter/dart_project.h> #include <flutter/dart_project.h>
#include <flutter/flutter_view_controller.h> #include <flutter/flutter_view_controller.h>
#include <windows.h> #include <windows.h>