mac toolbar button

This commit is contained in:
wanghongenpin
2025-08-17 08:49:44 +08:00
parent ac0e905cb7
commit 9368391cef
9 changed files with 38 additions and 15 deletions

View File

@@ -18,6 +18,7 @@ import 'dart:convert';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:macos_window_utils/macos/ns_window_button_type.dart';
import 'package:proxypin/network/bin/configuration.dart';
import 'package:proxypin/ui/component/chinese_font.dart';
import 'package:proxypin/ui/component/multi_window.dart';
@@ -28,6 +29,7 @@ import 'package:proxypin/ui/mobile/mobile.dart';
import 'package:proxypin/utils/navigator.dart';
import 'package:proxypin/utils/platform.dart';
import 'package:window_manager/window_manager.dart';
import 'package:macos_window_utils/macos_window_utils.dart';
import 'l10n/app_localizations.dart';
@@ -70,7 +72,18 @@ void main(List<String> args) async {
windowManager.setBrightness(appConfiguration.themeMode == ThemeMode.dark ? Brightness.dark : Brightness.light);
}
windowManager.waitUntilReadyToShow(windowOptions, () async {
if (Platform.isMacOS) {
await WindowManipulator.initialize();
// 调整关闭按钮的位置
WindowManipulator.overrideStandardWindowButtonPosition(
buttonType: NSWindowButtonType.closeButton, offset: Offset(10, 16));
WindowManipulator.overrideStandardWindowButtonPosition(
buttonType: NSWindowButtonType.miniaturizeButton, offset: const Offset(29, 16));
WindowManipulator.overrideStandardWindowButtonPosition(
buttonType: NSWindowButtonType.zoomButton, offset: const Offset(48, 16));
}
await windowManager.waitUntilReadyToShow(windowOptions, () async {
if (windowPosition != null) {
await windowManager.setPosition(windowPosition);
}
@@ -116,7 +129,7 @@ class FluentApp extends StatelessWidget {
bool isDark = brightness == Brightness.dark;
Color? themeColor = isDark ? appConfiguration.themeColor : appConfiguration.themeColor;
Color? cardColor = isDark ? Colors.grey[850]! : Colors.white;
Color? cardColor = isDark ? Color(0XFF3C3C3C) : Colors.white;
Color? surfaceContainer = isDark ? Colors.grey[800] : Colors.white;
Color? secondary = useMaterial3 ? null : themeColor;

View File

@@ -114,6 +114,7 @@ class NetworkTabState extends State<NetworkTabController> with SingleTickerProvi
var tabBar = TabBar(
padding: const EdgeInsets.only(bottom: 0),
controller: _tabController,
dividerColor: Theme.of(context).dividerColor.withOpacity(0.15),
labelPadding: const EdgeInsets.symmetric(horizontal: 10),
tabs: tabs.map((title) => Tab(child: Text(title, style: widget.tabStyle, maxLines: 1))).toList(),
);

View File

@@ -109,7 +109,12 @@ class _DesktopHomePagePageState extends State<DesktopHomePage> implements EventL
];
return Scaffold(
appBar: Tab(child: Toolbar(proxyServer, requestListStateKey, sideNotifier: _selectIndex)),
appBar: Tab(
child: Container(
decoration: BoxDecoration(
border: Border(bottom: BorderSide(color: Theme.of(context).dividerColor.withOpacity(0.25), width: 0.2))),
child: Toolbar(proxyServer, requestListStateKey, sideNotifier: _selectIndex),
)),
body: Row(
children: [
LeftNavigationBar(

View File

@@ -42,19 +42,19 @@ class _LeftNavigationBarState extends State<LeftNavigationBar> {
List<NavigationRailDestination> get destinations => [
NavigationRailDestination(
padding: const EdgeInsets.only(bottom: 3),
padding: const EdgeInsets.only(bottom: 5),
icon: Icon(Icons.workspaces_outlined),
label: Text(localizations.requests, style: Theme.of(context).textTheme.bodySmall)),
NavigationRailDestination(
padding: const EdgeInsets.only(bottom: 3),
padding: const EdgeInsets.only(bottom: 5),
icon: Icon(Icons.favorite_outline_outlined),
label: Text(localizations.favorites, style: Theme.of(context).textTheme.bodySmall)),
NavigationRailDestination(
padding: const EdgeInsets.only(bottom: 3),
padding: const EdgeInsets.only(bottom: 5),
icon: Icon(Icons.history_outlined),
label: Text(localizations.history, style: Theme.of(context).textTheme.bodySmall)),
NavigationRailDestination(
padding: const EdgeInsets.only(bottom: 3),
padding: const EdgeInsets.only(bottom: 5),
icon: Icon(Icons.hardware_outlined),
label: Text(localizations.toolbox, style: Theme.of(context).textTheme.bodySmall)),
];
@@ -69,7 +69,7 @@ class _LeftNavigationBarState extends State<LeftNavigationBar> {
}
return Container(
width: localizations.localeName == 'en' ? 68 : 55,
width: localizations.localeName == 'en' ? 70 : 57,
decoration:
BoxDecoration(border: Border(right: BorderSide(color: Theme.of(context).dividerColor, width: 0.2))),
child: Column(children: <Widget>[
@@ -110,10 +110,11 @@ class _LeftNavigationBarState extends State<LeftNavigationBar> {
//left menu eg: requests, favorites, history, toolbox
Widget leftNavigation(int index) {
return NavigationRail(
minWidth: 55,
minWidth: 57,
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
selectedIconTheme: IconTheme.of(context).copyWith(color: Theme.of(context).colorScheme.primary, size: 22),
unselectedIconTheme: IconTheme.of(context).copyWith(color: Colors.black54, size: 22),
unselectedIconTheme:
IconTheme.of(context).copyWith(color: IconTheme.of(context).color?.withOpacity(0.55), size: 22),
labelType: NavigationRailLabelType.all,
destinations: destinations,
selectedIndex: index,

View File

@@ -91,7 +91,7 @@ class DesktopRequestListState extends State<DesktopRequestListWidget> with Autom
child: Scaffold(
appBar: AppBar(
toolbarHeight: 40,
title: SizedBox(height: 40, child: TabBar(tabs: tabs)),
title: SizedBox(height: 40, child: TabBar(tabs: tabs, dividerColor: Colors.transparent)),
automaticallyImplyLeading: false,
actions: [popupMenus()],
),

View File

@@ -10,6 +10,7 @@ import device_info_plus
import file_picker
import flutter_desktop_context_menu
import flutter_js
import macos_window_utils
import path_provider_foundation
import proxy_manager
import screen_retriever_macos
@@ -25,6 +26,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FilePickerPlugin.register(with: registry.registrar(forPlugin: "FilePickerPlugin"))
FlutterDesktopContextMenuPlugin.register(with: registry.registrar(forPlugin: "FlutterDesktopContextMenuPlugin"))
FlutterJsPlugin.register(with: registry.registrar(forPlugin: "FlutterJsPlugin"))
MacOSWindowUtilsPlugin.register(with: registry.registrar(forPlugin: "MacOSWindowUtilsPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
ProxyManagerPlugin.register(with: registry.registrar(forPlugin: "ProxyManagerPlugin"))
ScreenRetrieverMacosPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverMacosPlugin"))

View File

@@ -1,4 +1,4 @@
platform :osx, '10.14'
platform :osx, '10.15'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

View File

@@ -592,7 +592,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MACOSX_DEPLOYMENT_TARGET = 10.15;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
@@ -685,7 +685,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MACOSX_DEPLOYMENT_TARGET = 10.15;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
@@ -734,7 +734,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MACOSX_DEPLOYMENT_TARGET = 10.15;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;

View File

@@ -47,6 +47,7 @@ dependencies:
brotli: ^0.6.0
macos_window_utils: ^1.8.4
win32audio: ^1.3.1
vclibs: ^0.1.3