mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 18:16:21 +00:00
code changes
This commit is contained in:
@ -34,7 +34,7 @@ part 'home_state.dart';
|
||||
|
||||
class HomeCubit extends Cubit<HomeState> {
|
||||
HomeCubit._() : super(HomeInitial()) {
|
||||
checkIfNotificationPermissionGranted();
|
||||
// checkIfNotificationPermissionGranted();
|
||||
fetchUserInfo();
|
||||
if (selectedSpace == null) {
|
||||
fetchUnitsByUserId();
|
||||
@ -55,7 +55,7 @@ class HomeCubit extends Cubit<HomeState> {
|
||||
|
||||
Future fetchUserInfo() async {
|
||||
try {
|
||||
var uuid = await const FlutterSecureStorage().read(key: UserModel.userUuidKey);
|
||||
var uuid=await const FlutterSecureStorage().read(key: UserModel.userUuidKey);
|
||||
user = await ProfileApi().fetchUserInfo(uuid);
|
||||
emit(HomeUserInfoLoaded(user!)); // Emit state after fetching user info
|
||||
} catch (e) {
|
||||
@ -76,9 +76,12 @@ class HomeCubit extends Cubit<HomeState> {
|
||||
selectedSpace = null;
|
||||
selectedRoom = null;
|
||||
pageIndex = 0;
|
||||
OneSignal.User.pushSubscription.removeObserver((stateChanges) => oneSignalSubscriptionObserver);
|
||||
OneSignal.Notifications.removePermissionObserver((permission) => oneSignalPermissionObserver);
|
||||
OneSignal.Notifications.removeClickListener((event) => oneSignalClickListenerObserver);
|
||||
// OneSignal.User.pushSubscription
|
||||
// .removeObserver((stateChanges) => oneSignalSubscriptionObserver);
|
||||
// OneSignal.Notifications.removePermissionObserver(
|
||||
// (permission) => oneSignalPermissionObserver);
|
||||
// OneSignal.Notifications.removeClickListener(
|
||||
// (event) => oneSignalClickListenerObserver);
|
||||
return super.close();
|
||||
}
|
||||
|
||||
@ -96,9 +99,9 @@ class HomeCubit extends Cubit<HomeState> {
|
||||
|
||||
var duration = const Duration(milliseconds: 300);
|
||||
|
||||
void oneSignalPermissionObserver;
|
||||
void oneSignalSubscriptionObserver;
|
||||
void oneSignalClickListenerObserver;
|
||||
// void oneSignalPermissionObserver;
|
||||
// void oneSignalSubscriptionObserver;
|
||||
// void oneSignalClickListenerObserver;
|
||||
|
||||
// selectSpace(SpaceModel space) async {
|
||||
// selectedSpace = space;
|
||||
@ -120,31 +123,36 @@ class HomeCubit extends Cubit<HomeState> {
|
||||
return;
|
||||
}
|
||||
|
||||
var userUuid = await const FlutterSecureStorage().read(key: UserModel.userUuidKey) ?? '';
|
||||
var userUuid =
|
||||
await const FlutterSecureStorage().read(key: UserModel.userUuidKey) ??
|
||||
'';
|
||||
if (userUuid.isNotEmpty) {
|
||||
await OneSignal.login(userUuid);
|
||||
}
|
||||
//Enable push notifications
|
||||
await OneSignal.User.pushSubscription.optIn();
|
||||
|
||||
//this function will be called once a user is subscribed
|
||||
oneSignalSubscriptionObserver = OneSignal.User.pushSubscription.addObserver((state) async {
|
||||
if (state.current.optedIn) {
|
||||
await _sendSubscriptionId();
|
||||
}
|
||||
});
|
||||
// //this function will be called once a user is subscribed
|
||||
// oneSignalSubscriptionObserver =
|
||||
// OneSignal.User.pushSubscription.addObserver((state) async {
|
||||
// if (state.current.optedIn) {
|
||||
// await _sendSubscriptionId();
|
||||
// }
|
||||
// });
|
||||
|
||||
// Send the player id when a user allows notifications
|
||||
oneSignalPermissionObserver = OneSignal.Notifications.addPermissionObserver((state) async {
|
||||
await _sendSubscriptionId();
|
||||
});
|
||||
// // Send the player id when a user allows notifications
|
||||
// oneSignalPermissionObserver =
|
||||
// OneSignal.Notifications.addPermissionObserver((state) async {
|
||||
// await _sendSubscriptionId();
|
||||
// });
|
||||
|
||||
//check if the player id is sent, if not send it again
|
||||
await _sendSubscriptionId();
|
||||
// //check if the player id is sent, if not send it again
|
||||
// await _sendSubscriptionId();
|
||||
|
||||
oneSignalClickListenerObserver = OneSignal.Notifications.addClickListener((event) async {
|
||||
//Once the user clicks on the notification
|
||||
});
|
||||
// oneSignalClickListenerObserver =
|
||||
// OneSignal.Notifications.addClickListener((event) async {
|
||||
// //Once the user clicks on the notification
|
||||
// });
|
||||
} catch (err) {
|
||||
debugPrint("******* Error");
|
||||
debugPrint(err.toString());
|
||||
@ -213,7 +221,8 @@ class HomeCubit extends Cubit<HomeState> {
|
||||
//////////////////////////////////////// API ////////////////////////////////////////
|
||||
generateInvitation(SpaceModel unit) async {
|
||||
try {
|
||||
final invitationCode = await SpacesAPI.generateInvitationCode(unit.id, unit.community.uuid);
|
||||
final invitationCode =
|
||||
await SpacesAPI.generateInvitationCode(unit.id, unit.community.uuid);
|
||||
if (invitationCode.isNotEmpty) {
|
||||
Share.share('The invitation code is $invitationCode');
|
||||
CustomSnackBar.displaySnackBar(
|
||||
@ -229,7 +238,9 @@ class HomeCubit extends Cubit<HomeState> {
|
||||
|
||||
Future<bool> joinAUnit(String code) async {
|
||||
try {
|
||||
var userUuid = await const FlutterSecureStorage().read(key: UserModel.userUuidKey) ?? '';
|
||||
var userUuid =
|
||||
await const FlutterSecureStorage().read(key: UserModel.userUuidKey) ??
|
||||
'';
|
||||
Map<String, String> body = {'inviteCode': code};
|
||||
|
||||
final success = await SpacesAPI.joinUnit(userUuid, body);
|
||||
@ -265,7 +276,8 @@ class HomeCubit extends Cubit<HomeState> {
|
||||
fetchRoomsByUnitId(SpaceModel space) async {
|
||||
emitSafe(GetSpaceRoomsLoading());
|
||||
try {
|
||||
space.subspaces = await SpacesAPI.getSubSpaceBySpaceId(space.community.uuid, space.id);
|
||||
space.subspaces =
|
||||
await SpacesAPI.getSubSpaceBySpaceId(space.community.uuid, space.id);
|
||||
} catch (failure) {
|
||||
emitSafe(GetSpaceRoomsError(failure.toString()));
|
||||
return;
|
||||
@ -347,7 +359,8 @@ class HomeCubit extends Cubit<HomeState> {
|
||||
size: 32,
|
||||
),
|
||||
style: ButtonStyle(
|
||||
foregroundColor: WidgetStateProperty.all(ColorsManager.textPrimaryColor),
|
||||
foregroundColor:
|
||||
WidgetStateProperty.all(ColorsManager.textPrimaryColor),
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(
|
||||
@ -368,7 +381,8 @@ class HomeCubit extends Cubit<HomeState> {
|
||||
NavigationService.navigatorKey.currentContext!
|
||||
.read<SmartSceneSelectBloc>()
|
||||
.add(const SmartSceneClearEvent());
|
||||
BlocProvider.of<EffectPeriodBloc>(NavigationService.navigatorKey.currentState!.context)
|
||||
BlocProvider.of<EffectPeriodBloc>(
|
||||
NavigationService.navigatorKey.currentState!.context)
|
||||
.add(ResetEffectivePeriod());
|
||||
NavigationService.navigatorKey.currentContext!
|
||||
.read<CreateSceneBloc>()
|
||||
@ -381,7 +395,8 @@ class HomeCubit extends Cubit<HomeState> {
|
||||
size: 28,
|
||||
),
|
||||
style: ButtonStyle(
|
||||
foregroundColor: WidgetStateProperty.all(ColorsManager.textPrimaryColor),
|
||||
foregroundColor:
|
||||
WidgetStateProperty.all(ColorsManager.textPrimaryColor),
|
||||
),
|
||||
onPressed: () {},
|
||||
),
|
||||
@ -414,7 +429,8 @@ class HomeCubit extends Cubit<HomeState> {
|
||||
};
|
||||
|
||||
static var bottomNavItems = [
|
||||
defaultBottomNavBarItem(icon: Assets.assetsIconsDashboard, label: 'Dashboard'),
|
||||
defaultBottomNavBarItem(
|
||||
icon: Assets.assetsIconsDashboard, label: 'Dashboard'),
|
||||
// defaultBottomNavBarItem(icon: Assets.assetsIconslayout, label: 'Layout'),
|
||||
defaultBottomNavBarItem(icon: Assets.assetsIconsDevices, label: 'Devices'),
|
||||
defaultBottomNavBarItem(icon: Assets.assetsIconsRoutines, label: 'Routine'),
|
||||
@ -440,7 +456,8 @@ class HomeCubit extends Cubit<HomeState> {
|
||||
|
||||
void updateDevice(String deviceId) async {
|
||||
try {
|
||||
final response = await DevicesAPI.firmwareDevice(deviceId: deviceId, firmwareVersion: '0');
|
||||
final response = await DevicesAPI.firmwareDevice(
|
||||
deviceId: deviceId, firmwareVersion: '0');
|
||||
if (response['success'] ?? false) {
|
||||
CustomSnackBar.displaySnackBar('No updates available');
|
||||
}
|
||||
@ -448,7 +465,8 @@ class HomeCubit extends Cubit<HomeState> {
|
||||
}
|
||||
}
|
||||
|
||||
BottomNavigationBarItem defaultBottomNavBarItem({required String icon, required String label}) {
|
||||
BottomNavigationBarItem defaultBottomNavBarItem(
|
||||
{required String icon, required String label}) {
|
||||
return BottomNavigationBarItem(
|
||||
icon: SvgPicture.asset(icon),
|
||||
activeIcon: SvgPicture.asset(
|
||||
|
@ -167,8 +167,8 @@ class SearchScenesEvent extends FourSceneEvent {
|
||||
class SaveLocationSelectionEvent extends FourSceneEvent {}
|
||||
|
||||
class SelectOptionEvent extends FourSceneEvent {
|
||||
dynamic selectedOption;
|
||||
SelectOptionEvent({
|
||||
final dynamic selectedOption;
|
||||
const SelectOptionEvent({
|
||||
this.selectedOption,
|
||||
});
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_blo
|
||||
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_event.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_state.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/four_scene_model.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
||||
@ -29,18 +28,6 @@ class FourSceneCreateGroup extends StatelessWidget {
|
||||
child: BlocBuilder<FourSceneBloc, FourSceneState>(
|
||||
builder: (context, state) {
|
||||
final sensor = BlocProvider.of<FourSceneBloc>(context);
|
||||
FourSceneModelState model = FourSceneModelState(
|
||||
scene_1: '',
|
||||
scene_2: '',
|
||||
scene_3: '',
|
||||
scene_4: '',
|
||||
scene_id_group_id: '',
|
||||
switch_backlight: '');
|
||||
if (state is LoadingNewSate) {
|
||||
model = state.device;
|
||||
} else if (state is UpdateState) {
|
||||
model = state.device;
|
||||
}
|
||||
return state is LoadingNewSate
|
||||
? const Center(
|
||||
child: DefaultContainer(
|
||||
@ -49,7 +36,7 @@ class FourSceneCreateGroup extends StatelessWidget {
|
||||
child: CircularProgressIndicator()),
|
||||
)
|
||||
: Padding(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
children: [
|
||||
const Padding(
|
||||
@ -201,7 +188,7 @@ class FourSceneCreateGroup extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
Spacer()
|
||||
const Spacer()
|
||||
],
|
||||
),
|
||||
);
|
||||
|
@ -5,7 +5,6 @@ import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_blo
|
||||
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_event.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_state.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/four_scene_model.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
||||
@ -29,18 +28,6 @@ class FourSceneInfoPage extends StatelessWidget {
|
||||
child: BlocBuilder<FourSceneBloc, FourSceneState>(
|
||||
builder: (context, state) {
|
||||
final _bloc = BlocProvider.of<FourSceneBloc>(context);
|
||||
FourSceneModelState model = FourSceneModelState(
|
||||
scene_1: '',
|
||||
scene_2: '',
|
||||
scene_3: '',
|
||||
scene_4: '',
|
||||
scene_id_group_id: '',
|
||||
switch_backlight: '');
|
||||
if (state is LoadingNewSate) {
|
||||
model = state.device;
|
||||
} else if (state is UpdateState) {
|
||||
model = state.device;
|
||||
}
|
||||
return state is FourSceneLoadingState
|
||||
? const Center(
|
||||
child: DefaultContainer(
|
||||
@ -69,7 +56,7 @@ class FourSceneInfoPage extends StatelessWidget {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Container(
|
||||
SizedBox(
|
||||
width:
|
||||
MediaQuery.of(context).size.width * 0.61,
|
||||
child: BodySmall(
|
||||
|
@ -6,7 +6,6 @@ import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_blo
|
||||
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_event.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_state.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/four_scene_model.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/four_scene_switch/four_scene_setting/location_setting_four_scene.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
||||
@ -37,18 +36,6 @@ class FourSceneProfilePage extends StatelessWidget {
|
||||
child: BlocBuilder<FourSceneBloc, FourSceneState>(
|
||||
builder: (context, state) {
|
||||
final _bloc = BlocProvider.of<FourSceneBloc>(context);
|
||||
FourSceneModelState model = FourSceneModelState(
|
||||
scene_1: '',
|
||||
scene_2: '',
|
||||
scene_3: '',
|
||||
scene_4: '',
|
||||
scene_id_group_id: '',
|
||||
switch_backlight: '');
|
||||
if (state is LoadingNewSate) {
|
||||
model = state.device;
|
||||
} else if (state is UpdateState) {
|
||||
model = state.device;
|
||||
}
|
||||
return state is FourSceneLoadingState
|
||||
? const Center(
|
||||
child: DefaultContainer(
|
||||
@ -73,7 +60,7 @@ class FourSceneProfilePage extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Center(
|
||||
@ -157,7 +144,7 @@ class FourSceneProfilePage extends StatelessWidget {
|
||||
)),
|
||||
);
|
||||
if (val == true) {
|
||||
_bloc.add(FourSceneInitialInfo());
|
||||
_bloc.add(const FourSceneInitialInfo());
|
||||
}
|
||||
},
|
||||
child: Row(
|
||||
|
@ -367,7 +367,8 @@ class FourSceneSettings extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
|
@ -2,11 +2,11 @@ import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class upDateNote extends StatelessWidget {
|
||||
class UpDateNote extends StatelessWidget {
|
||||
final Function()? cancelTab;
|
||||
final Function()? confirmTab;
|
||||
|
||||
const upDateNote({
|
||||
const UpDateNote({
|
||||
super.key,
|
||||
required this.cancelTab,
|
||||
required this.confirmTab,
|
||||
|
@ -39,9 +39,6 @@ class FourSceneUpdatePage extends StatelessWidget {
|
||||
onRefresh: () async {},
|
||||
child: Column(
|
||||
children: [
|
||||
// SizedBox(
|
||||
// height: MediaQuery.of(context).size.height * 0.15,
|
||||
// ),
|
||||
DefaultContainer(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
@ -116,7 +113,7 @@ class FourSceneUpdatePage extends StatelessWidget {
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
UpdateSosContainerWithProgressBar(
|
||||
const UpdateSosContainerWithProgressBar(
|
||||
sosDescription:
|
||||
'Connectivity Issue Resolved Fixed a bug that caused the SOS button to disconnect from the app intermittently.',
|
||||
sosVersion: 'SOS v2.0.5',
|
||||
@ -221,7 +218,7 @@ class NewUpdateContainer extends StatelessWidget {
|
||||
text: sosVersion!,
|
||||
fontColor: ColorsManager.primaryTextColor,
|
||||
),
|
||||
Container(
|
||||
SizedBox(
|
||||
width: MediaQuery.of(context).size.width * 0.7,
|
||||
child: BodyMedium(
|
||||
text: sosDescription!,
|
||||
@ -239,7 +236,7 @@ class NewUpdateContainer extends StatelessWidget {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return upDateNote(
|
||||
return UpDateNote(
|
||||
cancelTab: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
@ -297,7 +294,7 @@ class UpdateSosContainerWithProgressBar extends StatelessWidget {
|
||||
Assets.emptyUpdateIcon,
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
BodyMedium(
|
||||
const BodyMedium(
|
||||
text: 'New Update Available Now!',
|
||||
fontColor: ColorsManager.blueColor,
|
||||
),
|
||||
@ -314,7 +311,7 @@ class UpdateSosContainerWithProgressBar extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
LinearPercentIndicator(
|
||||
barRadius: Radius.circular(10),
|
||||
barRadius: const Radius.circular(10),
|
||||
width: 170.0,
|
||||
animation: true,
|
||||
animationDuration: 1000,
|
||||
|
@ -1,11 +1,9 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/app_layout/model/space_model.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_bloc.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_event.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_state.dart';
|
||||
import 'package:syncrow_app/features/devices/model/four_scene_model.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
||||
@ -29,21 +27,14 @@ class LocationFourScenePage extends StatelessWidget {
|
||||
body: BlocProvider(
|
||||
create: (context) => FourSceneBloc(fourSceneId: deviceId ?? '')
|
||||
..add(const FourSceneInitial())
|
||||
..add(FourSceneInitialInfo())
|
||||
..add(const FourSceneInitialInfo())
|
||||
..add(FetchRoomsEvent(unit: space!)),
|
||||
child: BlocBuilder<FourSceneBloc, FourSceneState>(
|
||||
builder: (context, state) {
|
||||
final _bloc = BlocProvider.of<FourSceneBloc>(context);
|
||||
FourSceneModelState model = FourSceneModelState(
|
||||
scene_1: '',
|
||||
scene_2: '',
|
||||
scene_3: '',
|
||||
scene_4: '',
|
||||
scene_id_group_id: '',
|
||||
switch_backlight: '');
|
||||
if (state is SaveSelectionSuccessState) {
|
||||
new Future.delayed(const Duration(microseconds: 500), () {
|
||||
_bloc.add(FourSceneInitialInfo());
|
||||
Future.delayed(const Duration(microseconds: 500), () {
|
||||
_bloc.add(const FourSceneInitialInfo());
|
||||
Navigator.of(context).pop(true);
|
||||
});
|
||||
}
|
||||
@ -84,65 +75,59 @@ class LocationFourScenePage extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
],
|
||||
|
||||
child: RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
// sensor.add(const SosInitial());
|
||||
},
|
||||
child: ListView(
|
||||
shrinkWrap: true,
|
||||
padding: const EdgeInsets.symmetric(vertical: 20),
|
||||
children: [
|
||||
const BodyMedium(
|
||||
text: 'Smart Device Location',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 12,
|
||||
fontColor: ColorsManager.grayColor,
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
DefaultContainer(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: ListView.builder(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
itemCount: _bloc.roomsList.length,
|
||||
itemBuilder: (context, index) {
|
||||
final fromRoom = _bloc.roomsList[index];
|
||||
final isSelected = (state
|
||||
is OptionSelectedState &&
|
||||
state.selectedOption == fromRoom.id) ||
|
||||
(state is! OptionSelectedState &&
|
||||
fromRoom.id ==
|
||||
_bloc.deviceInfo.subspace.uuid);
|
||||
child: ListView(
|
||||
shrinkWrap: true,
|
||||
padding: const EdgeInsets.symmetric(vertical: 20),
|
||||
children: [
|
||||
const BodyMedium(
|
||||
text: 'Smart Device Location',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 12,
|
||||
fontColor: ColorsManager.grayColor,
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
DefaultContainer(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: ListView.builder(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
itemCount: _bloc.roomsList.length,
|
||||
itemBuilder: (context, index) {
|
||||
final fromRoom = _bloc.roomsList[index];
|
||||
final isSelected = (state
|
||||
is OptionSelectedState &&
|
||||
state.selectedOption == fromRoom.id) ||
|
||||
(state is! OptionSelectedState &&
|
||||
fromRoom.id ==
|
||||
_bloc.deviceInfo.subspace.uuid);
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
_buildCheckboxOption(
|
||||
label: fromRoom.name!,
|
||||
isSelected: isSelected,
|
||||
onTap: (label) {
|
||||
context.read<FourSceneBloc>().add(
|
||||
SelectOptionEvent(
|
||||
selectedOption: fromRoom.id!,
|
||||
),
|
||||
);
|
||||
roomIdSelected = fromRoom.id!;
|
||||
},
|
||||
return Column(
|
||||
children: [
|
||||
_buildCheckboxOption(
|
||||
label: fromRoom.name!,
|
||||
isSelected: isSelected,
|
||||
onTap: (label) {
|
||||
context.read<FourSceneBloc>().add(
|
||||
SelectOptionEvent(
|
||||
selectedOption: fromRoom.id!,
|
||||
),
|
||||
);
|
||||
roomIdSelected = fromRoom.id!;
|
||||
},
|
||||
),
|
||||
if (index < _bloc.roomsList.length - 1) ...[
|
||||
const SizedBox(height: 10),
|
||||
const Divider(
|
||||
color: ColorsManager.dividerColor,
|
||||
),
|
||||
if (index < _bloc.roomsList.length - 1) ...[
|
||||
const SizedBox(height: 10),
|
||||
const Divider(
|
||||
color: ColorsManager.dividerColor,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
],
|
||||
const SizedBox(height: 10),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
@ -156,7 +141,8 @@ class CircularCheckbox extends StatefulWidget {
|
||||
final bool value;
|
||||
final ValueChanged<bool?> onChanged;
|
||||
|
||||
CircularCheckbox({required this.value, required this.onChanged});
|
||||
const CircularCheckbox(
|
||||
{super.key, required this.value, required this.onChanged});
|
||||
|
||||
@override
|
||||
_CircularCheckboxState createState() => _CircularCheckboxState();
|
||||
|
@ -4,7 +4,6 @@ import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_bloc.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_event.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_state.dart';
|
||||
import 'package:syncrow_app/features/devices/model/four_scene_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/question_model.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_button.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
@ -29,18 +28,6 @@ class QuestionPageFourScene extends StatelessWidget {
|
||||
child: BlocBuilder<FourSceneBloc, FourSceneState>(
|
||||
builder: (context, state) {
|
||||
final sensor = BlocProvider.of<FourSceneBloc>(context);
|
||||
FourSceneModelState model = FourSceneModelState(
|
||||
scene_1: '',
|
||||
scene_2: '',
|
||||
scene_3: '',
|
||||
scene_4: '',
|
||||
scene_id_group_id: '',
|
||||
switch_backlight: '');
|
||||
if (state is LoadingNewSate) {
|
||||
model = state.device;
|
||||
} else if (state is UpdateState) {
|
||||
model = state.device;
|
||||
}
|
||||
return state is FourSceneLoadingState
|
||||
? const Center(
|
||||
child: DefaultContainer(
|
||||
@ -48,109 +35,105 @@ class QuestionPageFourScene extends StatelessWidget {
|
||||
height: 50,
|
||||
child: CircularProgressIndicator()),
|
||||
)
|
||||
: RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
sensor.add(const FourSceneInitial());
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
DefaultContainer(
|
||||
padding: EdgeInsets.all(15),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
BodyLarge(
|
||||
text: questionModel!.question,
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontColor: ColorsManager.blackColor,
|
||||
),
|
||||
SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
BodyMedium(
|
||||
text: questionModel!.answer,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontColor: ColorsManager.secondaryTextColor,
|
||||
),
|
||||
],
|
||||
),
|
||||
: Column(
|
||||
children: [
|
||||
DefaultContainer(
|
||||
padding: const EdgeInsets.all(15),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
BodyLarge(
|
||||
text: questionModel!.question,
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontColor: ColorsManager.blackColor,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
BodyMedium(
|
||||
text: questionModel!.answer,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontColor: ColorsManager.secondaryTextColor,
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height * 0.15,
|
||||
),
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height * 0.15,
|
||||
),
|
||||
Center(
|
||||
child: SizedBox(
|
||||
width: 180,
|
||||
child: DefaultButton(
|
||||
backgroundColor: sensor.isHelpful == true
|
||||
? ColorsManager.grayColor
|
||||
: ColorsManager.grayButtonColors,
|
||||
borderRadius: 50,
|
||||
onPressed: () {
|
||||
sensor.add(
|
||||
const ToggleHelpfulEvent(isHelpful: true));
|
||||
},
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
Assets.thumbUp,
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
const BodyMedium(
|
||||
text: 'Helpful',
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontColor: ColorsManager.blackColor,
|
||||
),
|
||||
],
|
||||
)),
|
||||
),
|
||||
Center(
|
||||
child: SizedBox(
|
||||
width: 180,
|
||||
child: DefaultButton(
|
||||
backgroundColor: sensor.isHelpful == true
|
||||
? ColorsManager.grayColor
|
||||
: ColorsManager.grayButtonColors,
|
||||
borderRadius: 50,
|
||||
onPressed: () {
|
||||
sensor
|
||||
.add(ToggleHelpfulEvent(isHelpful: true));
|
||||
},
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
Assets.thumbUp,
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
const BodyMedium(
|
||||
text: 'Helpful',
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontColor: ColorsManager.blackColor,
|
||||
),
|
||||
],
|
||||
)),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Center(
|
||||
child: SizedBox(
|
||||
width: 180,
|
||||
child: DefaultButton(
|
||||
backgroundColor: sensor.isHelpful == false
|
||||
? ColorsManager.grayColor
|
||||
: ColorsManager.grayButtonColors,
|
||||
borderRadius: 50,
|
||||
onPressed: () {
|
||||
sensor.add(
|
||||
const ToggleHelpfulEvent(isHelpful: false));
|
||||
},
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
Assets.thumbDown,
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
const BodyMedium(
|
||||
text: 'Not Helpful',
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontColor: ColorsManager.blackColor,
|
||||
),
|
||||
],
|
||||
)),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Center(
|
||||
child: SizedBox(
|
||||
width: 180,
|
||||
child: DefaultButton(
|
||||
backgroundColor: sensor.isHelpful == false
|
||||
? ColorsManager.grayColor
|
||||
: ColorsManager.grayButtonColors,
|
||||
borderRadius: 50,
|
||||
onPressed: () {
|
||||
sensor.add(
|
||||
ToggleHelpfulEvent(isHelpful: false));
|
||||
},
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
Assets.thumbDown,
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
const BodyMedium(
|
||||
text: 'Not Helpful',
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontColor: ColorsManager.blackColor,
|
||||
),
|
||||
],
|
||||
)),
|
||||
),
|
||||
),
|
||||
],
|
||||
));
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
@ -5,7 +5,6 @@ import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_blo
|
||||
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_event.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_state.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/four_scene_model.dart';
|
||||
import 'package:syncrow_app/features/menu/view/widgets/manage_home/home_settings.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_button.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
@ -21,7 +20,6 @@ class ShareFourScenePage extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var spaces = HomeCubit.getInstance().spaces;
|
||||
|
||||
return DefaultScaffold(
|
||||
title: 'Share Device',
|
||||
child: BlocProvider(
|
||||
@ -30,18 +28,6 @@ class ShareFourScenePage extends StatelessWidget {
|
||||
child: BlocBuilder<FourSceneBloc, FourSceneState>(
|
||||
builder: (context, state) {
|
||||
final sensor = BlocProvider.of<FourSceneBloc>(context);
|
||||
FourSceneModelState model = FourSceneModelState(
|
||||
scene_1: '',
|
||||
scene_2: '',
|
||||
scene_3: '',
|
||||
scene_4: '',
|
||||
scene_id_group_id: '',
|
||||
switch_backlight: '');
|
||||
if (state is LoadingNewSate) {
|
||||
model = state.device;
|
||||
} else if (state is UpdateState) {
|
||||
model = state.device;
|
||||
}
|
||||
return state is LoadingNewSate
|
||||
? const Center(
|
||||
child: DefaultContainer(
|
||||
@ -103,7 +89,7 @@ class ShareFourScenePage extends StatelessWidget {
|
||||
space: spaces!.first,
|
||||
)));
|
||||
},
|
||||
child: Text('Add Home Member')),
|
||||
child: const Text('Add Home Member')),
|
||||
),
|
||||
)
|
||||
],
|
||||
|
@ -51,9 +51,10 @@ class SosScreen extends StatelessWidget {
|
||||
builder: (context) => SosSettings(device: device!),
|
||||
),
|
||||
);
|
||||
|
||||
sensor.add(SosInitialDeviseInfo());
|
||||
sensor.add(const SosInitial());
|
||||
if (val == true) {
|
||||
sensor.add(SosInitialDeviseInfo());
|
||||
sensor.add(const SosInitial());
|
||||
}
|
||||
},
|
||||
child: SvgPicture.asset(Assets.assetsIconsSettings),
|
||||
),
|
||||
|
Reference in New Issue
Block a user