mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-09 07:28:14 -07:00
fix: Small web fixes
This commit is contained in:
parent
64e49ce579
commit
c271e05a6e
2 changed files with 131 additions and 127 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
|
@ -51,139 +52,141 @@ class _DefaultTitleBarState extends ConsumerState<DefaultTitleBar> with WindowLi
|
||||||
color: hovering ? Colors.black.withValues(alpha: 0.15) : Colors.transparent,
|
color: hovering ? Colors.black.withValues(alpha: 0.15) : Colors.transparent,
|
||||||
),
|
),
|
||||||
height: widget.height,
|
height: widget.height,
|
||||||
child: switch (AdaptiveLayout.of(context).platform) {
|
child: kIsWeb
|
||||||
TargetPlatform.android || TargetPlatform.iOS => SizedBox(height: MediaQuery.paddingOf(context).top),
|
? const SizedBox.shrink()
|
||||||
TargetPlatform.windows || TargetPlatform.linux => Row(
|
: switch (AdaptiveLayout.of(context).platform) {
|
||||||
children: [
|
TargetPlatform.android || TargetPlatform.iOS => SizedBox(height: MediaQuery.paddingOf(context).top),
|
||||||
Expanded(
|
TargetPlatform.windows || TargetPlatform.linux => Row(
|
||||||
child: Container(
|
children: [
|
||||||
color: Colors.black.withValues(alpha: 0),
|
Expanded(
|
||||||
child: DragToMoveArea(
|
child: Container(
|
||||||
child: Row(
|
color: Colors.black.withValues(alpha: 0),
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
child: DragToMoveArea(
|
||||||
mainAxisSize: MainAxisSize.max,
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.only(left: 16),
|
||||||
|
child: DefaultTextStyle(
|
||||||
|
style: TextStyle(
|
||||||
|
color: iconColor,
|
||||||
|
fontSize: 14,
|
||||||
|
),
|
||||||
|
child: Text(widget.label ?? ""),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
FutureBuilder<List<bool>>(future: Future.microtask(() async {
|
||||||
padding: const EdgeInsets.only(left: 16),
|
final isMinimized = await windowManager.isMinimized();
|
||||||
child: DefaultTextStyle(
|
final isFullScreen = await windowManager.isFullScreen();
|
||||||
style: TextStyle(
|
return [isMinimized, isFullScreen];
|
||||||
color: iconColor,
|
}), builder: (context, snapshot) {
|
||||||
fontSize: 14,
|
final isMinimized = snapshot.data?.firstOrNull ?? false;
|
||||||
|
final fullScreen = snapshot.data?.lastOrNull ?? false;
|
||||||
|
return IconButton(
|
||||||
|
style: IconButton.styleFrom(
|
||||||
|
hoverColor: brightness == Brightness.light
|
||||||
|
? Colors.black.withValues(alpha: 0.1)
|
||||||
|
: Colors.white.withValues(alpha: 0.2),
|
||||||
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(2))),
|
||||||
|
onPressed: () async {
|
||||||
|
if (fullScreen) {
|
||||||
|
await windowManager.setFullScreen(false);
|
||||||
|
}
|
||||||
|
if (isMinimized) {
|
||||||
|
windowManager.restore();
|
||||||
|
} else {
|
||||||
|
windowManager.minimize();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
icon: Transform.translate(
|
||||||
|
offset: const Offset(0, -2),
|
||||||
|
child: Icon(
|
||||||
|
Icons.minimize_rounded,
|
||||||
|
color: iconColor,
|
||||||
|
size: 20,
|
||||||
|
shadows: shadows,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
FutureBuilder<List<bool>>(
|
||||||
|
future: Future.microtask(() async {
|
||||||
|
final isMaximized = await windowManager.isMaximized();
|
||||||
|
final isFullScreen = await windowManager.isFullScreen();
|
||||||
|
return [isMaximized, isFullScreen];
|
||||||
|
}),
|
||||||
|
builder: (BuildContext context, AsyncSnapshot<List<bool>> snapshot) {
|
||||||
|
final maximized = snapshot.data?.firstOrNull ?? false;
|
||||||
|
final fullScreen = snapshot.data?.lastOrNull ?? false;
|
||||||
|
return IconButton(
|
||||||
|
style: IconButton.styleFrom(
|
||||||
|
hoverColor: brightness == Brightness.light
|
||||||
|
? Colors.black.withValues(alpha: 0.1)
|
||||||
|
: Colors.white.withValues(alpha: 0.2),
|
||||||
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(2)),
|
||||||
|
),
|
||||||
|
onPressed: () async {
|
||||||
|
if (fullScreen && maximized) {
|
||||||
|
await windowManager.setFullScreen(false);
|
||||||
|
await windowManager.unmaximize();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fullScreen) {
|
||||||
|
await windowManager.setFullScreen(false);
|
||||||
|
} else if (!maximized) {
|
||||||
|
await windowManager.maximize();
|
||||||
|
} else {
|
||||||
|
await windowManager.unmaximize();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
icon: Transform.translate(
|
||||||
|
offset: const Offset(0, 0),
|
||||||
|
child: Icon(
|
||||||
|
maximized ? Icons.maximize_rounded : Icons.crop_square_rounded,
|
||||||
|
color: iconColor,
|
||||||
|
size: 19,
|
||||||
|
shadows: shadows,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
style: IconButton.styleFrom(
|
||||||
|
hoverColor: Colors.red,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(2),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onPressed: () async {
|
||||||
|
windowManager.close();
|
||||||
|
},
|
||||||
|
icon: Transform.translate(
|
||||||
|
offset: const Offset(0, -2),
|
||||||
|
child: Icon(
|
||||||
|
Icons.close_rounded,
|
||||||
|
color: iconColor,
|
||||||
|
size: 23,
|
||||||
|
shadows: shadows,
|
||||||
),
|
),
|
||||||
child: Text(widget.label ?? ""),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
),
|
TargetPlatform.macOS => const SizedBox.shrink(),
|
||||||
Row(
|
_ => Text(widget.label ?? "Fladder"),
|
||||||
children: [
|
},
|
||||||
FutureBuilder<List<bool>>(future: Future.microtask(() async {
|
|
||||||
final isMinimized = await windowManager.isMinimized();
|
|
||||||
final isFullScreen = await windowManager.isFullScreen();
|
|
||||||
return [isMinimized, isFullScreen];
|
|
||||||
}), builder: (context, snapshot) {
|
|
||||||
final isMinimized = snapshot.data?.firstOrNull ?? false;
|
|
||||||
final fullScreen = snapshot.data?.lastOrNull ?? false;
|
|
||||||
return IconButton(
|
|
||||||
style: IconButton.styleFrom(
|
|
||||||
hoverColor: brightness == Brightness.light
|
|
||||||
? Colors.black.withValues(alpha: 0.1)
|
|
||||||
: Colors.white.withValues(alpha: 0.2),
|
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(2))),
|
|
||||||
onPressed: () async {
|
|
||||||
if (fullScreen) {
|
|
||||||
await windowManager.setFullScreen(false);
|
|
||||||
}
|
|
||||||
if (isMinimized) {
|
|
||||||
windowManager.restore();
|
|
||||||
} else {
|
|
||||||
windowManager.minimize();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
icon: Transform.translate(
|
|
||||||
offset: const Offset(0, -2),
|
|
||||||
child: Icon(
|
|
||||||
Icons.minimize_rounded,
|
|
||||||
color: iconColor,
|
|
||||||
size: 20,
|
|
||||||
shadows: shadows,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
FutureBuilder<List<bool>>(
|
|
||||||
future: Future.microtask(() async {
|
|
||||||
final isMaximized = await windowManager.isMaximized();
|
|
||||||
final isFullScreen = await windowManager.isFullScreen();
|
|
||||||
return [isMaximized, isFullScreen];
|
|
||||||
}),
|
|
||||||
builder: (BuildContext context, AsyncSnapshot<List<bool>> snapshot) {
|
|
||||||
final maximized = snapshot.data?.firstOrNull ?? false;
|
|
||||||
final fullScreen = snapshot.data?.lastOrNull ?? false;
|
|
||||||
return IconButton(
|
|
||||||
style: IconButton.styleFrom(
|
|
||||||
hoverColor: brightness == Brightness.light
|
|
||||||
? Colors.black.withValues(alpha: 0.1)
|
|
||||||
: Colors.white.withValues(alpha: 0.2),
|
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(2)),
|
|
||||||
),
|
|
||||||
onPressed: () async {
|
|
||||||
if (fullScreen && maximized) {
|
|
||||||
await windowManager.setFullScreen(false);
|
|
||||||
await windowManager.unmaximize();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fullScreen) {
|
|
||||||
await windowManager.setFullScreen(false);
|
|
||||||
} else if (!maximized) {
|
|
||||||
await windowManager.maximize();
|
|
||||||
} else {
|
|
||||||
await windowManager.unmaximize();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
icon: Transform.translate(
|
|
||||||
offset: const Offset(0, 0),
|
|
||||||
child: Icon(
|
|
||||||
maximized ? Icons.maximize_rounded : Icons.crop_square_rounded,
|
|
||||||
color: iconColor,
|
|
||||||
size: 19,
|
|
||||||
shadows: shadows,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
style: IconButton.styleFrom(
|
|
||||||
hoverColor: Colors.red,
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(2),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onPressed: () async {
|
|
||||||
windowManager.close();
|
|
||||||
},
|
|
||||||
icon: Transform.translate(
|
|
||||||
offset: const Offset(0, -2),
|
|
||||||
child: Icon(
|
|
||||||
Icons.close_rounded,
|
|
||||||
color: iconColor,
|
|
||||||
size: 23,
|
|
||||||
shadows: shadows,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
TargetPlatform.macOS => const SizedBox.shrink(),
|
|
||||||
_ => Text(widget.label ?? "Fladder"),
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,8 @@ import 'package:fladder/util/input_handler.dart';
|
||||||
import 'package:fladder/util/list_padding.dart';
|
import 'package:fladder/util/list_padding.dart';
|
||||||
import 'package:fladder/util/localization_helper.dart';
|
import 'package:fladder/util/localization_helper.dart';
|
||||||
import 'package:fladder/util/string_extensions.dart';
|
import 'package:fladder/util/string_extensions.dart';
|
||||||
import 'package:fladder/widgets/shared/full_screen_button.dart';
|
import 'package:fladder/widgets/shared/full_screen_button.dart'
|
||||||
|
if (dart.library.html) 'package:fladder/widgets/shared/full_screen_button_web.dart';
|
||||||
|
|
||||||
class DesktopControls extends ConsumerStatefulWidget {
|
class DesktopControls extends ConsumerStatefulWidget {
|
||||||
const DesktopControls({super.key});
|
const DesktopControls({super.key});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue