Add maximize support and some other stuff
This commit is contained in:
parent
0d80c93bc7
commit
baf26d0ec9
4 changed files with 50 additions and 15 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import "dart:io";
|
||||
|
||||
import "package:flutter/foundation.dart";
|
||||
import "package:flutter_riverpod/flutter_riverpod.dart";
|
||||
import "package:nexus/controllers/client_controller.dart";
|
||||
|
|
@ -58,11 +60,15 @@ void main() async {
|
|||
WindowOptions(titleBarStyle: TitleBarStyle.hidden),
|
||||
);
|
||||
|
||||
if (Platform.isLinux) {
|
||||
setWindowMinSize(const Size.square(500));
|
||||
} else {
|
||||
await windowManager.setMinimumSize(Size.square(500));
|
||||
}
|
||||
|
||||
FlutterError.onError = (FlutterErrorDetails details) =>
|
||||
showError(details.exception.toString(), details.stack);
|
||||
|
||||
setWindowMinSize(const Size.square(500));
|
||||
|
||||
runApp(
|
||||
ProviderScope(
|
||||
observers: [
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
import "dart:io";
|
||||
import "dart:ui";
|
||||
import "package:flutter/material.dart";
|
||||
import "package:window_manager/window_manager.dart";
|
||||
|
||||
class Appbar extends StatelessWidget implements PreferredSizeWidget {
|
||||
final Widget? leading;
|
||||
|
|
@ -7,6 +9,7 @@ class Appbar extends StatelessWidget implements PreferredSizeWidget {
|
|||
final Color? backgroundColor;
|
||||
final double? scrolledUnderElevation;
|
||||
final List<Widget> actions;
|
||||
|
||||
const Appbar({
|
||||
super.key,
|
||||
this.title,
|
||||
|
|
@ -17,19 +20,42 @@ class Appbar extends StatelessWidget implements PreferredSizeWidget {
|
|||
});
|
||||
|
||||
@override
|
||||
Size get preferredSize => AppBar().preferredSize;
|
||||
Size get preferredSize => const Size.fromHeight(kToolbarHeight);
|
||||
|
||||
@override
|
||||
AppBar build(BuildContext context) => AppBar(
|
||||
leading: leading,
|
||||
backgroundColor: backgroundColor,
|
||||
scrolledUnderElevation: scrolledUnderElevation,
|
||||
actionsPadding: EdgeInsets.symmetric(horizontal: 8),
|
||||
title: title,
|
||||
actions: [
|
||||
...actions,
|
||||
if (!(Platform.isAndroid || Platform.isIOS))
|
||||
IconButton(onPressed: () => exit(0), icon: Icon(Icons.close)),
|
||||
],
|
||||
);
|
||||
Widget build(BuildContext context) {
|
||||
Future<void> maximize() async {
|
||||
final isMaximized = await windowManager.isMaximized();
|
||||
|
||||
if (isMaximized) {
|
||||
return windowManager.unmaximize();
|
||||
}
|
||||
|
||||
return windowManager.maximize();
|
||||
}
|
||||
|
||||
return GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onDoubleTap: maximize,
|
||||
onPanStart: (_) => windowManager.startDragging(),
|
||||
child: AppBar(
|
||||
leading: leading,
|
||||
backgroundColor: backgroundColor,
|
||||
scrolledUnderElevation: scrolledUnderElevation,
|
||||
actionsPadding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
title: title,
|
||||
actions: [
|
||||
...actions,
|
||||
if (!(Platform.isAndroid || Platform.isIOS)) ...[
|
||||
if (!Platform.isLinux)
|
||||
IconButton(
|
||||
onPressed: maximize,
|
||||
icon: const Icon(Icons.fullscreen),
|
||||
),
|
||||
IconButton(onPressed: () => exit(0), icon: const Icon(Icons.close)),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ class ChatBox extends HookConsumerWidget {
|
|||
}
|
||||
|
||||
void send() {
|
||||
if (controller.value.text.isEmpty) return;
|
||||
ref
|
||||
.watch(RoomChatController.provider(room).notifier)
|
||||
.send(
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ class MentionOverlay extends ConsumerWidget {
|
|||
super.key,
|
||||
});
|
||||
|
||||
// TODO: Don't embed mentions
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) => Padding(
|
||||
padding: EdgeInsets.all(8),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue