feat: tabbed settings dialog (pill tabs, full-bleed panel), hover color setting, title bar grab cursor (v1.9.2)
This commit is contained in:
1 parent
1a6de71ff6
commit
701eafa744
12 files changed
+1064
-221
No files matched your search
@@ -1,13 +1,22 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
|
||||
class CustomTitleBar extends StatelessWidget {
|
||||
import '../services/hover_color.dart';
|
||||
|
||||
class CustomTitleBar extends StatefulWidget {
|
||||
final VoidCallback? onSettings;
|
||||
final VoidCallback? onSaveCrop;
|
||||
final bool visible;
|
||||
|
||||
const CustomTitleBar({super.key, this.onSettings, this.onSaveCrop, this.visible = true});
|
||||
|
||||
@override
|
||||
State<CustomTitleBar> createState() => _CustomTitleBarState();
|
||||
}
|
||||
|
||||
class _CustomTitleBarState extends State<CustomTitleBar> {
|
||||
bool _barHovered = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Positioned(
|
||||
@@ -15,55 +24,66 @@ class CustomTitleBar extends StatelessWidget {
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: AnimatedOpacity(
|
||||
opacity: visible ? 1.0 : 0.0,
|
||||
opacity: widget.visible ? 1.0 : 0.0,
|
||||
duration: const Duration(milliseconds: 150),
|
||||
child: DragToMoveArea(
|
||||
child: SizedBox(
|
||||
height: 24,
|
||||
child: Stack(
|
||||
children: [
|
||||
if (onSettings != null)
|
||||
Positioned(
|
||||
left: 0,
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
_BarButton(
|
||||
icon: Icons.settings,
|
||||
onTap: onSettings!,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
right: 0,
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
child: MouseRegion(
|
||||
cursor: SystemMouseCursors.grab,
|
||||
onEnter: (_) => setState(() => _barHovered = true),
|
||||
onExit: (_) => setState(() => _barHovered = false),
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 120),
|
||||
color: _barHovered
|
||||
? Colors.white.withValues(alpha: 0.06)
|
||||
: Colors.transparent,
|
||||
child: DragToMoveArea(
|
||||
child: SizedBox(
|
||||
height: 24,
|
||||
child: Stack(
|
||||
children: [
|
||||
if (onSaveCrop != null)
|
||||
_BarButton(
|
||||
icon: Icons.save_outlined,
|
||||
onTap: onSaveCrop!,
|
||||
Positioned(
|
||||
left: 0,
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (widget.onSettings != null)
|
||||
_BarButton(
|
||||
icon: Icons.settings,
|
||||
onTap: widget.onSettings!,
|
||||
),
|
||||
if (widget.onSaveCrop != null)
|
||||
_BarButton(
|
||||
icon: Icons.save_outlined,
|
||||
onTap: widget.onSaveCrop!,
|
||||
),
|
||||
],
|
||||
),
|
||||
_BarButton(
|
||||
icon: Icons.horizontal_rule,
|
||||
onTap: () => windowManager.minimize(),
|
||||
),
|
||||
_BarButton(
|
||||
icon: Icons.close,
|
||||
onTap: () => windowManager.close(),
|
||||
Positioned(
|
||||
right: 0,
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
_BarButton(
|
||||
icon: Icons.horizontal_rule,
|
||||
onTap: () => windowManager.minimize(),
|
||||
),
|
||||
_BarButton(
|
||||
icon: Icons.close,
|
||||
onTap: () => windowManager.close(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -93,14 +113,17 @@ class _BarButtonState extends State<_BarButton> {
|
||||
cursor: SystemMouseCursors.click,
|
||||
onEnter: (_) => setState(() => _hovered = true),
|
||||
onExit: (_) => setState(() => _hovered = false),
|
||||
child: Container(
|
||||
width: 32,
|
||||
height: 24,
|
||||
color: _hovered ? Colors.red.withValues(alpha: 0.8) : Colors.transparent,
|
||||
child: Icon(
|
||||
widget.icon,
|
||||
color: Colors.white,
|
||||
size: 14,
|
||||
child: ValueListenableBuilder<Color>(
|
||||
valueListenable: HoverColor.notifier,
|
||||
builder: (context, hover, _) => Container(
|
||||
width: 32,
|
||||
height: 24,
|
||||
color: _hovered ? hover.withValues(alpha: 0.8) : Colors.transparent,
|
||||
child: Icon(
|
||||
widget.icon,
|
||||
color: Colors.white,
|
||||
size: 14,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../l10n/app_localizations.dart';
|
||||
import '../services/hover_color.dart';
|
||||
|
||||
/// Ekran oranı buton ızgarası: 31 buton `a:b` (a dikeyi, b yatayı böler;
|
||||
/// hedef boyut `W/b × H/a`). Sol-üst hücre (1:1) boş placeholder — 1:1 yok
|
||||
/// (title bar çift tık zaten tam ekran).
|
||||
/// hedef boyut `W/b × H/a`). Sol-üst hücre `H:W` etiketi — buton değil
|
||||
/// (1:1 yok: title bar çift tık zaten tam ekran).
|
||||
///
|
||||
/// Yerleşim: sabit 8 satır × 4 sütun (31-10: geniş/dar transpozesi
|
||||
/// kaldırıldı — kullanıcı kararı).
|
||||
/// Yerleşim: 8 satır × 4 sütun; hücreler mevcut alanı kaplayacak şekilde
|
||||
/// esner (pencere/sekme alanı büyüdükçe butonlar büyür).
|
||||
class WindowSizeSelector extends StatelessWidget {
|
||||
final Future<Size?> Function() workArea;
|
||||
final void Function(int rows, int cols, Size work) onPick;
|
||||
@@ -21,57 +21,89 @@ class WindowSizeSelector extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(AppLocalizations.of(context)!.sizeSection,
|
||||
style: const TextStyle(color: Colors.white70, fontSize: 13)),
|
||||
const SizedBox(height: 4),
|
||||
SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [for (var b = 1; b <= 8; b++) _row(b)],
|
||||
for (var b = 1; b <= 8; b++)
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
for (var a = 1; a <= 4; a++) Expanded(child: _cell(a, b)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// Satır = `b` (1..8, yatay bölün); satır içinde `a` (1..4, dikey bölün).
|
||||
Widget _row(int b) {
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
for (var a = 1; a <= 4; a++) _cell(a, b),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _cell(int a, int b) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(right: 4, bottom: 4),
|
||||
padding: const EdgeInsets.only(right: 3, bottom: 3),
|
||||
child: a == 1 && b == 1
|
||||
? const SizedBox(width: 46, height: 26)
|
||||
: GestureDetector(
|
||||
? _gridLabel('H:W')
|
||||
: _SizeCell(
|
||||
a: a,
|
||||
b: b,
|
||||
onTap: () async {
|
||||
final work = await workArea();
|
||||
if (work != null) onPick(a, b, work);
|
||||
},
|
||||
child: Container(
|
||||
width: 46,
|
||||
height: 26,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white10,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
'$a:$b',
|
||||
style: const TextStyle(color: Colors.white, fontSize: 11),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _gridLabel(String text) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white10,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
text,
|
||||
style: const TextStyle(color: Colors.white54, fontSize: 11),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _SizeCell extends StatefulWidget {
|
||||
final int a;
|
||||
final int b;
|
||||
final VoidCallback onTap;
|
||||
|
||||
const _SizeCell({required this.a, required this.b, required this.onTap});
|
||||
|
||||
@override
|
||||
State<_SizeCell> createState() => _SizeCellState();
|
||||
}
|
||||
|
||||
class _SizeCellState extends State<_SizeCell> {
|
||||
bool _hover = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MouseRegion(
|
||||
cursor: SystemMouseCursors.click,
|
||||
onEnter: (_) => setState(() => _hover = true),
|
||||
onExit: (_) => setState(() => _hover = false),
|
||||
child: GestureDetector(
|
||||
onTap: widget.onTap,
|
||||
child: ValueListenableBuilder<Color>(
|
||||
valueListenable: HoverColor.notifier,
|
||||
builder: (context, hover, _) => AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 100),
|
||||
decoration: BoxDecoration(
|
||||
color: _hover ? hover.withValues(alpha: 0.4) : Colors.white10,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
'${widget.a}:${widget.b}',
|
||||
style: const TextStyle(color: Colors.white, fontSize: 12),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user