mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-18 03:36:34 -07:00
fix(Desktop): Small improvement to padding and titlebar
This commit is contained in:
parent
3b4b8a9101
commit
4371368fda
3 changed files with 125 additions and 109 deletions
|
|
@ -106,7 +106,7 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
|
|||
child: HomeBannerWidget(posters: homeCarouselItems),
|
||||
),
|
||||
),
|
||||
} else if (AdaptiveLayout.of(context).isDesktop)
|
||||
},
|
||||
const DefaultSliverTopBadding(),
|
||||
if (AdaptiveLayout.of(context).isDesktop)
|
||||
const SliverToBoxAdapter(
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ class DefaultTitleBar extends ConsumerStatefulWidget {
|
|||
}
|
||||
|
||||
class _DefaultTitleBarState extends ConsumerState<DefaultTitleBar> with WindowListener {
|
||||
bool hovering = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
windowManager.addListener(this);
|
||||
|
|
@ -40,7 +42,14 @@ class _DefaultTitleBarState extends ConsumerState<DefaultTitleBar> with WindowLi
|
|||
]
|
||||
: <BoxShadow>[];
|
||||
final iconColor = Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.65);
|
||||
return SizedBox(
|
||||
return MouseRegion(
|
||||
onEnter: (event) => setState(() => hovering = true),
|
||||
onExit: (event) => setState(() => hovering = false),
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 250),
|
||||
decoration: BoxDecoration(
|
||||
color: hovering ? Colors.black.withValues(alpha: 0.15) : Colors.transparent,
|
||||
),
|
||||
height: widget.height,
|
||||
child: switch (AdaptiveLayout.of(context).platform) {
|
||||
TargetPlatform.android || TargetPlatform.iOS => SizedBox(height: MediaQuery.paddingOf(context).top),
|
||||
|
|
@ -71,10 +80,13 @@ class _DefaultTitleBarState extends ConsumerState<DefaultTitleBar> with WindowLi
|
|||
),
|
||||
Row(
|
||||
children: [
|
||||
FutureBuilder(
|
||||
future: windowManager.isMinimizable(),
|
||||
builder: (context, data) {
|
||||
final isMinimized = !(data.data ?? false);
|
||||
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
|
||||
|
|
@ -82,6 +94,9 @@ class _DefaultTitleBarState extends ConsumerState<DefaultTitleBar> with WindowLi
|
|||
: 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 {
|
||||
|
|
@ -169,6 +184,7 @@ class _DefaultTitleBarState extends ConsumerState<DefaultTitleBar> with WindowLi
|
|||
TargetPlatform.macOS => const SizedBox.shrink(),
|
||||
_ => Text(widget.label ?? "Fladder"),
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ class DefaultSliverTopBadding extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return (AdaptiveLayout.viewSizeOf(context) != ViewSize.phone)
|
||||
? const SliverPadding(padding: EdgeInsets.only(top: 35))
|
||||
return (AdaptiveLayout.viewSizeOf(context) == ViewSize.phone)
|
||||
? const SliverToBoxAdapter()
|
||||
: SliverPadding(padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue