mirror of
https://github.com/foss42/apidash.git
synced 2025-06-02 07:46:10 +08:00
Platform specific constants and changes
This commit is contained in:
@ -9,6 +9,11 @@ const kDiscordUrl = "https://bit.ly/heyfoss";
|
||||
const kGitUrl = "https://github.com/foss42/api-dash";
|
||||
const kIssueUrl = "$kGitUrl/issues";
|
||||
|
||||
final kIsMacOS = Platform.isMacOS;
|
||||
final kIsWindows = Platform.isWindows;
|
||||
final kIsLinux = Platform.isLinux;
|
||||
final kIsDesktop = kIsMacOS || kIsWindows || kIsLinux;
|
||||
|
||||
final kColorTransparentState =
|
||||
MaterialStateProperty.all<Color>(Colors.transparent);
|
||||
const kColorTransparent = Colors.transparent;
|
||||
@ -46,6 +51,7 @@ const kPs8 = EdgeInsets.only(left: 8);
|
||||
const kPh20v5 = EdgeInsets.symmetric(horizontal: 20, vertical: 5);
|
||||
const kPh20v10 = EdgeInsets.symmetric(horizontal: 20, vertical: 10);
|
||||
const kP10 = EdgeInsets.all(10);
|
||||
const kPt24o8 = EdgeInsets.only(top: 24, left: 8.0, right: 8.0, bottom: 8.0);
|
||||
const kPt5o10 =
|
||||
EdgeInsets.only(left: 10.0, right: 10.0, top: 5.0, bottom: 10.0);
|
||||
|
||||
|
@ -31,7 +31,7 @@ class _CollectionPaneState extends ConsumerState<CollectionPane> {
|
||||
);
|
||||
}
|
||||
return Padding(
|
||||
padding: kP8,
|
||||
padding: kIsMacOS ? kPt24o8 : kP8,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
|
@ -28,7 +28,7 @@ class _RequestEditorPaneState extends ConsumerState<RequestEditorPane> {
|
||||
return const RequestEditorPaneHome();
|
||||
} else {
|
||||
return Padding(
|
||||
padding: kP8,
|
||||
padding: kIsMacOS ? kPt24o8 : kP8,
|
||||
child: Column(
|
||||
children: const [
|
||||
EditorPaneRequestURLCard(),
|
||||
|
@ -1,4 +1,3 @@
|
||||
import 'dart:io';
|
||||
import 'dart:math' as math;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
@ -7,16 +6,15 @@ import 'package:window_manager/window_manager.dart';
|
||||
import '../consts.dart';
|
||||
|
||||
Future<void> setupInitialWindow(Size? sz) async {
|
||||
if (!kIsWeb) {
|
||||
if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) {
|
||||
if (!kIsWeb && kIsDesktop) {
|
||||
await window_size.getWindowInfo().then((window) {
|
||||
final screen = window.screen;
|
||||
if (screen != null) {
|
||||
final screenFrame = screen.visibleFrame;
|
||||
double width, height;
|
||||
if (sz == null) {
|
||||
width = math.max((screenFrame.width / 2).roundToDouble(),
|
||||
kMinInitialWindowWidth);
|
||||
width = math.max(
|
||||
(screenFrame.width / 2).roundToDouble(), kMinInitialWindowWidth);
|
||||
height = math.max((screenFrame.height / 2).roundToDouble(),
|
||||
kMinInitialWindowHeight);
|
||||
} else {
|
||||
@ -34,23 +32,21 @@ Future<void> setupInitialWindow(Size? sz) async {
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> resetWindowSize() async {
|
||||
await setupWindow(center: true);
|
||||
}
|
||||
|
||||
Future<void> setupWindow({Size? sz, Offset? off, bool center = false}) async {
|
||||
if (!kIsWeb) {
|
||||
if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) {
|
||||
if (!kIsWeb && kIsDesktop) {
|
||||
double width = kMinInitialWindowWidth, height = kMinInitialWindowHeight;
|
||||
if (sz == null) {
|
||||
await window_size.getWindowInfo().then((window) {
|
||||
final screen = window.screen;
|
||||
if (screen != null) {
|
||||
final screenFrame = screen.visibleFrame;
|
||||
width = math.max((screenFrame.width / 2).roundToDouble(),
|
||||
kMinInitialWindowWidth);
|
||||
width = math.max(
|
||||
(screenFrame.width / 2).roundToDouble(), kMinInitialWindowWidth);
|
||||
height = math.max((screenFrame.height / 2).roundToDouble(),
|
||||
kMinInitialWindowHeight);
|
||||
}
|
||||
@ -67,16 +63,14 @@ Future<void> setupWindow({Size? sz, Offset? off, bool center = false}) async {
|
||||
minimumSize: kMinWindowSize,
|
||||
skipTaskbar: false,
|
||||
title: kWindowTitle,
|
||||
titleBarStyle: Platform.isMacOS ? TitleBarStyle.hidden : null,
|
||||
titleBarStyle: kIsMacOS ? TitleBarStyle.hidden : null,
|
||||
);
|
||||
if (off != null) {
|
||||
await windowManager.setPosition(off);
|
||||
}
|
||||
|
||||
windowManager.waitUntilReadyToShow(windowOptions, () async {
|
||||
await windowManager.show();
|
||||
await windowManager.focus();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user