Adpative layout

- The desktop version has the score, ect, in the title bar area now while the mobile version remains the same
- Capitalized "bullseye"
- Used "late" keyword for certain variables
- Updated application Id
This commit is contained in:
Tony Bark 2021-05-29 12:01:35 -04:00
parent 964e861450
commit 593fda0975
22 changed files with 154 additions and 68 deletions

View file

@ -34,7 +34,7 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.bullseye"
applicationId "com.tonybark.bullseye"
minSdkVersion 16
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()

View file

@ -1,7 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.bullseye">
<application
android:label="bullseye"
android:label="Bullseye"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"

View file

@ -359,7 +359,7 @@
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.example.bullseye;
PRODUCT_BUNDLE_IDENTIFIER = com.tonybark.bullseye;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
@ -483,7 +483,7 @@
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.example.bullseye;
PRODUCT_BUNDLE_IDENTIFIER = com.tonybark.bullseye;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
@ -502,7 +502,7 @@
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.example.bullseye;
PRODUCT_BUNDLE_IDENTIFIER = com.tonybark.bullseye;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;

View file

@ -11,7 +11,7 @@
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>bullseye</string>
<string>Bullseye</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>

20
lib/desktop.dart Normal file
View file

@ -0,0 +1,20 @@
import 'dart:io';
import 'package:bitsdojo_window/bitsdojo_window.dart';
import 'package:flutter/material.dart';
bool get isDesktop =>
(Platform.isLinux || Platform.isMacOS || Platform.isWindows);
class WindowButtons extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Row(
children: [
MinimizeWindowButton(),
MaximizeWindowButton(),
CloseWindowButton()
],
);
}
}

View file

@ -8,8 +8,8 @@ class GameModel {
this.totalScore = SCORE_START,
this.round = ROUND_START]);
int? target;
int? current;
int? totalScore;
int? round;
late int target;
late int current;
late int totalScore;
late int round;
}

View file

@ -1,29 +1,46 @@
import 'package:flutter/cupertino.dart';
import 'dart:math';
import 'package:bitsdojo_window/bitsdojo_window.dart';
import 'package:bullseye/desktop.dart';
import 'package:flutter/material.dart';
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
import 'package:flutter/services.dart';
import 'package:bullseye/prompt.dart';
import 'package:bullseye/control.dart';
import 'package:bullseye/score.dart';
import 'package:bullseye/game_model.dart';
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
void main() => runApp(BullsEyeApp());
const gameTitle = "Bullseye";
void main() {
runApp(BullsEyeApp());
if (isDesktop) {
doWhenWindowReady(() {
final win = appWindow;
final minSize = Size(600, 450);
win.minSize = minSize;
win.size = minSize;
win.alignment = Alignment.center;
win.title = gameTitle;
win.show();
});
}
}
class BullsEyeApp extends StatelessWidget {
Brightness currentBrightness = Brightness.light;
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations(
[DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight]);
return PlatformApp(
title: 'BullsEye',
// For some reason text is black in dark mode on iOS
cupertino: (_, __) => CupertinoAppData(
theme: CupertinoThemeData(brightness: Brightness.light)),
home: GamePage(title: 'BullsEye'));
title: gameTitle,
debugShowCheckedModeBanner: false,
home: GamePage(title: gameTitle));
}
}
@ -37,38 +54,69 @@ class GamePage extends StatefulWidget {
class _GamePageState extends State<GamePage> {
bool _alertIsVisable = false;
GameModel _model = GameModel(50);
late GameModel _model;
@override
void initState() {
super.initState();
_model = GameModel(50);
var rng = Random();
_model = GameModel(rng.nextInt(100) + 1);
}
Widget gameContainer() {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Prompt(targetValue: _model.target),
Control(model: _model),
PlatformTextButton(
child: PlatformText('Hit me!'),
onPressed: () {
this._alertIsVisable = true;
_showAlert(context);
})
],
);
}
Widget mobileContainer() {
return Column(mainAxisAlignment: MainAxisAlignment.center, children: [
gameContainer(),
Score(totalScore: _model.totalScore, round: _model.round)
]);
}
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()),
]);
}
@override
Widget build(BuildContext context) {
return PlatformScaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Prompt(targetValue: _model.target),
Control(model: _model),
PlatformTextButton(
child: PlatformText('Hit me!'),
onPressed: () {
this._alertIsVisable = true;
_showAlert(context);
}),
Score(totalScore: _model.totalScore, round: _model.round)
],
),
),
return Scaffold(
body: LayoutBuilder(builder: (context, constraints) {
if (isDesktop)
return desktopContainer();
else
return mobileContainer();
}),
);
}
void _showAlert(BuildContext context) {
Widget okButton = PlatformTextButton(
var okButton = PlatformTextButton(
child: PlatformText("Awesome!"),
onPressed: () {
Navigator.of(context).pop();

View file

@ -13,7 +13,7 @@ class Score extends StatelessWidget {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
PlatformButton(
PlatformTextButton(
child: PlatformText("Start Over"),
onPressed: () {},
),
@ -35,7 +35,7 @@ class Score extends StatelessWidget {
],
),
),
PlatformButton(
PlatformTextButton(
child: PlatformText("Info"),
onPressed: () {},
)

View file

@ -1,8 +1,8 @@
cmake_minimum_required(VERSION 3.10)
project(runner LANGUAGES CXX)
set(BINARY_NAME "bullseye")
set(APPLICATION_ID "com.example.bullseye")
set(BINARY_NAME "Bullseye")
set(APPLICATION_ID "com.tonybark.bullseye")
cmake_policy(SET CMP0063 NEW)

View file

@ -4,6 +4,10 @@
#include "generated_plugin_registrant.h"
#include <bitsdojo_window_linux/bitsdojo_window_plugin.h>
void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) bitsdojo_window_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "BitsdojoWindowPlugin");
bitsdojo_window_plugin_register_with_registrar(bitsdojo_window_linux_registrar);
}

View file

@ -3,6 +3,7 @@
#
list(APPEND FLUTTER_PLUGIN_LIST
bitsdojo_window_linux
)
set(PLUGIN_BUNDLED_LIBRARIES)

View file

@ -40,12 +40,12 @@ static void my_application_activate(GApplication* application) {
if (use_header_bar) {
GtkHeaderBar *header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
gtk_widget_show(GTK_WIDGET(header_bar));
gtk_header_bar_set_title(header_bar, "bullseye");
gtk_header_bar_set_title(header_bar, "Bullseye");
gtk_header_bar_set_show_close_button(header_bar, TRUE);
gtk_window_set_titlebar(window, GTK_WIDGET(header_bar));
}
else {
gtk_window_set_title(window, "bullseye");
gtk_window_set_title(window, "Bullseye");
}
gtk_window_set_default_size(window, 1280, 720);

View file

@ -5,8 +5,10 @@
import FlutterMacOS
import Foundation
import bitsdojo_window_macos
import path_provider_macos
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
BitsdojoWindowPlugin.register(with: registry.registrar(forPlugin: "BitsdojoWindowPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
}

View file

@ -1,19 +1,25 @@
PODS:
- bitsdojo_window_macos (0.0.1):
- FlutterMacOS
- FlutterMacOS (1.0.0)
- path_provider_macos (0.0.1):
- FlutterMacOS
DEPENDENCIES:
- bitsdojo_window_macos (from `Flutter/ephemeral/.symlinks/plugins/bitsdojo_window_macos/macos`)
- FlutterMacOS (from `Flutter/ephemeral`)
- path_provider_macos (from `Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos`)
EXTERNAL SOURCES:
bitsdojo_window_macos:
:path: Flutter/ephemeral/.symlinks/plugins/bitsdojo_window_macos/macos
FlutterMacOS:
:path: Flutter/ephemeral
path_provider_macos:
:path: Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos
SPEC CHECKSUMS:
bitsdojo_window_macos: 7e9b1bbb09bdce418d9657ead7fc9d824203ff0d
FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424
path_provider_macos: a0a3fd666cb7cd0448e936fb4abad4052961002b

View file

@ -56,7 +56,7 @@
1FA37E1854051AEE30722181 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = "<group>"; };
335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = "<group>"; };
33CC10ED2044A3C60003C045 /* bullseye.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = bullseye.app; sourceTree = BUILT_PRODUCTS_DIR; };
33CC10ED2044A3C60003C045 /* Bullseye.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Bullseye.app; sourceTree = BUILT_PRODUCTS_DIR; };
33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = "<group>"; };
33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = "<group>"; };
@ -112,7 +112,7 @@
33CC10EE2044A3C60003C045 /* Products */ = {
isa = PBXGroup;
children = (
33CC10ED2044A3C60003C045 /* bullseye.app */,
33CC10ED2044A3C60003C045 /* Bullseye.app */,
);
name = Products;
sourceTree = "<group>";
@ -159,7 +159,6 @@
774797C801BB581636907200 /* Pods-Runner.release.xcconfig */,
6F8A7F66FBB30BD4E0A9315F /* Pods-Runner.profile.xcconfig */,
);
name = Pods;
path = Pods;
sourceTree = "<group>";
};
@ -193,7 +192,7 @@
);
name = Runner;
productName = Runner;
productReference = 33CC10ED2044A3C60003C045 /* bullseye.app */;
productReference = 33CC10ED2044A3C60003C045 /* Bullseye.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */

