Skip to content

Commit

Permalink
Show version number (at least on on Windows) (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
Levi-Lesches authored Mar 14, 2023
1 parent 1faa8a3 commit 08d6406
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 25 deletions.
16 changes: 5 additions & 11 deletions .metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This file should be version controlled.

version:
revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
revision: 12cb4eb7a009f52b347b62ade7cb4854b926af72
channel: stable

project_type: app
Expand All @@ -13,17 +13,11 @@ project_type: app
migration:
platforms:
- platform: root
create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
- platform: linux
create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
- platform: macos
create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
create_revision: 12cb4eb7a009f52b347b62ade7cb4854b926af72
base_revision: 12cb4eb7a009f52b347b62ade7cb4854b926af72
- platform: windows
create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
create_revision: 12cb4eb7a009f52b347b62ade7cb4854b926af72
base_revision: 12cb4eb7a009f52b347b62ade7cb4854b926af72

# User provided section

Expand Down
3 changes: 3 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ library main;
import "package:flutter/material.dart";

import "app.dart";
import "models.dart";
import "services.dart";

void main() async {
WidgetsFlutterBinding.ensureInitialized();
await services.init();
await models.init();
runApp(RoverControlDashboard());
}
2 changes: 1 addition & 1 deletion lib/models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,4 @@ class Models extends Model {
/// This constant is here to provide easy access to the backend. But simply using this variable
/// will not cause the UI to update. For that, you must place it in a `ChangeNotifierProvider`
/// and use `Consumer` when needed.
final models = Models()..init();
final models = Models();
9 changes: 8 additions & 1 deletion lib/src/models/data/home.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import "dart:async";
import "package:package_info_plus/package_info_plus.dart";

import "package:rover_dashboard/data.dart";
import "package:rover_dashboard/models.dart";
Expand All @@ -11,8 +12,14 @@ class HomeModel extends Model {
/// The timer responsible for clearing the [message].
Timer? _messageTimer;

/// The dashboard's version from the `pubspec.yaml`.
String? version;

@override
Future<void> init() async { }
Future<void> init() async {
final info = await PackageInfo.fromPlatform();
version = info.version;
}

/// Sets a new message that will disappear in 5 seconds.
void setMessage({required Severity severity, required String text}) {
Expand Down
3 changes: 2 additions & 1 deletion lib/src/pages/home.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import "package:flutter/material.dart";

import "package:rover_dashboard/data.dart";
import "package:rover_dashboard/models.dart";
import "package:rover_dashboard/pages.dart";
import "package:rover_dashboard/widgets.dart";

Expand Down Expand Up @@ -34,7 +35,7 @@ class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(
title: const Text("Dashboard"),
title: Text("Dashboard v${models.home.version ?? ''}"),
actions: [
IconButton(
icon: const Icon(Icons.settings),
Expand Down
2 changes: 2 additions & 0 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import FlutterMacOS
import Foundation

import flutter_libserialport
import package_info_plus_macos

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FlutterLibserialportPlugin.register(with: registry.registrar(forPlugin: "FlutterLibserialportPlugin"))
FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin"))
}
61 changes: 61 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,11 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_web_plugins:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
frontend_server_client:
dependency: transitive
description:
Expand Down Expand Up @@ -387,6 +392,54 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.0"
package_info_plus:
dependency: "direct main"
description:
name: package_info_plus
sha256: "7a6114becdf042be2b0777d77ace954d4a205644171a1cbd8712976b9bbb837c"
url: "https://pub.dev"
source: hosted
version: "1.4.2"
package_info_plus_linux:
dependency: transitive
description:
name: package_info_plus_linux
sha256: "04b575f44233d30edbb80a94e57cad9107aada334fc02aabb42b6becd13c43fc"
url: "https://pub.dev"
source: hosted
version: "1.0.5"
package_info_plus_macos:
dependency: transitive
description:
name: package_info_plus_macos
sha256: a2ad8b4acf4cd479d4a0afa5a74ea3f5b1c7563b77e52cc32b3ee6956d5482a6
url: "https://pub.dev"
source: hosted
version: "1.3.0"
package_info_plus_platform_interface:
dependency: transitive
description:
name: package_info_plus_platform_interface
sha256: f7a0c8f1e7e981bc65f8b64137a53fd3c195b18d429fba960babc59a5a1c7ae8
url: "https://pub.dev"
source: hosted
version: "1.0.2"
package_info_plus_web:
dependency: transitive
description:
name: package_info_plus_web
sha256: f0829327eb534789e0a16ccac8936a80beed4e2401c4d3a74f3f39094a822d3b
url: "https://pub.dev"
source: hosted
version: "1.0.6"
package_info_plus_windows:
dependency: transitive
description:
name: package_info_plus_windows
sha256: a6040b8695c82f8dd3c3d4dfab7ef96fbe9c67aac21b9bcf5db272589ef84441
url: "https://pub.dev"
source: hosted
version: "1.0.5"
path:
dependency: transitive
description:
Expand All @@ -403,6 +456,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.1.0"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
sha256: "6a2128648c854906c53fa8e33986fc0247a1116122f9534dd20e3ab9e16a32bc"
url: "https://pub.dev"
source: hosted
version: "2.1.4"
pointycastle:
dependency: transitive
description:
Expand Down
3 changes: 2 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# For information on the generic Dart part of this file, see
# https://dart.dev/tools/pub/pubspec

version: 0.0.1-alpha
version: 2023.3.13+1

environment:
sdk: ">=2.17.6 <3.0.0"
Expand All @@ -24,6 +24,7 @@ dependencies:
flutter:
sdk: flutter
flutter_libserialport: ^0.3.0
package_info_plus: ^1.4.2
protobuf: ^2.1.0
provider: ^6.0.5
win32_gamepad: ^1.0.2
Expand Down
8 changes: 8 additions & 0 deletions windows/runner/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,20 @@ add_executable(${BINARY_NAME} WIN32
# that need different build settings.
apply_standard_settings(${BINARY_NAME})

# Add preprocessor definitions for the build version.
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"")
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}")
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}")
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}")
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}")

# Disable Windows macros that collide with C++ standard library functions.
target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")

# Add dependency libraries and include directories. Add any application-specific
# dependencies here.
target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib")
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")

# Run the Flutter tool portions of the build. This must not be removed.
Expand Down
20 changes: 10 additions & 10 deletions windows/runner/Runner.rc
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ IDI_APP_ICON ICON "resources\\app_icon.ico"
// Version
//

#ifdef FLUTTER_BUILD_NUMBER
#define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER
#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD)
#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD
#else
#define VERSION_AS_NUMBER 1,0,0
#define VERSION_AS_NUMBER 1,0,0,0
#endif

#ifdef FLUTTER_BUILD_NAME
#define VERSION_AS_STRING #FLUTTER_BUILD_NAME
#if defined(FLUTTER_VERSION)
#define VERSION_AS_STRING FLUTTER_VERSION
#else
#define VERSION_AS_STRING "1.0.0"
#endif
Expand All @@ -90,12 +90,12 @@ BEGIN
BLOCK "040904e4"
BEGIN
VALUE "CompanyName", "com.example" "\0"
VALUE "FileDescription", "rover_control_dashboard" "\0"
VALUE "FileDescription", "dashboard" "\0"
VALUE "FileVersion", VERSION_AS_STRING "\0"
VALUE "InternalName", "rover_control_dashboard" "\0"
VALUE "LegalCopyright", "Copyright (C) 2022 com.example. All rights reserved." "\0"
VALUE "OriginalFilename", "rover_control_dashboard.exe" "\0"
VALUE "ProductName", "rover_control_dashboard" "\0"
VALUE "InternalName", "dashboard" "\0"
VALUE "LegalCopyright", "Copyright (C) 2023 com.example. All rights reserved." "\0"
VALUE "OriginalFilename", "dashboard.exe" "\0"
VALUE "ProductName", "dashboard" "\0"
VALUE "ProductVersion", VERSION_AS_STRING "\0"
END
END
Expand Down

0 comments on commit 08d6406

Please sign in to comment.