From 0948bc27373d32e109829fc43e4d36a6433f20d2 Mon Sep 17 00:00:00 2001 From: LiquidatorCoder Date: Thu, 25 Nov 2021 15:12:04 +0530 Subject: [PATCH] add popup menu for windows --- lib/widgets/window_buttons.dart | 40 +++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/lib/widgets/window_buttons.dart b/lib/widgets/window_buttons.dart index d7f32a5..673515e 100644 --- a/lib/widgets/window_buttons.dart +++ b/lib/widgets/window_buttons.dart @@ -1,5 +1,6 @@ import 'package:bitsdojo_window/bitsdojo_window.dart'; import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; import 'package:odin/widgets/menu_window_button.dart'; final buttonColors = WindowButtonColors( @@ -16,9 +17,15 @@ final closeButtonColors = WindowButtonColors( iconNormal: const Color(0x77FFFFFF), iconMouseOver: const Color(0xFFD32F2F)); -class WindowButtons extends StatelessWidget { +class WindowButtons extends StatefulWidget { const WindowButtons({Key? key}) : super(key: key); + @override + State createState() => _WindowButtonsState(); +} + +class _WindowButtonsState extends State { + final GlobalKey _menuKey = GlobalKey(); @override Widget build(BuildContext context) { return Row( @@ -27,9 +34,34 @@ class WindowButtons extends StatelessWidget { colors: buttonColors, animate: true, ), - MenuWindowButton( - colors: buttonColors, - animate: true, + Theme( + data: ThemeData.dark(), + child: PopupMenuButton( + key: _menuKey, + child: MenuWindowButton( + colors: buttonColors, + animate: true, + onPressed: () { + dynamic state = _menuKey.currentState; + state.showButtonMenu(); + }, + ), + itemBuilder: (context) => [ + PopupMenuItem( + child: Text( + "About", + style: GoogleFonts.poppins(), + ), + value: 1, + ), + PopupMenuItem( + child: Text( + "Support", + style: GoogleFonts.poppins(), + ), + value: 2, + ) + ]), ), CloseWindowButton( colors: closeButtonColors,