Improve example app UI (#193)

* Improve example app ui

* Store favorite services in local storage

* Use Text instead of SelectableText

* Improve colors

* Fix flutter analyzer issues

* Revert example app minimum sdk requirement

* Implement hasPermission api and improve ui flow

* More ui improvements

* Improve ScannedItem ui

* Improve control ui

* Change color theme to blue

* Minor improvements wip

* improve responsive ui and flow

* More improvements

* More improvements

* Update Mac podfile

* Fix home page scroll view

* Update app and package name

* Revert changelog

* Resolve Ai comments

---------

Co-authored-by: Foti Dim <foti@navideck.com>
This commit is contained in:
Rohit Sangwan
2025-12-21 13:21:36 +05:30
committed by GitHub
parent a7e280be29
commit 895dcbe343
90 changed files with 4928 additions and 1147 deletions
+25 -13
View File
@@ -5,6 +5,7 @@ import 'package:universal_ble/universal_ble.dart';
/// Mock implementation of [UniversalBlePlatform] for testing
class MockUniversalBle extends UniversalBlePlatform {
final Map<String, BleConnectionState> _connectionStateMap = {};
final _mockBleDevice = BleDevice(
name: 'MockDevice',
deviceId: 'MockDeviceId',
@@ -15,12 +16,20 @@ class MockUniversalBle extends UniversalBlePlatform {
Uint8List _serviceValue = utf8.encode('Result');
bool _isScanning = false;
final BleService _mockService = BleService('180', [
BleCharacteristic('180A', [
CharacteristicProperty.read,
CharacteristicProperty.write,
CharacteristicProperty.notify,
], []),
final BleService _mockService = BleService('180a', [
BleCharacteristic.withMetaData(
deviceId: 'MockDeviceId',
serviceId: '180a',
uuid: '220a',
properties: [
CharacteristicProperty.read,
CharacteristicProperty.write,
CharacteristicProperty.notify,
],
descriptors: [
BleDescriptor('220b'),
],
),
]);
@override
@@ -45,11 +54,13 @@ class MockUniversalBle extends UniversalBlePlatform {
@override
Future<void> connect(String deviceId, {Duration? connectionTimeout}) async {
updateConnection(deviceId, true);
_connectionStateMap[deviceId] = BleConnectionState.connected;
}
@override
Future<void> disconnect(String deviceId) async {
updateConnection(deviceId, false);
_connectionStateMap[deviceId] = BleConnectionState.disconnected;
}
@override
@@ -71,7 +82,7 @@ class MockUniversalBle extends UniversalBlePlatform {
@override
Future<List<BleDevice>> getSystemDevices(List<String>? withServices) async {
return [];
return [_mockBleDevice];
}
@override
@@ -124,17 +135,18 @@ class MockUniversalBle extends UniversalBlePlatform {
}
@override
Future<BleConnectionState> getConnectionState(String deviceId) {
throw UnimplementedError();
Future<BleConnectionState> getConnectionState(String deviceId) async {
return _connectionStateMap[deviceId] ?? BleConnectionState.disconnected;
}
@override
Future<bool> disableBluetooth() {
throw UnimplementedError();
Future<bool> disableBluetooth() async {
return true;
}
@override
Future<void> requestPermissions({bool withAndroidFineLocation = false}) {
throw UnimplementedError();
Future<void> requestPermissions(
{bool withAndroidFineLocation = false}) async {
return;
}
}
+22
View File
@@ -0,0 +1,22 @@
import 'package:shared_preferences/shared_preferences.dart';
class StorageService {
StorageService._();
static StorageService? _instance;
static StorageService get instance => _instance ??= StorageService._();
late SharedPreferencesWithCache _preferences;
Future<void> init() async {
_preferences = await SharedPreferencesWithCache.create(
cacheOptions: const SharedPreferencesWithCacheOptions(),
);
}
Future<void> setFavoriteServices(List<String> services) async {
await _preferences.setStringList('favorite_services', services);
}
List<String> getFavoriteServices() =>
_preferences.getStringList('favorite_services') ?? [];
}
+7
View File
@@ -0,0 +1,7 @@
bool isSystemService(String uuid) {
final normalized = uuid.toUpperCase().replaceAll('-', '');
return normalized == '00001800' ||
normalized == '00001801' ||
normalized == '0000180A' ||
normalized.startsWith('000018');
}