mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 09:45:22 +00:00
Added gateway screen and bloc
This commit is contained in:
40
assets/icons/gateway_icon.svg
Normal file
40
assets/icons/gateway_icon.svg
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<svg width="170" height="170" viewBox="0 0 170 170" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<g filter="url(#filter0_di_551_1151)">
|
||||||
|
<path d="M135 75C135 41.8629 108.137 15 75 15C41.8629 15 15 41.8629 15 75C15 108.137 41.8629 135 75 135C108.137 135 135 108.137 135 75Z" fill="white"/>
|
||||||
|
</g>
|
||||||
|
<path d="M50.3906 107.625C49.2571 107.625 48.3398 106.708 48.3398 105.574V101.473C48.3398 100.339 49.2571 99.4219 50.3906 99.4219C51.5242 99.4219 52.4414 100.339 52.4414 101.473V105.574C52.4414 106.708 51.5242 107.625 50.3906 107.625Z" fill="#5C6699"/>
|
||||||
|
<path d="M99.6094 107.625C98.4758 107.625 97.5586 106.708 97.5586 105.574V101.473C97.5586 100.339 98.4758 99.4219 99.6094 99.4219C100.743 99.4219 101.66 100.339 101.66 101.473V105.574C101.66 106.708 100.743 107.625 99.6094 107.625Z" fill="#404A80"/>
|
||||||
|
<path d="M52.6057 81.7709L40.3011 53.0599C39.8564 52.0205 40.3371 50.8149 41.3785 50.3682C42.4079 49.9236 43.6215 50.3983 44.0742 51.4457L56.3789 80.1566C56.8235 81.1961 56.3428 82.4017 55.3014 82.8483C54.2827 83.2883 53.0633 82.8306 52.6057 81.7709Z" fill="#5C6699"/>
|
||||||
|
<path d="M94.6988 82.85C93.6575 82.4034 93.1768 81.1978 93.6214 80.1583L105.926 51.4474C106.379 50.4 107.584 49.9213 108.622 50.3699C109.663 50.8165 110.144 52.0221 109.699 53.0616L97.3945 81.7725C96.9368 82.8325 95.7173 83.2899 94.6988 82.85Z" fill="#404A80"/>
|
||||||
|
<path d="M103.848 103.523H46.1523C42.7598 103.523 40 100.764 40 97.3711V85.0664C40 81.6739 42.7598 78.9141 46.1523 78.9141H103.848C107.24 78.9141 110 81.6739 110 85.0664V97.3711C110 100.764 107.24 103.523 103.848 103.523Z" fill="#C1DCFF"/>
|
||||||
|
<path d="M103.848 78.9141H75V103.523H103.848C107.24 103.523 110 100.764 110 97.3711V85.0664C110 81.6739 107.24 78.9141 103.848 78.9141Z" fill="#D5E8FE"/>
|
||||||
|
<path d="M76.4422 71.3137C76.2178 71.0895 75.7292 70.7109 75.0002 70.7109C74.2712 70.7109 73.7826 71.0895 73.5582 71.3137C72.7572 72.1148 71.4593 72.1148 70.6583 71.3137C69.8572 70.5127 69.8572 69.2148 70.6583 68.4138C71.3312 67.7389 72.7931 66.6094 75.0002 66.6094C77.2072 66.6094 78.6692 67.7389 79.3421 68.4138C80.1431 69.2148 80.1431 70.5127 79.3421 71.3137C78.5411 72.1148 77.2432 72.1149 76.4422 71.3137Z" fill="#80BFFF"/>
|
||||||
|
<path d="M93.8537 53.9202C88.815 48.8774 82.1179 46.1016 75.0002 46.1016C67.8825 46.1016 61.1855 48.8774 56.1467 53.9202C55.3457 54.7213 54.0478 54.7213 53.2468 53.9202C52.4457 53.1192 52.4457 51.8213 53.2468 51.0203C59.0627 45.2044 66.7851 42 75.0002 42C83.2154 42 90.9378 45.2044 96.7537 51.0203C97.5547 51.8213 97.5547 53.1192 96.7537 53.9202C95.9527 54.7213 94.6549 54.7213 93.8537 53.9202Z" fill="#80BFFF"/>
|
||||||
|
<path d="M88.0498 59.7181C84.5611 56.2274 79.9267 54.3047 75.0001 54.3047C70.0734 54.3047 65.4391 56.2274 61.9504 59.7181C61.1494 60.5191 59.8515 60.5191 59.0505 59.7181C58.2494 58.917 58.2494 57.6192 59.0505 56.8181C63.3123 52.5524 68.98 50.2031 75.0001 50.2031C81.0202 50.2031 86.6879 52.5524 90.9497 56.8181C91.7507 57.6192 91.7507 58.917 90.9497 59.7181C90.1487 60.5191 88.8509 60.5191 88.0498 59.7181Z" fill="#80BFFF"/>
|
||||||
|
<path d="M82.2458 65.5158C78.3686 61.6345 71.6313 61.6345 67.7541 65.5158C66.9531 66.3169 65.6552 66.3169 64.8542 65.5158C64.0532 64.7167 64.0532 63.4169 64.8542 62.6159C70.2776 57.1886 79.7224 57.1886 85.1457 62.6159C85.9468 63.4169 85.9468 64.7167 85.1457 65.5158C84.3447 66.3169 83.0469 66.3169 82.2458 65.5158Z" fill="#80BFFF"/>
|
||||||
|
<path d="M83.2031 95.3203C82.0696 95.3203 81.1523 94.4031 81.1523 93.2695V89.168C81.1523 88.0344 82.0696 87.1172 83.2031 87.1172C84.3367 87.1172 85.2539 88.0344 85.2539 89.168V93.2695C85.2539 94.4031 84.3367 95.3203 83.2031 95.3203Z" fill="#6699FF"/>
|
||||||
|
<path d="M91.4062 95.3203C90.2727 95.3203 89.3555 94.4031 89.3555 93.2695V89.168C89.3555 88.0344 90.2727 87.1172 91.4062 87.1172C92.5398 87.1172 93.457 88.0344 93.457 89.168V93.2695C93.457 94.4031 92.5398 95.3203 91.4062 95.3203Z" fill="#6699FF"/>
|
||||||
|
<path d="M99.6094 95.3203C98.4758 95.3203 97.5586 94.4031 97.5586 93.2695V89.168C97.5586 88.0344 98.4758 87.1172 99.6094 87.1172C100.743 87.1172 101.66 88.0344 101.66 89.168V93.2695C101.66 94.4031 100.743 95.3203 99.6094 95.3203Z" fill="#6699FF"/>
|
||||||
|
<path d="M76.442 71.3137C77.243 72.1148 78.5407 72.1149 79.3419 71.3137C80.1429 70.5127 80.1429 69.2148 79.3419 68.4138C78.669 67.7389 77.2071 66.6094 75 66.6094V70.7109C75.729 70.7109 76.2176 71.0895 76.442 71.3137Z" fill="#6699FF"/>
|
||||||
|
<path d="M82.2458 65.5159C83.0469 66.3169 84.3446 66.317 85.1458 65.5159C85.9468 64.7168 85.9468 63.417 85.1458 62.6159C82.4339 59.9022 78.7171 58.5454 75 58.5454V62.6049C77.6536 62.6049 80.3071 63.5753 82.2458 65.5159Z" fill="#6699FF"/>
|
||||||
|
<path d="M88.0497 59.7181C88.8507 60.5191 90.1484 60.5192 90.9496 59.7181C91.7506 58.917 91.7506 57.6192 90.9496 56.8181C86.6878 52.5524 81.0201 50.2031 75 50.2031V54.3047C79.9267 54.3047 84.561 56.2274 88.0497 59.7181Z" fill="#6699FF"/>
|
||||||
|
<path d="M93.8535 53.9202C94.6546 54.7213 95.9523 54.7214 96.7535 53.9202C97.5545 53.1192 97.5545 51.8213 96.7535 51.0203C90.9376 45.2044 83.2152 42 75 42V46.1016C82.1177 46.1016 88.8147 48.8774 93.8535 53.9202Z" fill="#6699FF"/>
|
||||||
|
<defs>
|
||||||
|
<filter id="filter0_di_551_1151" x="0" y="0" width="170" height="170" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||||
|
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||||
|
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
||||||
|
<feOffset dx="10" dy="10"/>
|
||||||
|
<feGaussianBlur stdDeviation="12.5"/>
|
||||||
|
<feComposite in2="hardAlpha" operator="out"/>
|
||||||
|
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.15 0"/>
|
||||||
|
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_551_1151"/>
|
||||||
|
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_551_1151" result="shape"/>
|
||||||
|
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
||||||
|
<feOffset dx="5" dy="5"/>
|
||||||
|
<feGaussianBlur stdDeviation="15"/>
|
||||||
|
<feComposite in2="hardAlpha" operator="arithmetic" k2="-1" k3="1"/>
|
||||||
|
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.05 0"/>
|
||||||
|
<feBlend mode="normal" in2="shape" result="effect2_innerShadow_551_1151"/>
|
||||||
|
</filter>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 6.0 KiB |
@ -1,5 +1,4 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
@ -275,7 +274,7 @@ class HomeCubit extends Cubit<HomeState> {
|
|||||||
size: 25,
|
size: 25,
|
||||||
),
|
),
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
foregroundColor: MaterialStateProperty.all(ColorsManager.textPrimaryColor),
|
foregroundColor: WidgetStateProperty.all(ColorsManager.textPrimaryColor),
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
@ -300,7 +299,7 @@ class HomeCubit extends Cubit<HomeState> {
|
|||||||
size: 25,
|
size: 25,
|
||||||
),
|
),
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
foregroundColor: MaterialStateProperty.all(ColorsManager.textPrimaryColor),
|
foregroundColor: WidgetStateProperty.all(ColorsManager.textPrimaryColor),
|
||||||
),
|
),
|
||||||
onPressed: () {},
|
onPressed: () {},
|
||||||
),
|
),
|
||||||
@ -310,7 +309,7 @@ class HomeCubit extends Cubit<HomeState> {
|
|||||||
size: 25,
|
size: 25,
|
||||||
),
|
),
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
foregroundColor: MaterialStateProperty.all(ColorsManager.textPrimaryColor),
|
foregroundColor: WidgetStateProperty.all(ColorsManager.textPrimaryColor),
|
||||||
),
|
),
|
||||||
onPressed: () {},
|
onPressed: () {},
|
||||||
),
|
),
|
||||||
|
@ -85,10 +85,10 @@ class LoginForm extends StatelessWidget {
|
|||||||
isDone: state is AuthLoginSuccess,
|
isDone: state is AuthLoginSuccess,
|
||||||
isLoading: state is AuthLoading,
|
isLoading: state is AuthLoading,
|
||||||
customButtonStyle: ButtonStyle(
|
customButtonStyle: ButtonStyle(
|
||||||
backgroundColor: MaterialStateProperty.all(
|
backgroundColor: WidgetStateProperty.all(
|
||||||
Colors.black.withOpacity(.25),
|
Colors.black.withOpacity(.25),
|
||||||
),
|
),
|
||||||
foregroundColor: MaterialStateProperty.all(
|
foregroundColor: WidgetStateProperty.all(
|
||||||
Colors.white,
|
Colors.white,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -87,8 +87,8 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
return const CurtainListView();
|
return const CurtainListView();
|
||||||
// case DeviceType.ThreeGang:
|
// case DeviceType.ThreeGang:
|
||||||
// return const ThreeGangSwitchesView();
|
// return const ThreeGangSwitchesView();
|
||||||
case DeviceType.Gateway:
|
// case DeviceType.Gateway:
|
||||||
return const GateWayView();
|
// return const GateWayView();
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
23
lib/features/devices/bloc/gateway_bloc/gateway_bloc.dart
Normal file
23
lib/features/devices/bloc/gateway_bloc/gateway_bloc.dart
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/bloc/gateway_bloc/gateway_event.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/bloc/gateway_bloc/gateway_state.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||||
|
import 'package:syncrow_app/services/api/devices_api.dart';
|
||||||
|
|
||||||
|
class GatewayBloc extends Bloc<GatewayEvent, GatewayState> {
|
||||||
|
GatewayBloc() : super(GatewayInitialState()) {
|
||||||
|
on<GatewayInitial>(_fetchDevices);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _fetchDevices(GatewayInitial event, Emitter<GatewayState> emit) async {
|
||||||
|
emit(GatewayLoadingState());
|
||||||
|
try {
|
||||||
|
List<DeviceModel> devicesList = await DevicesAPI.getDevicesByGatewayId(event.gatewayId);
|
||||||
|
|
||||||
|
emit(UpdateGatewayState(list: devicesList));
|
||||||
|
} catch (e) {
|
||||||
|
emit(ErrorState(message: e.toString()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
20
lib/features/devices/bloc/gateway_bloc/gateway_event.dart
Normal file
20
lib/features/devices/bloc/gateway_bloc/gateway_event.dart
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import 'package:equatable/equatable.dart';
|
||||||
|
|
||||||
|
abstract class GatewayEvent extends Equatable {
|
||||||
|
const GatewayEvent();
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [];
|
||||||
|
}
|
||||||
|
|
||||||
|
class GatewayInitial extends GatewayEvent {
|
||||||
|
final String gatewayId;
|
||||||
|
const GatewayInitial({required this.gatewayId});
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [gatewayId];
|
||||||
|
}
|
||||||
|
|
||||||
|
class GatewayLoading extends GatewayEvent {}
|
||||||
|
|
||||||
|
class GatewayUpdateState extends GatewayEvent {}
|
29
lib/features/devices/bloc/gateway_bloc/gateway_state.dart
Normal file
29
lib/features/devices/bloc/gateway_bloc/gateway_state.dart
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import 'package:equatable/equatable.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||||
|
|
||||||
|
abstract class GatewayState extends Equatable {
|
||||||
|
const GatewayState();
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [];
|
||||||
|
}
|
||||||
|
|
||||||
|
class GatewayInitialState extends GatewayState {}
|
||||||
|
|
||||||
|
class GatewayLoadingState extends GatewayState {}
|
||||||
|
|
||||||
|
class UpdateGatewayState extends GatewayState {
|
||||||
|
final List<DeviceModel> list;
|
||||||
|
const UpdateGatewayState({required this.list});
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [list];
|
||||||
|
}
|
||||||
|
|
||||||
|
class ErrorState extends GatewayState {
|
||||||
|
final String message;
|
||||||
|
const ErrorState({required this.message});
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [message];
|
||||||
|
}
|
@ -1,10 +1,128 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/bloc/gateway_bloc/gateway_bloc.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/bloc/gateway_bloc/gateway_event.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/bloc/gateway_bloc/gateway_state.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/view/widgets/room_page_switch.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/generated/assets.dart';
|
||||||
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||||
|
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||||
|
import 'package:syncrow_app/utils/resource_manager/font_manager.dart';
|
||||||
|
|
||||||
class GateWayView extends StatelessWidget {
|
class GateWayView extends StatelessWidget {
|
||||||
const GateWayView({super.key});
|
final DeviceModel gatewayObj;
|
||||||
|
|
||||||
|
const GateWayView({required this.gatewayObj, super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return const Placeholder();
|
return BlocProvider(
|
||||||
|
create: (context) => GatewayBloc()..add(GatewayInitial(gatewayId: gatewayObj.uuid ?? '')),
|
||||||
|
child: BlocBuilder<GatewayBloc, GatewayState>(builder: (context, state) {
|
||||||
|
List<DeviceModel> devicesList = [];
|
||||||
|
if (state is UpdateGatewayState) {
|
||||||
|
devicesList = state.list;
|
||||||
|
}
|
||||||
|
return AnnotatedRegion(
|
||||||
|
value: SystemUiOverlayStyle(
|
||||||
|
statusBarColor: ColorsManager.primaryColor.withOpacity(0.5),
|
||||||
|
statusBarIconBrightness: Brightness.light,
|
||||||
|
),
|
||||||
|
child: Scaffold(
|
||||||
|
backgroundColor: ColorsManager.backgroundColor,
|
||||||
|
extendBodyBehindAppBar: true,
|
||||||
|
extendBody: true,
|
||||||
|
appBar: AppBar(
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
centerTitle: true,
|
||||||
|
title: const BodyLarge(
|
||||||
|
text: 'Gateway',
|
||||||
|
fontColor: ColorsManager.primaryColor,
|
||||||
|
fontWeight: FontsManager.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
body: Container(
|
||||||
|
width: MediaQuery.sizeOf(context).width,
|
||||||
|
height: MediaQuery.sizeOf(context).height,
|
||||||
|
padding: const EdgeInsets.all(Constants.defaultPadding),
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
image: DecorationImage(
|
||||||
|
image: AssetImage(
|
||||||
|
Assets.assetsImagesBackground,
|
||||||
|
),
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
opacity: 0.4,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: SafeArea(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
height: MediaQuery.sizeOf(context).height * 0.3,
|
||||||
|
width: MediaQuery.sizeOf(context).width,
|
||||||
|
alignment: AlignmentDirectional.center,
|
||||||
|
child: Stack(children: [
|
||||||
|
SvgPicture.asset(
|
||||||
|
Assets.gatewayIcon,
|
||||||
|
width: 125,
|
||||||
|
height: 125,
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
right: 30,
|
||||||
|
top: 15,
|
||||||
|
child: Container(
|
||||||
|
width: 12,
|
||||||
|
height: 12,
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
color: ColorsManager.lightGreen,
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
const BodyMedium(
|
||||||
|
text: 'Zigbee Devices',
|
||||||
|
fontSize: 15,
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
state is GatewayLoadingState
|
||||||
|
? Center(
|
||||||
|
child: Container(
|
||||||
|
margin: const EdgeInsets.only(top: 20),
|
||||||
|
height: 50,
|
||||||
|
width: 50,
|
||||||
|
child: const RefreshProgressIndicator()),
|
||||||
|
)
|
||||||
|
: Expanded(
|
||||||
|
child: GridView.builder(
|
||||||
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
|
crossAxisCount: 2,
|
||||||
|
crossAxisSpacing: 10,
|
||||||
|
mainAxisSpacing: 10,
|
||||||
|
childAspectRatio: 1.5,
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.only(top: 10),
|
||||||
|
shrinkWrap: true,
|
||||||
|
itemCount: devicesList.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
return RoomPageSwitch(device: devicesList[index]);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)));
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,20 +3,18 @@
|
|||||||
/// This widget displays the icon and name of the device, along with a switch
|
/// This widget displays the icon and name of the device, along with a switch
|
||||||
/// to control its state. Tapping on the widget opens the device interface.
|
/// to control its state. Tapping on the widget opens the device interface.
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart';
|
import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/ACs/acs_view.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/ACs/acs_view.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/view/widgets/gateway/gateway_view.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/lights/light_interface.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/lights/light_interface.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/wall_sensor/wall_sensor_interface.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/wall_sensor/wall_sensor_interface.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/ceiling_sensor/ceiling_sensor_interface.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/ceiling_sensor/ceiling_sensor_interface.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/smart_door/door_interface.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/smart_door/door_interface.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/three_gang/three_gang_interface.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/three_gang/three_gang_interface.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/custom_switch.dart';
|
|
||||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
|
||||||
import 'package:syncrow_app/utils/context_extension.dart';
|
import 'package:syncrow_app/utils/context_extension.dart';
|
||||||
import 'package:syncrow_app/utils/helpers/custom_page_route.dart';
|
import 'package:syncrow_app/utils/helpers/custom_page_route.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||||
@ -31,46 +29,44 @@ class RoomPageSwitch extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return InkWell(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
showDeviceInterface(device, context);
|
showDeviceInterface(device, context);
|
||||||
},
|
},
|
||||||
child: DefaultContainer(
|
child: DefaultContainer(
|
||||||
child: Padding(
|
padding: const EdgeInsets.all(15),
|
||||||
padding: const EdgeInsets.only(top: 10, right: 10, left: 10),
|
child: Column(
|
||||||
child: Column(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
children: [
|
||||||
children: [
|
Row(
|
||||||
Row(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
children: [
|
||||||
children: [
|
SvgPicture.asset(
|
||||||
SvgPicture.asset(
|
device.icon!,
|
||||||
device.icon!,
|
fit: BoxFit.contain,
|
||||||
fit: BoxFit.contain,
|
),
|
||||||
),
|
// CustomSwitch(
|
||||||
CustomSwitch(
|
// device: device,
|
||||||
device: device,
|
// ),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
Flexible(
|
||||||
Expanded(
|
child: FittedBox(
|
||||||
child: FittedBox(
|
child: Text(
|
||||||
fit: BoxFit.scaleDown,
|
device.name ?? "",
|
||||||
child: BodyLarge(
|
overflow: TextOverflow.ellipsis,
|
||||||
text: device.name ?? "",
|
maxLines: 2,
|
||||||
style: context.bodyLarge.copyWith(
|
style: context.bodyLarge.copyWith(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
height: 0,
|
fontSize: 20,
|
||||||
fontSize: 24,
|
color: Colors.grey,
|
||||||
color: Colors.grey,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -117,6 +113,10 @@ void showDeviceInterface(DeviceModel device, BuildContext context) {
|
|||||||
// navigateToInterface(DoorInterface(doorlock: device), context);
|
// navigateToInterface(DoorInterface(doorlock: device), context);
|
||||||
break;
|
break;
|
||||||
case DeviceType.Gateway:
|
case DeviceType.Gateway:
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
PageRouteBuilder(
|
||||||
|
pageBuilder: (context, animation1, animation2) => GateWayView(gatewayObj: device)));
|
||||||
break;
|
break;
|
||||||
case DeviceType.LightBulb:
|
case DeviceType.LightBulb:
|
||||||
navigateToInterface(LightInterface(light: device), context);
|
navigateToInterface(LightInterface(light: device), context);
|
||||||
|
@ -651,6 +651,7 @@ class Assets {
|
|||||||
static const String emptyCheckboxIcon = "assets/icons/empty_checkbox_ic.svg";
|
static const String emptyCheckboxIcon = "assets/icons/empty_checkbox_ic.svg";
|
||||||
static const String pauseIcon = "assets/icons/pause_ic.svg";
|
static const String pauseIcon = "assets/icons/pause_ic.svg";
|
||||||
static const String playIcon = "assets/icons/play_ic.svg";
|
static const String playIcon = "assets/icons/play_ic.svg";
|
||||||
|
static const String gatewayIcon = "assets/icons/gateway_icon.svg";
|
||||||
|
|
||||||
/// Assets for assetsImagesAutomation
|
/// Assets for assetsImagesAutomation
|
||||||
/// assets/images/automation.jpg
|
/// assets/images/automation.jpg
|
||||||
|
@ -96,6 +96,7 @@ abstract class ApiEndpoints {
|
|||||||
static const String deviceByRoom = '$baseUrl/device/room';
|
static const String deviceByRoom = '$baseUrl/device/room';
|
||||||
static const String deviceByUuid = '$baseUrl/device/{deviceUuid}';
|
static const String deviceByUuid = '$baseUrl/device/{deviceUuid}';
|
||||||
static const String deviceFunctions = '$baseUrl/device/{deviceUuid}/functions';
|
static const String deviceFunctions = '$baseUrl/device/{deviceUuid}/functions';
|
||||||
|
static const String gatewayApi = '$baseUrl/device/getaway/{gatewayUuid}/devices';
|
||||||
static const String deviceFunctionsStatus = '$baseUrl/device/{deviceUuid}/functions/status';
|
static const String deviceFunctionsStatus = '$baseUrl/device/{deviceUuid}/functions/status';
|
||||||
|
|
||||||
///Device Permission Module
|
///Device Permission Module
|
||||||
|
@ -50,7 +50,6 @@ class DevicesAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Future<List<DeviceModel>> getDevicesByRoomId(String roomId) async {
|
static Future<List<DeviceModel>> getDevicesByRoomId(String roomId) async {
|
||||||
// print("Room ID: $roomId");
|
|
||||||
final response = await _httpService.get(
|
final response = await _httpService.get(
|
||||||
path: ApiEndpoints.deviceByRoom,
|
path: ApiEndpoints.deviceByRoom,
|
||||||
queryParameters: {"roomUuid": roomId},
|
queryParameters: {"roomUuid": roomId},
|
||||||
@ -68,4 +67,22 @@ class DevicesAPI {
|
|||||||
);
|
);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Future<List<DeviceModel>> getDevicesByGatewayId(String gatewayId) async {
|
||||||
|
final response = await _httpService.get(
|
||||||
|
path: ApiEndpoints.gatewayApi.replaceAll('{gatewayUuid}', gatewayId),
|
||||||
|
showServerMessage: false,
|
||||||
|
expectedResponseModel: (json) {
|
||||||
|
List<DeviceModel> devices = [];
|
||||||
|
if (json == null || json.isEmpty || json == []) {
|
||||||
|
return devices;
|
||||||
|
}
|
||||||
|
for (var device in json['devices']) {
|
||||||
|
devices.add(DeviceModel.fromJson(device));
|
||||||
|
}
|
||||||
|
return devices;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,4 +20,5 @@ abstract class ColorsManager {
|
|||||||
static const Color dividerColor = Color(0xFFEBEBEB);
|
static const Color dividerColor = Color(0xFFEBEBEB);
|
||||||
static const Color slidingBlueColor = Color(0x99023DFE);
|
static const Color slidingBlueColor = Color(0x99023DFE);
|
||||||
static const Color blackColor = Color(0xFF000000);
|
static const Color blackColor = Color(0xFF000000);
|
||||||
|
static const Color lightGreen = Color(0xFF00FF0A);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user