diff --git a/.vscode/launch.json b/.vscode/launch.json index d1e17ab..64bfb24 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -14,6 +14,11 @@ "request": "launch", "type": "dart", "flutterMode": "profile" + }, + { + "name": "Flutter: Attach to Device", + "type": "dart", + "request": "attach" } ] } diff --git a/lib/desktop.dart b/lib/adaptive.dart similarity index 87% rename from lib/desktop.dart rename to lib/adaptive.dart index 61cf252..9e18b06 100644 --- a/lib/desktop.dart +++ b/lib/adaptive.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; bool get isDesktop => (Platform.isLinux || Platform.isMacOS || Platform.isWindows); +bool get isMacWin => (Platform.isMacOS || Platform.isWindows); class WindowButtons extends StatelessWidget { @override diff --git a/lib/main.dart b/lib/main.dart index a146f50..78939e2 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,6 @@ import 'dart:math'; import 'package:bitsdojo_window/bitsdojo_window.dart'; -import 'package:bullseye/desktop.dart'; +import 'package:bullseye/adaptive.dart'; import 'package:flutter/material.dart'; @@ -96,20 +96,26 @@ class _GamePageState extends State { } Widget desktopContainer() { - return Column(children: [ - Container( - height: 50, - child: WindowTitleBarBox( - child: Row( - children: [ - Expanded( - child: MoveWindow( - child: Score( - totalScore: _model.totalScore, round: _model.round))) - ], - ))), - Expanded(child: gameContainer()), - ]); + var score = Score(totalScore: _model.totalScore, round: _model.round); + + // Fallback to standard Flutter window on Linux while retaining the score toolbar. + // Rendering on Linux isn't quite perfect yet, but it's better than nothing. + if (isMacWin) { + return Column(children: [ + Container( + height: 50, + child: WindowTitleBarBox( + child: Row( + children: [Expanded(child: MoveWindow(child: score))], + ))), + Expanded(child: gameContainer()), + ]); + } else { + return Column(children: [ + Container(height: 50, child: score), + Expanded(child: gameContainer()), + ]); + } } @override