mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 17:47:28 +00:00
added Null state from the AC universal switch (in case the status for the ACs are different from each other)
This commit is contained in:
@ -9,14 +9,14 @@ PODS:
|
||||
- Firebase/Crashlytics (10.20.0):
|
||||
- Firebase/CoreOnly
|
||||
- FirebaseCrashlytics (~> 10.20.0)
|
||||
- firebase_analytics (10.8.6):
|
||||
- firebase_analytics (10.8.7):
|
||||
- Firebase/Analytics (= 10.20.0)
|
||||
- firebase_core
|
||||
- Flutter
|
||||
- firebase_core (2.25.4):
|
||||
- firebase_core (2.25.5):
|
||||
- Firebase/CoreOnly (= 10.20.0)
|
||||
- Flutter
|
||||
- firebase_crashlytics (3.4.15):
|
||||
- firebase_crashlytics (3.4.16):
|
||||
- Firebase/Crashlytics (= 10.20.0)
|
||||
- firebase_core
|
||||
- Flutter
|
||||
@ -188,9 +188,9 @@ EXTERNAL SOURCES:
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
Firebase: 10c8cb12fb7ad2ae0c09ffc86cd9c1ab392a0031
|
||||
firebase_analytics: 9c600045bfb4d16dd78593d18f32c99bb77e5001
|
||||
firebase_core: a46c312d8bae4defa3d009b2aa7b5b413aeb394e
|
||||
firebase_crashlytics: 3054fbdd2b4a4a91f25a15e57c9f1bd2a9ed81ae
|
||||
firebase_analytics: 2c1c3057d5da3bd3aab819f7e6ee153a4e46c59e
|
||||
firebase_core: c8628c7ce80f79439149549052bff22f6784fbf5
|
||||
firebase_crashlytics: 012078b4eec6fc9716f97ba3da0f0e44a04e95b1
|
||||
FirebaseAnalytics: a2731bf3670747ce8f65368b118d18aa8e368246
|
||||
FirebaseCore: 28045c1560a2600d284b9c45a904fe322dc890b6
|
||||
FirebaseCoreExtension: 1c044fd46e95036cccb29134757c499613f3f564
|
||||
|
@ -43,11 +43,11 @@ class AcCubit extends Cubit<AcState> {
|
||||
}
|
||||
|
||||
void updateACsStatus() {
|
||||
bool tempStatus = DevicesCubit.categories[0].devices[0].status ?? false;
|
||||
bool? tempStatus = DevicesCubit.categories[0].devices[0].status;
|
||||
for (var AC in DevicesCubit.categories[0].devices) {
|
||||
//check if there any AC have a different status than the initial ==> turn off the universal switch
|
||||
if (AC.status != tempStatus) {
|
||||
DevicesCubit.categories[0].devicesStatus = false;
|
||||
DevicesCubit.categories[0].devicesStatus = null;
|
||||
emit(ACsStatusChanged());
|
||||
return;
|
||||
}
|
||||
|
@ -20,10 +20,18 @@ class DevicesCubit extends Cubit<DevicesState> {
|
||||
}
|
||||
|
||||
void changeCategorySwitchValue(DevicesCategoryModel category) {
|
||||
category.devicesStatus = !category.devicesStatus;
|
||||
if (category.devicesStatus != null) {
|
||||
category.devicesStatus = !category.devicesStatus!;
|
||||
for (var device in category.devices) {
|
||||
device.status = category.devicesStatus;
|
||||
}
|
||||
} else {
|
||||
category.devicesStatus = true;
|
||||
for (var device in category.devices) {
|
||||
device.status = true;
|
||||
}
|
||||
}
|
||||
|
||||
emit(CategorySwitchChanged());
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ class DevicesCategoryModel {
|
||||
|
||||
final Widget page;
|
||||
|
||||
bool devicesStatus = false;
|
||||
bool? devicesStatus = false;
|
||||
final List<DeviceModel> devices;
|
||||
|
||||
final DeviceType type;
|
||||
|
@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/strings_manager.dart';
|
||||
|
||||
import '../../../../../utils/resource_manager/color_manager.dart';
|
||||
import '../../../../shared_widgets/text_widgets/body_medium.dart';
|
||||
@ -13,9 +14,9 @@ class UniversalACSwitch extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
//TODO: Move these to String Manager "ON" and "OFF"
|
||||
return BlocBuilder<AcCubit, AcState>(
|
||||
builder: (context, state) {
|
||||
bool? status = DevicesCubit.categories[0].devicesStatus;
|
||||
return Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
@ -26,8 +27,10 @@ class UniversalACSwitch extends StatelessWidget {
|
||||
child: Container(
|
||||
height: 60,
|
||||
decoration: BoxDecoration(
|
||||
color: DevicesCubit.categories[0].devicesStatus
|
||||
color: status != null
|
||||
? status
|
||||
? ColorsManager.primaryColor
|
||||
: Colors.white
|
||||
: Colors.white,
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(15),
|
||||
@ -36,9 +39,11 @@ class UniversalACSwitch extends StatelessWidget {
|
||||
),
|
||||
child: Center(
|
||||
child: BodyMedium(
|
||||
text: "ON",
|
||||
fontColor: DevicesCubit.categories[0].devicesStatus
|
||||
text: StringsManager.on,
|
||||
fontColor: status != null
|
||||
? status
|
||||
? Colors.white
|
||||
: null
|
||||
: null,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
@ -54,9 +59,11 @@ class UniversalACSwitch extends StatelessWidget {
|
||||
child: Container(
|
||||
height: 60,
|
||||
decoration: BoxDecoration(
|
||||
color: DevicesCubit.categories[0].devicesStatus
|
||||
color: status != null
|
||||
? status
|
||||
? Colors.white
|
||||
: ColorsManager.primaryColor,
|
||||
: ColorsManager.primaryColor
|
||||
: Colors.white,
|
||||
borderRadius: const BorderRadius.only(
|
||||
topRight: Radius.circular(15),
|
||||
bottomRight: Radius.circular(15),
|
||||
@ -64,10 +71,12 @@ class UniversalACSwitch extends StatelessWidget {
|
||||
),
|
||||
child: Center(
|
||||
child: BodyMedium(
|
||||
text: "OFF",
|
||||
fontColor: DevicesCubit.categories[0].devicesStatus
|
||||
text: StringsManager.off,
|
||||
fontColor: status != null
|
||||
? status
|
||||
? null
|
||||
: Colors.white,
|
||||
: Colors.white
|
||||
: null,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
|
@ -22,8 +22,10 @@ class CustomSwitch extends StatelessWidget {
|
||||
height: 28.0,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(24.0),
|
||||
color: category.devicesStatus
|
||||
color: category.devicesStatus != null
|
||||
? category.devicesStatus!
|
||||
? ColorsManager.primaryColor
|
||||
: const Color(0xFFD9D9D9)
|
||||
: const Color(0xFFD9D9D9),
|
||||
),
|
||||
child: Center(
|
||||
@ -37,16 +39,20 @@ class CustomSwitch extends StatelessWidget {
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(2.0),
|
||||
child: Container(
|
||||
alignment: category.devicesStatus
|
||||
alignment: category.devicesStatus != null
|
||||
? category.devicesStatus!
|
||||
? Alignment.centerRight
|
||||
: Alignment.centerLeft
|
||||
: Alignment.centerLeft,
|
||||
child: Container(
|
||||
width: 20.0,
|
||||
height: 20.0,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: category.devicesStatus
|
||||
color: category.devicesStatus != null
|
||||
? category.devicesStatus!
|
||||
? ColorsManager.primaryColor
|
||||
: Colors.grey
|
||||
: Colors.grey,
|
||||
),
|
||||
),
|
||||
|
@ -22,4 +22,6 @@ class StringsManager {
|
||||
static const winterMode = 'Winter Mode';
|
||||
static const summer = 'Summer';
|
||||
static const summerMode = 'Summer Mode';
|
||||
static const on = 'ON';
|
||||
static const off = 'OFF';
|
||||
}
|
||||
|
48
pubspec.lock
48
pubspec.lock
@ -389,6 +389,30 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.6.7"
|
||||
leak_tracker:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: leak_tracker
|
||||
sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "10.0.0"
|
||||
leak_tracker_flutter_testing:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: leak_tracker_flutter_testing
|
||||
sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.1"
|
||||
leak_tracker_testing:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: leak_tracker_testing
|
||||
sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.1"
|
||||
lints:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -401,26 +425,26 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: matcher
|
||||
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
|
||||
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.12.16"
|
||||
version: "0.12.16+1"
|
||||
material_color_utilities:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: material_color_utilities
|
||||
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
|
||||
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.5.0"
|
||||
version: "0.8.0"
|
||||
meta:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: meta
|
||||
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
|
||||
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.10.0"
|
||||
version: "1.11.0"
|
||||
nested:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -441,10 +465,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path
|
||||
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
|
||||
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.8.3"
|
||||
version: "1.9.0"
|
||||
path_parsing:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -802,6 +826,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.4"
|
||||
vm_service:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vm_service
|
||||
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "13.0.0"
|
||||
web:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
Reference in New Issue
Block a user