App version from pubspec only. Bump version.

This commit is contained in:
stopflock
2025-10-03 10:44:33 -05:00
parent fd47813bdf
commit 02c66b3785
9 changed files with 99 additions and 8 deletions
+3 -3
View File
@@ -34,12 +34,12 @@ double bottomPositionFromButtonBar(double spacingAboveButtonBar, double safeArea
// Add Camera icon vertical offset (no offset needed since circle is centered)
const double kAddPinYOffset = 0.0;
// Client name and version for OSM uploads ("created_by" tag)
// Client name for OSM uploads ("created_by" tag)
const String kClientName = 'DeFlock';
const String kClientVersion = '1.0.2';
// Note: Version is now dynamically retrieved from VersionService
// Development/testing features - set to false for production builds
const bool kEnableDevelopmentModes = false; // Set to false to hide sandbox/simulate modes and force production mode
const bool kEnableDevelopmentModes = true; // Set to false to hide sandbox/simulate modes and force production mode
// Navigation features - set to false to hide navigation UI elements while in development
const bool kEnableNavigationFeatures = kEnableDevelopmentModes; // Hide navigation until fully implemented
+4
View File
@@ -11,12 +11,16 @@ import 'screens/advanced_settings_screen.dart';
import 'screens/language_settings_screen.dart';
import 'screens/about_screen.dart';
import 'services/localization_service.dart';
import 'services/version_service.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
// Initialize version service
await VersionService().init();
// Initialize localization service
await LocalizationService.instance.init();
+2 -1
View File
@@ -3,6 +3,7 @@ import 'settings/sections/auth_section.dart';
import 'settings/sections/upload_mode_section.dart';
import 'settings/sections/queue_section.dart';
import '../services/localization_service.dart';
import '../services/version_service.dart';
import '../dev_config.dart';
class SettingsScreen extends StatelessWidget {
@@ -91,7 +92,7 @@ class SettingsScreen extends StatelessWidget {
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: Text(
'Version: $kClientVersion',
'Version: ${VersionService().version}',
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: Theme.of(context).textTheme.bodySmall?.color?.withOpacity(0.6),
),
+2 -1
View File
@@ -3,6 +3,7 @@ import 'package:http/http.dart' as http;
import '../models/pending_upload.dart';
import '../dev_config.dart';
import 'version_service.dart';
import '../app_state.dart';
class Uploader {
@@ -32,7 +33,7 @@ class Uploader {
final csXml = '''
<osm>
<changeset>
<tag k="created_by" v="$kClientName $kClientVersion"/>
<tag k="created_by" v="$kClientName ${VersionService().version}"/>
<tag k="comment" v="$action ${p.profile.name} surveillance node"/>
</changeset>
</osm>''';
+68
View File
@@ -0,0 +1,68 @@
import 'package:flutter/foundation.dart';
import 'package:package_info_plus/package_info_plus.dart';
/// Service for getting app version information from pubspec.yaml.
/// This ensures we have a single source of truth for version info.
class VersionService {
static final VersionService _instance = VersionService._internal();
factory VersionService() => _instance;
VersionService._internal();
PackageInfo? _packageInfo;
bool _initialized = false;
/// Initialize the service by loading package info
Future<void> init() async {
if (_initialized) return;
try {
_packageInfo = await PackageInfo.fromPlatform();
_initialized = true;
debugPrint('[VersionService] Loaded version: ${_packageInfo!.version}');
} catch (e) {
debugPrint('[VersionService] Failed to load package info: $e');
_initialized = false;
}
}
/// Get the app version (e.g., "1.0.2")
String get version {
if (!_initialized || _packageInfo == null) {
debugPrint('[VersionService] Warning: Service not initialized, returning fallback version');
return 'unknown'; // Fallback for development/testing
}
return _packageInfo!.version;
}
/// Get the app name
String get appName {
if (!_initialized || _packageInfo == null) {
return 'DeFlock'; // Fallback
}
return _packageInfo!.appName;
}
/// Get the package name/bundle ID
String get packageName {
if (!_initialized || _packageInfo == null) {
return 'me.deflock.deflockapp'; // Fallback
}
return _packageInfo!.packageName;
}
/// Get the build number
String get buildNumber {
if (!_initialized || _packageInfo == null) {
return '1'; // Fallback
}
return _packageInfo!.buildNumber;
}
/// Get full version string with build number (e.g., "1.0.2+1")
String get fullVersion {
return '$version+$buildNumber';
}
/// Check if the service is properly initialized
bool get isInitialized => _initialized && _packageInfo != null;
}