mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-09 15:38:13 -07:00
feature(web): Added full-screen button and volume slider (#50)
## Pull Request Description Adds the full screen toggle to web and the volume slider. fix: small fixes for desktop padding fix: only reload widgets when the content has changed ## Issue Being Fixed Issue Number: #28 --------- Co-authored-by: PartyDonut <PartyDonut@users.noreply.github.com>
This commit is contained in:
parent
da9e0423c8
commit
8e2ce7861b
7 changed files with 359 additions and 250 deletions
|
|
@ -123,7 +123,8 @@ class _NavigationBodyState extends ConsumerState<NavigationBody> {
|
|||
Flexible(
|
||||
child: Padding(
|
||||
key: const Key('navigation_rail'),
|
||||
padding: MediaQuery.paddingOf(context).copyWith(right: 0),
|
||||
padding:
|
||||
MediaQuery.paddingOf(context).copyWith(right: 0, top: AdaptiveLayout.of(context).isDesktop ? 8 : null),
|
||||
child: Column(
|
||||
children: [
|
||||
IconButton(
|
||||
|
|
|
|||
|
|
@ -41,9 +41,8 @@ class NestedNavigationDrawer extends ConsumerWidget {
|
|||
backgroundColor: isExpanded ? Colors.transparent : null,
|
||||
surfaceTintColor: isExpanded ? Colors.transparent : null,
|
||||
children: [
|
||||
if (AdaptiveLayout.of(context).isDesktop || kIsWeb) const SizedBox(height: 16),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(28, 16, 16, 0),
|
||||
padding: EdgeInsets.fromLTRB(28, AdaptiveLayout.of(context).isDesktop ? 0 : 16, 16, 0),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
|
|
|
|||
44
lib/widgets/shared/full_screen_button.dart
Normal file
44
lib/widgets/shared/full_screen_button.dart
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:ficonsax/ficonsax.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
|
||||
class FullScreenButton extends StatefulWidget {
|
||||
const FullScreenButton({super.key});
|
||||
|
||||
@override
|
||||
State<FullScreenButton> createState() => _FullScreenButtonState();
|
||||
}
|
||||
|
||||
class _FullScreenButtonState extends State<FullScreenButton> {
|
||||
bool isFullScreen = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
Future.microtask(checkFullScreen);
|
||||
}
|
||||
|
||||
void checkFullScreen() async {
|
||||
final fullScreen = await windowManager.isFullScreen();
|
||||
setState(() {
|
||||
isFullScreen = fullScreen;
|
||||
});
|
||||
log(isFullScreen.toString());
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return IconButton(
|
||||
onPressed: () async {
|
||||
await windowManager.setFullScreen(!isFullScreen);
|
||||
checkFullScreen();
|
||||
},
|
||||
icon: Icon(
|
||||
isFullScreen ? IconsaxOutline.close_square : IconsaxOutline.maximize_4,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
49
lib/widgets/shared/full_screen_button_web.dart
Normal file
49
lib/widgets/shared/full_screen_button_web.dart
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:ficonsax/ficonsax.dart';
|
||||
import 'package:universal_html/html.dart' as html;
|
||||
|
||||
class FullScreenButton extends StatefulWidget {
|
||||
const FullScreenButton({super.key});
|
||||
|
||||
@override
|
||||
State<FullScreenButton> createState() => _FullScreenButtonState();
|
||||
}
|
||||
|
||||
class _FullScreenButtonState extends State<FullScreenButton> {
|
||||
bool fullScreen = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_updateFullScreenStatus();
|
||||
}
|
||||
|
||||
void _updateFullScreenStatus() {
|
||||
setState(() {
|
||||
fullScreen = html.document.fullscreenElement != null;
|
||||
});
|
||||
}
|
||||
|
||||
void toggleFullScreen() async {
|
||||
if (fullScreen) {
|
||||
html.document.exitFullscreen();
|
||||
//Wait for 1 second
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
} else {
|
||||
await html.document.documentElement?.requestFullscreen();
|
||||
}
|
||||
|
||||
_updateFullScreenStatus();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return IconButton(
|
||||
onPressed: toggleFullScreen,
|
||||
icon: Icon(
|
||||
fullScreen ? IconsaxOutline.close_square : IconsaxOutline.maximize_4,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue