Compare commits

...

3 Commits

Author SHA1 Message Date
anhtunz
6af1baed32 Resolve merge conflict between main and vypq 2025-04-14 11:41:00 +07:00
anhtunz
758cc22a0f chore(ui): Update notificationCard and warningCard in HomeScreen 2025-04-14 11:30:10 +07:00
anhtunz
345c554519 chore: update ios config to use location 2025-04-14 09:48:29 +07:00
6 changed files with 72 additions and 46 deletions

View File

@@ -37,6 +37,35 @@ end
post_install do |installer| post_install do |installer|
installer.pods_project.targets.each do |target| installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target) flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
# You can remove unused permissions here
# for more information: https://github.com/BaseflowIT/flutter-permission-handler/blob/master/permission_handler/ios/Classes/PermissionHandlerEnums.h
# e.g. when you don't need camera permission, just add 'PERMISSION_CAMERA=0'
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',
## dart: PermissionGroup.camera
'PERMISSION_CAMERA=1',
## The 'PERMISSION_LOCATION' macro enables the `locationWhenInUse` and `locationAlways` permission. If
## the application only requires `locationWhenInUse`, only specify the `PERMISSION_LOCATION_WHENINUSE`
## macro.
##
## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
'PERMISSION_LOCATION=0',
'PERMISSION_LOCATION_WHENINUSE=1',
## dart: PermissionGroup.notification
'PERMISSION_NOTIFICATIONS=1',
## dart: PermissionGroup.criticalAlerts
'PERMISSION_CRITICAL_ALERTS=1',
]
end
target.build_configurations.each do |config| target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0' config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0'
end end

View File

@@ -28,14 +28,12 @@
<true/> <true/>
<key>NSCameraUsageDescription</key> <key>NSCameraUsageDescription</key>
<string>Camera permission is required for barcode scanning.</string> <string>Camera permission is required for barcode scanning.</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Always and when in use!</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Can I have location always?</string>
<key>NSLocationUsageDescription</key>
<string>Older devices need location.</string>
<key>NSLocationWhenInUseUsageDescription</key> <key>NSLocationWhenInUseUsageDescription</key>
<string>Need location when in use</string> <string>Cần vị trí để hiển thị bản đồ hoặc tìm địa điểm gần bạn</string>
<key>NSUserNotificationsUsageDescription</key>
<string>Chúng tôi cần gửi thông báo khẩn cấp để cảnh báo về việc thiết bị phát hiện có cháy.</string>
<key>com.apple.developer.usernotifications.critical-alerts</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key> <key>UIApplicationSupportsIndirectInputEvents</key>
<true/> <true/>
<key>UIBackgroundModes</key> <key>UIBackgroundModes</key>

View File

@@ -82,60 +82,57 @@ class _HomeScreenState extends State<HomeScreen> {
stream: homeBloc.streamOwnerDevicesStatus, stream: homeBloc.streamOwnerDevicesStatus,
builder: (context, snapshot) { builder: (context, snapshot) {
if (snapshot.data?['state'] != null || snapshot.data?['battery'] != null) { if (snapshot.data?['state'] != null || snapshot.data?['battery'] != null) {
return Row( return ConstrainedBox(
mainAxisAlignment: MainAxisAlignment.start, constraints: BoxConstraints(minWidth: MediaQuery.of(context).size.width),
crossAxisAlignment: CrossAxisAlignment.start, child: Row(
children: [ mainAxisAlignment: MainAxisAlignment.start,
if (snapshot.data?['state'] != null) children: [
...snapshot.data!['state']! if (snapshot.data?['state'] != null)
.map( ...snapshot.data!['state']!
(item) => FutureBuilder<Widget>( .map(
(item) => SizedBox(
width: context.dynamicWidth(0.95),
child: FutureBuilder<Widget>(
future: warningCard(context, apiServices, item), future: warningCard(context, apiServices, item),
builder: (context, warningCardSnapshot) { builder: (context, warningCardSnapshot) {
if (warningCardSnapshot.hasData) { if (warningCardSnapshot.hasData) {
return ConstrainedBox( return warningCardSnapshot.data!;
constraints: const BoxConstraints(
maxWidth: 400,
maxHeight: 260,
),
child: warningCardSnapshot.data!,
);
} else { } else {
return const SizedBox.shrink(); return const SizedBox.shrink();
} }
}, },
), ),
) ),
.toList(), )
if (snapshot.data?['battery'] != null) .toList(),
...snapshot.data!['battery']! if (snapshot.data?['battery'] != null)
.map( ...snapshot.data!['battery']!
(batteryItem) => FutureBuilder<Widget>( .map(
(batteryItem) => SizedBox(
width: context.dynamicWidth(0.95),
child: FutureBuilder<Widget>(
future: notificationCard( future: notificationCard(
context, "lowBattery", appLocalization(context).low_battery_message, batteryItem), context, "lowBattery", appLocalization(context).low_battery_message, batteryItem),
builder: (context, warningCardSnapshot) { builder: (context, warningCardSnapshot) {
if (warningCardSnapshot.hasData) { if (warningCardSnapshot.hasData) {
return ConstrainedBox( return warningCardSnapshot.data!;
constraints: const BoxConstraints(
maxWidth: 400,
maxHeight: 260,
),
child: warningCardSnapshot.data!,
);
} else { } else {
return const SizedBox.shrink(); return const SizedBox.shrink();
} }
}, },
), ),
) ),
.toList(), )
], .toList(),
],
),
); );
} else { } else {
return Padding( return Padding(
padding: context.paddingMedium, padding: context.paddingMedium,
child: Center( child: Center(
child: Row( child: Row(
mainAxisSize: MainAxisSize.min,
children: [ children: [
const Icon( const Icon(
Icons.check_circle_outline_rounded, Icons.check_circle_outline_rounded,
@@ -159,6 +156,11 @@ class _HomeScreenState extends State<HomeScreen> {
), ),
), ),
), ),
StreamBuilder<Map<String, List<DeviceWithAlias>>>( StreamBuilder<Map<String, List<DeviceWithAlias>>>(
stream: homeBloc.streamAllDevicesAliasMap, stream: homeBloc.streamAllDevicesAliasMap,
builder: (context, allDevicesAliasMapSnapshot) { builder: (context, allDevicesAliasMapSnapshot) {

View File

@@ -23,7 +23,6 @@ class OverviewCard extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Card( return Card(
margin: context.paddingLow,
elevation: 8, elevation: 8,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)),
child: Padding( child: Padding(

View File

@@ -235,9 +235,9 @@ class _MapScreenState extends State<MapScreen> with WidgetsBindingObserver {
if (hasStateOne) { if (hasStateOne) {
return flameIcon; // flameIcon return flameIcon; // flameIcon
} else if (hasOtherState) { } else if (hasOtherState) {
return normalIcon; // normalIcon return offlineIcon; // normalIcon
} else { } else {
return offlineIcon; // offlineIcon return normalIcon; // offlineIcon
} }
} }
@@ -275,16 +275,13 @@ class _MapScreenState extends State<MapScreen> with WidgetsBindingObserver {
if (response != "") { if (response != "") {
final data = jsonDecode(response); final data = jsonDecode(response);
List<dynamic> result = data['items']; List<dynamic> result = data['items'];
if(result.isNotEmpty){ if (result.isNotEmpty) {
devices.clear(); devices.clear();
final devicesList = Device.fromJsonDynamicList(result); final devicesList = Device.fromJsonDynamicList(result);
for (var device in devicesList) { for (var device in devicesList) {
devices.add(device); devices.add(device);
} }
}else{ } else {}
}
} }
} }

View File

@@ -163,6 +163,7 @@ onTapMarker(
style: const ButtonStyle( style: const ButtonStyle(
backgroundColor: WidgetStatePropertyAll(Colors.red), backgroundColor: WidgetStatePropertyAll(Colors.red),
foregroundColor: WidgetStatePropertyAll(Colors.white), foregroundColor: WidgetStatePropertyAll(Colors.white),
iconColor: WidgetStatePropertyAll(Colors.white),
), ),
icon: IconConstants.instance icon: IconConstants.instance
.getMaterialIcon(Icons.fire_truck_outlined), .getMaterialIcon(Icons.fire_truck_outlined),