View file

@ -15,7 +15,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
BuildableName = "bullseye.app"
BuildableName = "Bullseye.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
@ -31,13 +31,13 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
BuildableName = "bullseye.app"
BuildableName = "Bullseye.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
@ -54,13 +54,11 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
BuildableName = "bullseye.app"
BuildableName = "Bullseye.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Profile"
@ -73,7 +71,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
BuildableName = "bullseye.app"
BuildableName = "Bullseye.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>

View file

@ -5,10 +5,10 @@
// 'flutter create' template.
// The application's name. By default this is also the title of the Flutter window.
PRODUCT_NAME = bullseye
PRODUCT_NAME = Bullseye;
// The application's bundle identifier
PRODUCT_BUNDLE_IDENTIFIER = com.example.bullseye
PRODUCT_BUNDLE_IDENTIFIER = com.tonybark.bullseye;
// The copyright displayed in application information
PRODUCT_COPYRIGHT = Copyright © 2021 com.example. All rights reserved.

View file

@ -1,7 +1,13 @@
import Cocoa
import FlutterMacOS
import bitsdojo_window_macos
class MainFlutterWindow: BitsdojoWindow {
override func bitsdojo_window_configure() -> UInt {
return BDW_CUSTOM_FRAME | BDW_HIDE_ON_STARTUP
}
class MainFlutterWindow: NSWindow {
override func awakeFromNib() {
let flutterViewController = FlutterViewController.init()
let windowFrame = self.frame

View file

@ -3,7 +3,7 @@ description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
publish_to: "none" # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
@ -24,12 +24,12 @@ dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
google_fonts: ^2.1.0
flutter_platform_widgets: ^1.9.0
bitsdojo_window: ^0.1.0+1
dev_dependencies:
flutter_test:
@ -40,23 +40,18 @@ dev_dependencies:
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a

View file

@ -4,6 +4,9 @@
#include "generated_plugin_registrant.h"
#include <bitsdojo_window_windows/bitsdojo_window_plugin.h>
void RegisterPlugins(flutter::PluginRegistry* registry) {
BitsdojoWindowPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("BitsdojoWindowPlugin"));
}

View file

@ -3,6 +3,7 @@
#
list(APPEND FLUTTER_PLUGIN_LIST
bitsdojo_window_windows
)
set(PLUGIN_BUNDLED_LIBRARIES)

View file

@ -6,6 +6,9 @@
#include "run_loop.h"
#include "utils.h"
#include <bitsdojo_window_windows/bitsdojo_window_plugin.h>
auto bdw = bitsdojo_window_configure(BDW_CUSTOM_FRAME | BDW_HIDE_ON_STARTUP);
int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
_In_ wchar_t *command_line, _In_ int show_command) {
// Attach to console when present (e.g., 'flutter run') or create a