diff --git a/assets/icons/linkageIcons/doorLockAlarm.svg b/assets/icons/linkageIcons/doorLockAlarm.svg
new file mode 100644
index 0000000..3452356
--- /dev/null
+++ b/assets/icons/linkageIcons/doorLockAlarm.svg
@@ -0,0 +1,11 @@
+
diff --git a/assets/icons/linkageIcons/familyHome.svg b/assets/icons/linkageIcons/familyHome.svg
new file mode 100644
index 0000000..d4b0a95
--- /dev/null
+++ b/assets/icons/linkageIcons/familyHome.svg
@@ -0,0 +1,6 @@
+
diff --git a/assets/icons/unlockingMethodsIcons/face.svg b/assets/icons/unlockingMethodsIcons/face.svg
new file mode 100644
index 0000000..2a317e4
--- /dev/null
+++ b/assets/icons/unlockingMethodsIcons/face.svg
@@ -0,0 +1,3 @@
+
diff --git a/assets/icons/unlockingMethodsIcons/fingerprint.svg b/assets/icons/unlockingMethodsIcons/fingerprint.svg
new file mode 100644
index 0000000..f9f55c5
--- /dev/null
+++ b/assets/icons/unlockingMethodsIcons/fingerprint.svg
@@ -0,0 +1,9 @@
+
diff --git a/assets/icons/unlockingMethodsIcons/remote.svg b/assets/icons/unlockingMethodsIcons/remote.svg
new file mode 100644
index 0000000..da59643
--- /dev/null
+++ b/assets/icons/unlockingMethodsIcons/remote.svg
@@ -0,0 +1,9 @@
+
diff --git a/lib/features/app_layout/view/app_layout.dart b/lib/features/app_layout/view/app_layout.dart
index cdb1725..93e486d 100644
--- a/lib/features/app_layout/view/app_layout.dart
+++ b/lib/features/app_layout/view/app_layout.dart
@@ -1,12 +1,11 @@
import 'package:flutter/material.dart';
-import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
import 'package:syncrow_app/features/app_layout/view/widgets/app_body.dart';
import 'package:syncrow_app/features/app_layout/view/widgets/default_app_bar.dart';
import 'package:syncrow_app/features/app_layout/view/widgets/default_nav_bar.dart';
-import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
+import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
class AppLayout extends StatelessWidget {
const AppLayout({super.key});
@@ -17,23 +16,12 @@ class AppLayout extends StatelessWidget {
create: (context) => HomeCubit.getInstance(),
child: BlocBuilder(
builder: (context, state) {
- return AnnotatedRegion(
- value: SystemUiOverlayStyle(
- statusBarColor: ColorsManager.primaryColor.withOpacity(0.5),
- statusBarIconBrightness: Brightness.light,
- ),
- child: SafeArea(
- child: Scaffold(
- backgroundColor: ColorsManager.backgroundColor,
- extendBodyBehindAppBar: true,
- extendBody: true,
- appBar: HomeCubit.getInstance().spaces != null
- ? const DefaultAppBar()
- : null,
- body: const AppBody(),
- bottomNavigationBar: const DefaultNavBar(),
- ),
- ),
+ return DefaultScaffold(
+ appBar: HomeCubit.getInstance().spaces != null
+ ? const DefaultAppBar()
+ : null,
+ bottomNavBar: const DefaultNavBar(),
+ child: const AppBody(),
);
},
),
diff --git a/lib/features/app_layout/view/widgets/app_body.dart b/lib/features/app_layout/view/widgets/app_body.dart
index 6e80454..a8693f2 100644
--- a/lib/features/app_layout/view/widgets/app_body.dart
+++ b/lib/features/app_layout/view/widgets/app_body.dart
@@ -3,7 +3,6 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
-import 'package:syncrow_app/generated/assets.dart';
class AppBody extends StatelessWidget {
const AppBody({
@@ -15,32 +14,20 @@ class AppBody extends StatelessWidget {
return BlocConsumer(
listener: (context, state) {
if (state is GetSpacesError) {
- // ScaffoldMessenger.of(context).showSnackBar(
- // SnackBar(
- // content: Text(state.errMessage),
- // ),
- // );
+ ScaffoldMessenger.of(context).removeCurrentSnackBar();
+ ScaffoldMessenger.of(context).showSnackBar(
+ SnackBar(
+ content: Text(state.errMessage),
+ ),
+ );
}
},
builder: (context, state) {
- return Container(
- width: MediaQuery.sizeOf(context).width,
- height: MediaQuery.sizeOf(context).height,
- decoration: const BoxDecoration(
- image: DecorationImage(
- image: AssetImage(
- Assets.imagesBackground,
- ),
- fit: BoxFit.cover,
- opacity: 0.4,
- ),
- ),
- child: state is! GetSpacesLoading
- ? state is! GetSpaceRoomsLoading
- ? HomeCubit.getInstance().pages[HomeCubit.pageIndex]
- : const Center(child: CircularProgressIndicator())
- : const Center(child: CircularProgressIndicator()),
- );
+ return state is! GetSpacesLoading
+ ? state is! GetSpaceRoomsLoading
+ ? HomeCubit.getInstance().pages[HomeCubit.pageIndex]
+ : const Center(child: CircularProgressIndicator())
+ : const Center(child: CircularProgressIndicator());
},
);
}
diff --git a/lib/features/app_layout/view/widgets/default_nav_bar.dart b/lib/features/app_layout/view/widgets/default_nav_bar.dart
index 178faa5..79754a6 100644
--- a/lib/features/app_layout/view/widgets/default_nav_bar.dart
+++ b/lib/features/app_layout/view/widgets/default_nav_bar.dart
@@ -3,7 +3,6 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
-import 'package:syncrow_app/utils/resource_manager/constants.dart';
class DefaultNavBar extends StatelessWidget {
const DefaultNavBar({
@@ -15,34 +14,23 @@ class DefaultNavBar extends StatelessWidget {
return BlocBuilder(
builder: (context, state) {
var cubit = HomeCubit.getInstance();
- return SizedBox(
- height: Constants.bottomNavBarHeight,
- child: BottomNavigationBar(
- backgroundColor: Colors.transparent,
- onTap: (int index) {
- cubit.updatePageIndex(index);
- // if (DevicesCubit.getInstance().chosenCategoryView != null) {
- // DevicesCubit.getInstance()
- // .clearCategoriesSelection(context);
- // }
- // if (HomeCubit.getInstance().selectedRoom != null) {
- // HomeCubit.getInstance().unselectRoom();
- // }
-
- HomeCubit.getInstance().updatePageIndex(index);
- },
- currentIndex: HomeCubit.pageIndex,
- selectedItemColor: ColorsManager.primaryColor,
- selectedLabelStyle: const TextStyle(
- color: ColorsManager.primaryColor,
- fontSize: 10,
- ),
- showUnselectedLabels: true,
- unselectedItemColor: Colors.grey,
- type: BottomNavigationBarType.fixed,
- elevation: 0,
- items: HomeCubit.bottomNavItems,
+ return BottomNavigationBar(
+ backgroundColor: Colors.transparent,
+ onTap: (int index) {
+ cubit.updatePageIndex(index);
+ HomeCubit.getInstance().updatePageIndex(index);
+ },
+ currentIndex: HomeCubit.pageIndex,
+ selectedItemColor: ColorsManager.primaryColor,
+ selectedLabelStyle: const TextStyle(
+ color: ColorsManager.primaryColor,
+ fontSize: 10,
),
+ showUnselectedLabels: true,
+ unselectedItemColor: Colors.grey,
+ type: BottomNavigationBarType.fixed,
+ elevation: 0,
+ items: HomeCubit.bottomNavItems,
);
},
);
diff --git a/lib/features/auth/bloc/auth_cubit.dart b/lib/features/auth/bloc/auth_cubit.dart
index 4e10a42..daa909a 100644
--- a/lib/features/auth/bloc/auth_cubit.dart
+++ b/lib/features/auth/bloc/auth_cubit.dart
@@ -140,7 +140,7 @@ class AuthCubit extends Cubit {
final value =
await const FlutterSecureStorage().read(key: Token.loginAccessTokenKey);
- if (value == null) {
+ if (value == null || value.isEmpty) {
emit(AuthTokenError(message: "Token not found"));
return;
}
diff --git a/lib/features/dashboard/view/dashboard_view.dart b/lib/features/dashboard/view/dashboard_view.dart
index 9977200..3e7346d 100644
--- a/lib/features/dashboard/view/dashboard_view.dart
+++ b/lib/features/dashboard/view/dashboard_view.dart
@@ -5,7 +5,6 @@ import 'package:syncrow_app/features/dashboard/view/widgets/carbon_emission.dart
import 'package:syncrow_app/features/dashboard/view/widgets/consumption.dart';
import 'package:syncrow_app/features/dashboard/view/widgets/live_monitor_tab.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/title_medium.dart';
-import 'package:syncrow_app/utils/resource_manager/constants.dart';
import 'package:syncrow_app/utils/resource_manager/strings_manager.dart';
import 'widgets/energy_usage.dart';
@@ -15,45 +14,36 @@ class DashboardView extends StatelessWidget {
@override
Widget build(BuildContext context) {
- return Padding(
- padding: EdgeInsets.only(
- top: Constants.appBarHeight,
- left: Constants.defaultPadding,
- right: Constants.defaultPadding,
- bottom: Constants.bottomNavBarHeight,
- ),
- child: SingleChildScrollView(
- child: Column(
- mainAxisAlignment: MainAxisAlignment.start,
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [
- const TitleMedium(
- text: StringsManager.dashboard,
- style: TextStyle(
- fontSize: 32,
- fontWeight: FontWeight.bold,
- ),
+ return SingleChildScrollView(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ const TitleMedium(
+ text: StringsManager.dashboard,
+ style: TextStyle(
+ fontSize: 32,
+ fontWeight: FontWeight.bold,
),
- const LiveMonitorTab(),
- const SizedBox(height: 10),
- const EnergyUsage(),
- Container(
- padding: const EdgeInsets.only(top: 20),
- constraints: const BoxConstraints(
- minHeight: 220,
- maxHeight: 240,
- ),
- child: const Column(
- mainAxisAlignment: MainAxisAlignment.start,
- children: [
- Consumption(),
- SizedBox(height: 20),
- CarbonEmission(),
- ],
- ),
+ ),
+ const LiveMonitorTab(),
+ const SizedBox(height: 10),
+ const EnergyUsage(),
+ Container(
+ padding: const EdgeInsets.only(top: 20),
+ constraints: const BoxConstraints(
+ minHeight: 220,
+ maxHeight: 240,
),
- ],
- ),
+ child: const Column(
+ mainAxisAlignment: MainAxisAlignment.start,
+ children: [
+ Consumption(),
+ SizedBox(height: 20),
+ CarbonEmission(),
+ ],
+ ),
+ ),
+ ],
),
);
}
diff --git a/lib/features/devices/view/devices_view.dart b/lib/features/devices/view/devices_view.dart
deleted file mode 100644
index 6793026..0000000
--- a/lib/features/devices/view/devices_view.dart
+++ /dev/null
@@ -1,17 +0,0 @@
-// import 'package:flutter/material.dart';
-// import 'package:syncrow_app/features/devices/view/widgets/devices_view_body.dart';
-
-// class DevicesView extends StatelessWidget {
-// const DevicesView({super.key});
-
-// @override
-// Widget build(BuildContext context) {
-// print('built DevicesView');
-// return Container(
-// padding: const EdgeInsets.all(8),
-// width: MediaQuery.of(context).size.width,
-// height: MediaQuery.of(context).size.height,
-// child: const DevicesViewBody(),
-// );
-// }
-// }
diff --git a/lib/features/devices/view/widgets/presence_sensors/parameter_control_dialog.dart b/lib/features/devices/view/widgets/presence_sensors/parameter_control_dialog.dart
index 1d22095..e8776aa 100644
--- a/lib/features/devices/view/widgets/presence_sensors/parameter_control_dialog.dart
+++ b/lib/features/devices/view/widgets/presence_sensors/parameter_control_dialog.dart
@@ -144,7 +144,6 @@ class ParameterControlDialogState extends State {
return;
}
if (!widget.sensor.isOnline!) {
- debugPrint('Device is offline');
return;
}
diff --git a/lib/features/devices/view/widgets/smart_door/add_member_interface.dart b/lib/features/devices/view/widgets/smart_door/add_member_interface.dart
new file mode 100644
index 0000000..3622ad9
--- /dev/null
+++ b/lib/features/devices/view/widgets/smart_door/add_member_interface.dart
@@ -0,0 +1,231 @@
+import 'package:flutter/cupertino.dart';
+import 'package:flutter/material.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';
+import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
+import 'package:syncrow_app/utils/context_extension.dart';
+import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
+import 'package:syncrow_app/utils/resource_manager/constants.dart';
+
+class AddMemberInterface extends StatelessWidget {
+ const AddMemberInterface({super.key, required this.memberRole});
+ final MemberRole memberRole;
+ @override
+ Widget build(BuildContext context) {
+ return DefaultScaffold(
+ title: 'Add Member',
+ actions: [
+ Padding(
+ padding: const EdgeInsets.only(right: 10),
+ child: TextButton(
+ onPressed: () {},
+ child: const BodyMedium(
+ text: 'SAVE',
+ fontWeight: FontWeight.bold,
+ ),
+ ),
+ ),
+ ],
+ child: Column(
+ children: [
+ SizedBox.square(
+ dimension: 120,
+ child: CircleAvatar(
+ backgroundColor: Colors.white,
+ child: SizedBox.square(
+ dimension: 117,
+ child: CircleAvatar(
+ backgroundColor: Colors.grey,
+ child: Icon(
+ memberRole == MemberRole.FamilyMember
+ ? Icons.family_restroom
+ : Icons.person,
+ size: 25,
+ color: Colors.white,
+ ),
+ ),
+ ),
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.symmetric(vertical: 20),
+ child: Row(
+ children: [
+ const Expanded(
+ child: SizedBox.shrink(),
+ ),
+ BodyLarge(
+ text: memberRole == MemberRole.FamilyMember
+ ? 'Family Member'
+ : 'Guest',
+ fontWeight: FontWeight.bold,
+ ),
+ Expanded(
+ child: Row(
+ children: [
+ IconButton(
+ onPressed: () {},
+ icon: const Icon(
+ Icons.edit_outlined,
+ size: 20,
+ ),
+ ),
+ ],
+ ),
+ ),
+ ],
+ ),
+ ),
+ memberRole == MemberRole.FamilyMember
+ ? DefaultContainer(
+ padding: const EdgeInsets.symmetric(
+ horizontal: 25,
+ vertical: 5,
+ ),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ mainAxisAlignment: MainAxisAlignment.start,
+ children: [
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ const BodyMedium(text: 'Region '),
+ Flexible(
+ child: TextField(
+ textAlign: TextAlign.end,
+ decoration: InputDecoration(
+ hintText: 'United Arab Emirates',
+ hintStyle: context.bodyMedium
+ .copyWith(color: Colors.grey),
+ border: InputBorder.none,
+ ),
+ ),
+ ),
+ ],
+ ),
+ Container(
+ height: 1,
+ color: ColorsManager.greyColor,
+ ),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ const BodyMedium(text: 'Account '),
+ Flexible(
+ child: TextField(
+ textAlign: TextAlign.end,
+ decoration: InputDecoration(
+ hintText: 'Account Name',
+ hintStyle: context.bodyMedium
+ .copyWith(color: Colors.grey),
+ border: InputBorder.none,
+ ),
+ ),
+ ),
+ ],
+ ),
+ Container(
+ height: 1,
+ color: ColorsManager.greyColor,
+ ),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ const BodyMedium(text: 'Family Role'),
+ Flexible(
+ child: TextField(
+ textAlign: TextAlign.end,
+ decoration: InputDecoration(
+ hintText: 'Common Member',
+ hintStyle: context.bodyMedium
+ .copyWith(color: Colors.grey),
+ border: InputBorder.none,
+ ),
+ ),
+ ),
+ ],
+ ),
+ ],
+ ),
+ )
+ : DefaultContainer(
+ padding: const EdgeInsets.symmetric(
+ horizontal: 25,
+ vertical: 5,
+ ),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ mainAxisAlignment: MainAxisAlignment.start,
+ children: [
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ const BodyMedium(text: 'Unlock with Mobile phone '),
+ Expanded(
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.end,
+ children: [
+ Transform.scale(
+ scale: .8,
+ child: CupertinoSwitch(
+ value: false,
+ onChanged: (value) {},
+ applyTheme: true,
+ ),
+ ),
+ ],
+ ),
+ ),
+ ],
+ ),
+ Container(
+ height: 1,
+ color: ColorsManager.greyColor,
+ ),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ const BodyMedium(text: 'Set Validity Period '),
+ Flexible(
+ child: TextField(
+ textAlign: TextAlign.end,
+ decoration: InputDecoration(
+ hintText: 'Start and End Date',
+ hintStyle: context.bodyMedium
+ .copyWith(color: Colors.grey),
+ border: InputBorder.none,
+ ),
+ ),
+ ),
+ ],
+ ),
+ Container(
+ height: 1,
+ color: ColorsManager.greyColor,
+ ),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ const BodyMedium(text: 'Effictive Period '),
+ Flexible(
+ child: TextField(
+ textAlign: TextAlign.end,
+ decoration: InputDecoration(
+ hintText: 'Start and End Time',
+ hintStyle: context.bodyMedium
+ .copyWith(color: Colors.grey),
+ border: InputBorder.none,
+ ),
+ ),
+ ),
+ ],
+ ),
+ ],
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+}
diff --git a/lib/features/devices/view/widgets/smart_door/add_member_view.dart b/lib/features/devices/view/widgets/smart_door/add_member_view.dart
new file mode 100644
index 0000000..cd039f2
--- /dev/null
+++ b/lib/features/devices/view/widgets/smart_door/add_member_view.dart
@@ -0,0 +1,129 @@
+import 'package:flutter/material.dart';
+import 'package:syncrow_app/features/devices/view/widgets/smart_door/add_member_interface.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';
+import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
+import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
+import 'package:syncrow_app/utils/resource_manager/constants.dart';
+
+class AddMemberView extends StatelessWidget {
+ const AddMemberView({super.key});
+ @override
+ Widget build(BuildContext context) {
+ return DefaultScaffold(
+ title: 'Add Member',
+ child: Column(
+ children: [
+ DefaultContainer(
+ padding: const EdgeInsets.symmetric(
+ horizontal: 15,
+ vertical: 20,
+ ),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ const BodyMedium(
+ text: 'Family Members', fontWeight: FontWeight.bold),
+ const Padding(
+ padding: EdgeInsets.symmetric(vertical: 13),
+ child: BodySmall(
+ text:
+ 'After adding:\n\n\t\t1.The user will join the family.\n\n\t\t2.The user will be able to control and use all devices in the family.',
+ fontColor: ColorsManager.greyColor,
+ fontSize: 10,
+ ),
+ ),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ TextButton(
+ style: ButtonStyle(
+ backgroundColor: MaterialStateProperty.all(
+ ColorsManager.primaryColorWithOpacity,
+ ),
+ ),
+ onPressed: () {
+ Navigator.of(context).push(
+ MaterialPageRoute(
+ builder: (context) => const AddMemberInterface(
+ memberRole: MemberRole.FamilyMember,
+ ),
+ ),
+ );
+ },
+ child: const Padding(
+ padding: EdgeInsets.symmetric(horizontal: 50),
+ child: BodyMedium(
+ text: 'ADD',
+ fontColor: Colors.white,
+ fontWeight: FontWeight.bold,
+ ),
+ ),
+ ),
+ ],
+ )
+ ],
+ ),
+ ),
+ const SizedBox(
+ height: 10,
+ ),
+ DefaultContainer(
+ padding: const EdgeInsets.symmetric(
+ horizontal: 15,
+ vertical: 20,
+ ),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ const BodyMedium(
+ text: 'Other Member', fontWeight: FontWeight.bold),
+ const Padding(
+ padding: EdgeInsets.symmetric(vertical: 13),
+ child: BodySmall(
+ text:
+ 'After adding:\n\n\t\t1.The user only appears in the member list of the current lock and can only view their own unlocking records.\n\n\t\t2.The user cannot obtain the permissions to operate or manage the lock.\n\n\t\t3.To grant the user operation permissions on the lock, you must use the device sharing functions.',
+ fontColor: ColorsManager.greyColor,
+ fontSize: 10,
+ ),
+ ),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ TextButton(
+ onPressed: () {
+ Navigator.of(context).push(
+ MaterialPageRoute(
+ builder: (context) => const AddMemberInterface(
+ memberRole: MemberRole.OtherMember,
+ ),
+ ),
+ );
+ },
+ style: ButtonStyle(
+ backgroundColor: MaterialStateProperty.all(
+ ColorsManager.primaryColorWithOpacity,
+ ),
+ ),
+ child: const Padding(
+ padding: EdgeInsets.symmetric(horizontal: 50),
+ child: BodyMedium(
+ text: 'ADD',
+ fontColor: Colors.white,
+ fontWeight: FontWeight.bold,
+ ),
+ ),
+ ),
+ ],
+ )
+ ],
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+}
diff --git a/lib/features/devices/view/widgets/smart_door/door_button.dart b/lib/features/devices/view/widgets/smart_door/door_button.dart
index 610ffad..cfc91c1 100644
--- a/lib/features/devices/view/widgets/smart_door/door_button.dart
+++ b/lib/features/devices/view/widgets/smart_door/door_button.dart
@@ -1,5 +1,9 @@
import 'package:flutter/material.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/flutter_svg.dart';
+import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart';
+import 'package:syncrow_app/features/devices/model/device_control_model.dart';
+import 'package:syncrow_app/features/devices/model/device_model.dart';
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/utils/context_extension.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
@@ -7,8 +11,10 @@ import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class DoorLockButton extends StatefulWidget {
const DoorLockButton({
super.key,
+ required this.doorLock,
});
+ final DeviceModel doorLock;
@override
State createState() => _DoorLockButtonState();
}
@@ -28,9 +34,29 @@ class _DoorLockButtonState extends State
_animation = Tween(begin: 0, end: 1.0).animate(_animationController)
..addListener(() {
if (_animation.status == AnimationStatus.completed) {
- //TODO send a request to lock the door but check if the door is already locked
+ if (widget.doorLock.status
+ .firstWhere((element) => element.code == 'normal_open_switch')
+ .value !=
+ true) {
+ DevicesCubit.getInstance().deviceControl(
+ DeviceControlModel(
+ deviceId: widget.doorLock.uuid,
+ code: 'normal_open_switch',
+ value: true),
+ widget.doorLock.uuid ?? "");
+ }
} else if (_animation.status == AnimationStatus.dismissed) {
- //TODO send a request to unlock the door but check if the door is already unlocked
+ if (widget.doorLock.status
+ .firstWhere((element) => element.code == 'normal_open_switch')
+ .value !=
+ false) {
+ DevicesCubit.getInstance().deviceControl(
+ DeviceControlModel(
+ deviceId: widget.doorLock.uuid,
+ code: 'normal_open_switch',
+ value: false),
+ widget.doorLock.uuid ?? "");
+ }
}
setState(() {});
});
@@ -44,101 +70,119 @@ class _DoorLockButtonState extends State
@override
Widget build(BuildContext context) {
- return Padding(
- padding: EdgeInsets.only(
- right: context.width * 0.25 / 2,
- left: context.width * 0.25 / 2,
- bottom: context.width * 0.2 / 2,
- ),
- child: InkWell(
- overlayColor: MaterialStateProperty.all(
- ColorsManager.primaryColorWithOpacity.withOpacity(0.1)),
- borderRadius: BorderRadius.circular(999),
- onTapDown: (details) {
- if (_animationController.status == AnimationStatus.dismissed) {
- _animationController.forward();
- } else if (_animationController.status == AnimationStatus.completed) {
- _animationController.reverse();
- } else if (_animationController.status == AnimationStatus.forward) {
- _animationController.reverse();
- } else if (_animationController.status == AnimationStatus.reverse) {
- _animationController.forward();
- }
- },
- onTapUp: (details) {
- if (_animationController.status == AnimationStatus.forward) {
- _animationController.reverse();
- } else if (_animationController.status == AnimationStatus.reverse) {
- _animationController.forward();
- }
- },
- child: Container(
- width: context.width * 06,
- height: context.width * 0.6,
- margin: const EdgeInsets.all(10),
- decoration: const BoxDecoration(
- boxShadow: [
- BoxShadow(
- color: Colors.grey,
- blurRadius: 18,
- offset: Offset(6, 7),
- blurStyle: BlurStyle.outer,
- ),
- ],
- color: Color(0xFFEBECED),
- borderRadius: BorderRadius.all(Radius.circular(999)),
+ return BlocConsumer(
+ listener: (context, state) {
+ if (state is GetDeviceStatusError) {
+ ScaffoldMessenger.of(context).showSnackBar(
+ SnackBar(
+ content: Text(state.errorMsg),
+ backgroundColor: Colors.red,
+ ),
+ );
+ }
+ },
+ builder: (context, state) {
+ return Padding(
+ padding: EdgeInsets.only(
+ right: context.width * 0.25 / 2,
+ left: context.width * 0.25 / 2,
+ bottom: context.width * 0.2 / 2,
),
- child: Padding(
- padding: const EdgeInsets.all(25),
- child: Stack(
- alignment: Alignment.center,
- children: [
- Container(
- margin: const EdgeInsets.all(8),
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.circular(999),
- boxShadow: [
- BoxShadow(
- color: Colors.white.withOpacity(0.5),
- blurRadius: 30,
- offset: const Offset(-5, -5),
- blurStyle: BlurStyle.outer,
- ),
- BoxShadow(
- color: Colors.black.withOpacity(0.14),
- blurRadius: 25,
- offset: const Offset(5, 5),
- blurStyle: BlurStyle.outer,
- ),
- BoxShadow(
- color: Colors.black.withOpacity(0.14),
- blurRadius: 30,
- offset: const Offset(5, 5),
- blurStyle: BlurStyle.inner,
- ),
- ],
+ child: InkWell(
+ overlayColor: MaterialStateProperty.all(
+ ColorsManager.primaryColorWithOpacity.withOpacity(0.1)),
+ borderRadius: BorderRadius.circular(999),
+ onTapDown: (details) {
+ if (_animationController.status == AnimationStatus.dismissed) {
+ _animationController.forward();
+ } else if (_animationController.status ==
+ AnimationStatus.completed) {
+ _animationController.reverse();
+ } else if (_animationController.status ==
+ AnimationStatus.forward) {
+ _animationController.reverse();
+ } else if (_animationController.status ==
+ AnimationStatus.reverse) {
+ _animationController.forward();
+ }
+ },
+ onTapUp: (details) {
+ if (_animationController.status == AnimationStatus.forward) {
+ _animationController.reverse();
+ } else if (_animationController.status ==
+ AnimationStatus.reverse) {
+ _animationController.forward();
+ }
+ },
+ child: Container(
+ width: context.width * 06,
+ height: context.width * 0.6,
+ margin: const EdgeInsets.all(10),
+ decoration: const BoxDecoration(
+ boxShadow: [
+ BoxShadow(
+ color: Colors.grey,
+ blurRadius: 18,
+ offset: Offset(6, 7),
+ blurStyle: BlurStyle.outer,
),
- child: Center(
- child: SvgPicture.asset(
- Assets.doorlockAssetsLockIcon,
+ ],
+ color: Color(0xFFEBECED),
+ borderRadius: BorderRadius.all(Radius.circular(999)),
+ ),
+ child: Padding(
+ padding: const EdgeInsets.all(25),
+ child: Stack(
+ alignment: Alignment.center,
+ children: [
+ Container(
+ margin: const EdgeInsets.all(8),
+ decoration: BoxDecoration(
+ color: Colors.white,
+ borderRadius: BorderRadius.circular(999),
+ boxShadow: [
+ BoxShadow(
+ color: Colors.white.withOpacity(0.5),
+ blurRadius: 30,
+ offset: const Offset(-5, -5),
+ blurStyle: BlurStyle.outer,
+ ),
+ BoxShadow(
+ color: Colors.black.withOpacity(0.14),
+ blurRadius: 25,
+ offset: const Offset(5, 5),
+ blurStyle: BlurStyle.outer,
+ ),
+ BoxShadow(
+ color: Colors.black.withOpacity(0.14),
+ blurRadius: 30,
+ offset: const Offset(5, 5),
+ blurStyle: BlurStyle.inner,
+ ),
+ ],
+ ),
+ child: Center(
+ child: SvgPicture.asset(
+ Assets.doorlockAssetsLockIcon,
+ ),
+ ),
),
- ),
+ SizedBox.expand(
+ child: CircularProgressIndicator(
+ value: _animation.value,
+ strokeWidth: 15,
+ backgroundColor: Colors.transparent,
+ valueColor: const AlwaysStoppedAnimation(
+ ColorsManager.primaryColor),
+ ),
+ )
+ ],
),
- SizedBox.expand(
- child: CircularProgressIndicator(
- value: _animation.value,
- strokeWidth: 15,
- backgroundColor: Colors.transparent,
- valueColor: const AlwaysStoppedAnimation(
- ColorsManager.primaryColor),
- ),
- )
- ],
+ ),
),
),
- ),
- ),
+ );
+ },
);
}
}
diff --git a/lib/features/devices/view/widgets/smart_door/door_grid.dart b/lib/features/devices/view/widgets/smart_door/door_grid.dart
index f739291..425778a 100644
--- a/lib/features/devices/view/widgets/smart_door/door_grid.dart
+++ b/lib/features/devices/view/widgets/smart_door/door_grid.dart
@@ -1,5 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
+import 'package:syncrow_app/features/devices/view/widgets/smart_door/members_management_view.dart';
+import 'package:syncrow_app/features/devices/view/widgets/smart_door/smart_linkage_view.dart';
+import 'package:syncrow_app/features/devices/view/widgets/smart_door/unlocking_records_view.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
import 'package:syncrow_app/generated/assets.dart';
@@ -67,12 +70,12 @@ List