bitsdojo / bitsdojo_window

A Flutter package that makes it easy to customize and work with your Flutter desktop app window.
http://www.youtube.com/watch?v=bee2AHQpGK4
MIT License
816 stars 229 forks source link

Customized WindowButton never shown on my app. #132

Closed Moosphan closed 2 years ago

Moosphan commented 2 years ago

My code of AppBar is:

return MoveWindow(
            child: Row(
              children: [
                WindowButtons(),
                Padding(
                  padding: EdgeInsets.only(left: 28.0),
                  child: Text(Constants.windowTitle, style: TextStyle(
                    fontSize: 20,
                    fontWeight: FontWeight.bold
                  ),),
                ),
              ],
            ),
          );

MainFlutterWindow.swift code:

import Cocoa
import FlutterMacOS
import bitsdojo_window_macos

class MainFlutterWindow: BitsdojoWindow {
  override func awakeFromNib() {
    let flutterViewController = FlutterViewController.init()
    let windowFrame = self.frame
    self.contentViewController = flutterViewController
    self.setFrame(windowFrame, display: true)

    RegisterGeneratedPlugins(registry: flutterViewController)

    super.awakeFromNib()
  }

  override func bitsdojo_window_configure() -> UInt {
    return BDW_CUSTOM_FRAME | BDW_HIDE_ON_STARTUP
  }
}

After running my app on macos, it looked like this:

WeChat945bf9bfbce1055320aaae9cfddcaeea

You can see that the title in Row has already been shown, but these WindowButtons has never shown successfully.

bitsdojo commented 2 years ago

This is because WindowButton is not showing up on Mac. Check out this line in the source code:

https://github.com/bitsdojo/bitsdojo_window/blob/f320b623db107b03a5976fd88e52ec4fe81fa0c9/bitsdojo_window/lib/src/widgets/window_button.dart#L94

However, you can implement any widget and use the WindowButton as an inspiration.