Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 136 additions & 21 deletions app/lib/pages/settings/settings_drawer.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:omi/backend/auth.dart';
import 'package:omi/backend/preferences.dart';
Expand All @@ -18,6 +20,7 @@ import 'package:package_info_plus/package_info_plus.dart';
import 'package:provider/provider.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:share_plus/share_plus.dart';
import 'package:device_info_plus/device_info_plus.dart';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's no device_info_plus entry in pubspec? forgot to push that change?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forgot to push that change?

Yep, pushed it now.

import 'device_settings.dart';
import '../conversations/sync_page.dart';

Expand Down Expand Up @@ -50,15 +53,51 @@ class SettingsDrawer extends StatefulWidget {
class _SettingsDrawerState extends State<SettingsDrawer> {
String? version;
String? buildVersion;
String? shortDeviceInfo;

@override
void initState() {
super.initState();
PackageInfo.fromPlatform().then((PackageInfo packageInfo) {
version = packageInfo.version;
buildVersion = packageInfo.buildNumber.toString();
setState(() {});
});
_loadAppAndDeviceInfo();
}

Future<String> _getShortDeviceInfo() async {
try {
final deviceInfoPlugin = DeviceInfoPlugin();

if (Platform.isAndroid) {
final androidInfo = await deviceInfoPlugin.androidInfo;
return '${androidInfo.brand} ${androidInfo.model} — Android ${androidInfo.version.release}';
} else if (Platform.isIOS) {
final iosInfo = await deviceInfoPlugin.iosInfo;
return '${iosInfo.name} — iOS ${iosInfo.systemVersion}';
} else {
return 'Unknown Device';
}
} catch (e) {
return 'Unknown Device';
}
}

Future<void> _loadAppAndDeviceInfo() async {
try {
final packageInfo = await PackageInfo.fromPlatform();
final shortDevice = await _getShortDeviceInfo();

if (mounted) {
setState(() {
version = packageInfo.version;
buildVersion = packageInfo.buildNumber.toString();
shortDeviceInfo = shortDevice;
});
}
} catch (e) {
if (mounted) {
setState(() {
shortDeviceInfo = 'Unknown Device';
});
}
}
}

Widget _buildSettingsItem({
Expand Down Expand Up @@ -118,6 +157,96 @@ class _SettingsDrawerState extends State<SettingsDrawer> {
);
}

Widget _buildVersionInfoSection() {
if (!Platform.isIOS && !Platform.isAndroid) {
return const SizedBox.shrink();
}

final displayText = buildVersion != null ? '${version ?? ""} ($buildVersion)' : (version ?? '');

return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
displayText,
style: const TextStyle(
color: Color(0xFF8E8E93),
fontSize: 13,
fontWeight: FontWeight.w400,
),
),
const SizedBox(width: 2),
GestureDetector(
onTap: _copyVersionInfo,
child: Container(
padding: const EdgeInsets.all(2),
child: const Icon(
Icons.copy,
size: 12,
color: Color(0xFF8E8E93),
),
),
),
],
);
}

Future<void> _copyVersionInfo() async {
final versionPart = buildVersion != null ? 'Omi AI ${version ?? ""} ($buildVersion)' : 'Omi AI ${version ?? ""}';
final devicePart = shortDeviceInfo ?? 'Unknown Device';
final fullVersionInfo = '$versionPart — $devicePart';

await Clipboard.setData(ClipboardData(text: fullVersionInfo));

if (mounted) {
_showCopyNotification();
}
}

void _showCopyNotification() {
final overlay = Overlay.of(context);
late OverlayEntry overlayEntry;

overlayEntry = OverlayEntry(
builder: (_) => Positioned(
bottom: 20,
left: 0,
right: 0,
child: Center(
child: Material(
color: Colors.transparent,
child: Container(
width: MediaQuery.of(context).size.width * 0.7,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
decoration: BoxDecoration(
color: Colors.black87,
borderRadius: BorderRadius.circular(8),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.2),
blurRadius: 4,
offset: const Offset(0, 2),
),
],
),
child: const Text(
'App and device details copied',
textAlign: TextAlign.center,
style: TextStyle(color: Colors.white, fontSize: 14),
),
),
),
),
),
);

overlay.insert(overlayEntry);

Future.delayed(const Duration(seconds: 2), () {
overlayEntry.remove();
});
}

Widget _buildOmiModeContent(BuildContext context) {
return Consumer<UsageProvider>(builder: (context, usageProvider, child) {
final bool showSubscription = usageProvider.subscription?.showSubscriptionUi ?? false;
Expand Down Expand Up @@ -331,14 +460,7 @@ class _SettingsDrawerState extends State<SettingsDrawer> {
const SizedBox(height: 32),

// Version Info
Text(
'${version ?? ""}${buildVersion != null ? " ($buildVersion)" : ""}',
style: const TextStyle(
color: Color(0xFF8E8E93),
fontSize: 13,
fontWeight: FontWeight.w400,
),
),
_buildVersionInfoSection(),
const SizedBox(height: 24),
],
);
Expand Down Expand Up @@ -404,14 +526,7 @@ class _SettingsDrawerState extends State<SettingsDrawer> {
const SizedBox(height: 32),

// Version Info
Text(
'${version ?? ""}${buildVersion != null ? " ($buildVersion)" : ""}',
style: const TextStyle(
color: Color(0xFF8E8E93),
fontSize: 13,
fontWeight: FontWeight.w400,
),
),
_buildVersionInfoSection(),
const SizedBox(height: 24),
],
);
Expand Down
3 changes: 2 additions & 1 deletion app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ dependencies:
mcumgr_flutter: ^0.4.2
flutter_archive: ^6.0.3
json_annotation: ^4.9.0
json_serializable: 6.8.0
json_serializable: ^6.9.5
package_info_plus: ^8.0.1
device_info_plus: ^11.5.0
path_provider: 2.1.5
flutter_foreground_task: 9.1.0
upgrader: 11.4.0
Expand Down