bug fixes and read sensors states

This commit is contained in:
Abdullah Alassaf
2024-06-06 11:14:25 +03:00
parent 631ba53d7a
commit 76f5c6d325
20 changed files with 561 additions and 547 deletions

View File

@ -177,6 +177,8 @@ PODS:
- PromisesObjC (2.3.1) - PromisesObjC (2.3.1)
- PromisesSwift (2.3.1): - PromisesSwift (2.3.1):
- PromisesObjC (= 2.3.1) - PromisesObjC (= 2.3.1)
- share_plus (0.0.1):
- Flutter
- shared_preferences_foundation (0.0.1): - shared_preferences_foundation (0.0.1):
- Flutter - Flutter
- FlutterMacOS - FlutterMacOS
@ -196,6 +198,7 @@ DEPENDENCIES:
- onesignal_flutter (from `.symlinks/plugins/onesignal_flutter/ios`) - onesignal_flutter (from `.symlinks/plugins/onesignal_flutter/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`) - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`) - permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
- share_plus (from `.symlinks/plugins/share_plus/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`) - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- sqflite (from `.symlinks/plugins/sqflite/darwin`) - sqflite (from `.symlinks/plugins/sqflite/darwin`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
@ -237,6 +240,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/path_provider_foundation/darwin" :path: ".symlinks/plugins/path_provider_foundation/darwin"
permission_handler_apple: permission_handler_apple:
:path: ".symlinks/plugins/permission_handler_apple/ios" :path: ".symlinks/plugins/permission_handler_apple/ios"
share_plus:
:path: ".symlinks/plugins/share_plus/ios"
shared_preferences_foundation: shared_preferences_foundation:
:path: ".symlinks/plugins/shared_preferences_foundation/darwin" :path: ".symlinks/plugins/shared_preferences_foundation/darwin"
sqflite: sqflite:
@ -269,6 +274,7 @@ SPEC CHECKSUMS:
permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2 permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2
PromisesObjC: c50d2056b5253dadbd6c2bea79b0674bd5a52fa4 PromisesObjC: c50d2056b5253dadbd6c2bea79b0674bd5a52fa4
PromisesSwift: 28dca69a9c40779916ac2d6985a0192a5cb4a265 PromisesSwift: 28dca69a9c40779916ac2d6985a0192a5cb4a265
share_plus: 8875f4f2500512ea181eef553c3e27dba5135aad
shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695 shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695
sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec
url_launcher_ios: bbd758c6e7f9fd7b5b1d4cde34d2b95fcce5e812 url_launcher_ios: bbd758c6e7f9fd7b5b1d4cde34d2b95fcce5e812

View File

@ -208,6 +208,7 @@ class AuthCubit extends Cubit<AuthState> {
sendOtp() async { sendOtp() async {
try { try {
emit(AuthLoading());
await AuthenticationAPI.sendOtp(body: {'email': email, 'type': 'VERIFICATION'}); await AuthenticationAPI.sendOtp(body: {'email': email, 'type': 'VERIFICATION'});
emit(AuthSignUpSuccess()); emit(AuthSignUpSuccess());
} catch (_) { } catch (_) {
@ -217,6 +218,7 @@ class AuthCubit extends Cubit<AuthState> {
reSendOtp() async { reSendOtp() async {
try { try {
emit(AuthLoading());
await AuthenticationAPI.sendOtp(body: {'email': email, 'type': 'VERIFICATION'}); await AuthenticationAPI.sendOtp(body: {'email': email, 'type': 'VERIFICATION'});
emit(ResendOtpSuccess()); emit(ResendOtpSuccess());
} catch (_) { } catch (_) {

View File

@ -1,5 +1,7 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.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/auth/bloc/auth_cubit.dart'; import 'package:syncrow_app/features/auth/bloc/auth_cubit.dart';
@ -35,33 +37,33 @@ class LoginView extends StatelessWidget {
}, },
builder: (context, state) { builder: (context, state) {
return Scaffold( return Scaffold(
body: SafeArea( body: Stack(
child: Stack( children: [
children: [ Container(
Container( width: MediaQuery.sizeOf(context).width,
width: MediaQuery.sizeOf(context).width, height: MediaQuery.sizeOf(context).height,
height: MediaQuery.sizeOf(context).height, decoration: const BoxDecoration(
decoration: const BoxDecoration( image: DecorationImage(
image: DecorationImage( image: AssetImage(
image: AssetImage( Assets.assetsImagesBackground,
Assets.assetsImagesBackground,
),
fit: BoxFit.cover,
), ),
fit: BoxFit.cover,
), ),
), ),
Container( ),
width: MediaQuery.sizeOf(context).width, Container(
height: MediaQuery.sizeOf(context).height, width: MediaQuery.sizeOf(context).width,
decoration: const BoxDecoration( height: MediaQuery.sizeOf(context).height,
image: DecorationImage( decoration: const BoxDecoration(
image: AssetImage(Assets.assetsImagesVector), image: DecorationImage(
fit: BoxFit.cover, image: AssetImage(Assets.assetsImagesVector),
opacity: 0.9, fit: BoxFit.cover,
), opacity: 0.9,
), ),
), ),
Padding( ),
SafeArea(
child: Padding(
padding: const EdgeInsets.only( padding: const EdgeInsets.only(
right: Constants.defaultPadding, right: Constants.defaultPadding,
left: Constants.defaultPadding, left: Constants.defaultPadding,
@ -100,9 +102,9 @@ class LoginView extends StatelessWidget {
), ),
), ),
), ),
) ),
], )
), ],
), ),
); );
}, },

View File

@ -1,4 +1,5 @@
import 'dart:async'; import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
@ -116,7 +117,9 @@ class _OtpViewState extends State<OtpView> {
return BlocConsumer<AuthCubit, AuthState>( return BlocConsumer<AuthCubit, AuthState>(
listener: (context, state) { listener: (context, state) {
if (state is AuthOtpSuccess) { if (state is AuthOtpSuccess) {
Navigator.pushNamedAndRemoveUntil(context, Routes.homeRoute, (value) => false); Navigator.of(context).pop();
Navigator.of(context).pop();
Navigator.popAndPushNamed(context, Routes.homeRoute);
} }
if (state is ResendOtpSuccess) { if (state is ResendOtpSuccess) {
startTimer(30); startTimer(30);
@ -124,33 +127,33 @@ class _OtpViewState extends State<OtpView> {
}, },
builder: (context, state) { builder: (context, state) {
return Scaffold( return Scaffold(
body: SafeArea( body: Stack(
child: Stack( children: [
children: [ Container(
Container( width: MediaQuery.sizeOf(context).width,
width: MediaQuery.sizeOf(context).width, height: MediaQuery.sizeOf(context).height,
height: MediaQuery.sizeOf(context).height, decoration: const BoxDecoration(
decoration: const BoxDecoration( image: DecorationImage(
image: DecorationImage( image: AssetImage(
image: AssetImage( Assets.assetsImagesBackground,
Assets.assetsImagesBackground,
),
fit: BoxFit.cover,
), ),
fit: BoxFit.cover,
), ),
), ),
Container( ),
width: MediaQuery.sizeOf(context).width, Container(
height: MediaQuery.sizeOf(context).height, width: MediaQuery.sizeOf(context).width,
decoration: const BoxDecoration( height: MediaQuery.sizeOf(context).height,
image: DecorationImage( decoration: const BoxDecoration(
image: AssetImage(Assets.assetsImagesVector), image: DecorationImage(
fit: BoxFit.cover, image: AssetImage(Assets.assetsImagesVector),
opacity: 0.9, fit: BoxFit.cover,
), opacity: 0.9,
), ),
), ),
Padding( ),
SafeArea(
child: Padding(
padding: const EdgeInsets.only( padding: const EdgeInsets.only(
right: Constants.defaultPadding, right: Constants.defaultPadding,
left: Constants.defaultPadding, left: Constants.defaultPadding,
@ -181,33 +184,38 @@ class _OtpViewState extends State<OtpView> {
const SizedBox( const SizedBox(
height: 20, height: 20,
), ),
RichText( GestureDetector(
text: TextSpan( onTap: () {
text: Navigator.of(context).pop();
'We have sent the verification codeWe have sent the verification code to', },
style: Theme.of(context).textTheme.titleSmall!.copyWith( child: RichText(
color: Colors.white, text: TextSpan(
fontWeight: FontsManager.regular, text:
fontSize: 14, 'We have sent the verification codeWe have sent the verification code to',
style: Theme.of(context).textTheme.titleSmall!.copyWith(
color: Colors.white,
fontWeight: FontsManager.regular,
fontSize: 14,
),
children: [
TextSpan(
text: ' $maskedEmail',
style: Theme.of(context).textTheme.titleSmall!.copyWith(
color: Colors.black,
fontWeight: FontsManager.bold,
fontSize: 14,
),
), ),
children: [ TextSpan(
TextSpan( text: ' change email?',
text: ' $maskedEmail', style: Theme.of(context).textTheme.titleSmall!.copyWith(
style: Theme.of(context).textTheme.titleSmall!.copyWith( color: const Color(0xFF87C7FF),
color: Colors.black, fontWeight: FontsManager.regular,
fontWeight: FontsManager.bold, fontSize: 14,
fontSize: 14, ),
), ),
), ]),
TextSpan( ),
text: ' change email?',
style: Theme.of(context).textTheme.titleSmall!.copyWith(
color: const Color(0xFF87C7FF),
fontWeight: FontsManager.regular,
fontSize: 14,
),
),
]),
), ),
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
@ -326,7 +334,7 @@ class _OtpViewState extends State<OtpView> {
return; return;
} }
if ((state is! AuthLoading)) { if ((state is! AuthLoading)) {
await AuthCubit.get(context).sendOtp(); await AuthCubit.get(context).reSendOtp();
FocusScope.of(context).unfocus(); FocusScope.of(context).unfocus();
} }
}, },
@ -340,9 +348,9 @@ class _OtpViewState extends State<OtpView> {
), ),
), ),
), ),
) ),
], )
), ],
), ),
); );
}, },

View File

@ -1,4 +1,5 @@
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/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'package:syncrow_app/features/auth/bloc/auth_cubit.dart'; import 'package:syncrow_app/features/auth/bloc/auth_cubit.dart';
@ -21,39 +22,40 @@ class SignUpView extends StatelessWidget {
return BlocConsumer<AuthCubit, AuthState>( return BlocConsumer<AuthCubit, AuthState>(
listener: (context, state) { listener: (context, state) {
if (state is AuthSignUpSuccess) { if (state is AuthSignUpSuccess) {
Navigator.popAndPushNamed(context, Routes.otpRoute); Navigator.pushNamed(context, Routes.otpRoute);
// Navigator.popAndPushNamed(context, Routes.otpRoute);
} }
}, },
builder: (context, state) { builder: (context, state) {
return Scaffold( return Scaffold(
body: SafeArea( body: Stack(
child: Stack( children: [
children: [ Container(
Container( width: MediaQuery.sizeOf(context).width,
width: MediaQuery.sizeOf(context).width, height: MediaQuery.sizeOf(context).height,
height: MediaQuery.sizeOf(context).height, padding: const EdgeInsets.symmetric(vertical: 24),
padding: const EdgeInsets.symmetric(vertical: 24), decoration: const BoxDecoration(
decoration: const BoxDecoration( image: DecorationImage(
image: DecorationImage( image: AssetImage(
image: AssetImage( Assets.assetsImagesBackground,
Assets.assetsImagesBackground,
),
fit: BoxFit.cover,
), ),
fit: BoxFit.cover,
), ),
), ),
Container( ),
width: MediaQuery.sizeOf(context).width, Container(
height: MediaQuery.sizeOf(context).height, width: MediaQuery.sizeOf(context).width,
decoration: const BoxDecoration( height: MediaQuery.sizeOf(context).height,
image: DecorationImage( decoration: const BoxDecoration(
image: AssetImage(Assets.assetsImagesVector), image: DecorationImage(
fit: BoxFit.cover, image: AssetImage(Assets.assetsImagesVector),
opacity: 0.9, fit: BoxFit.cover,
), opacity: 0.9,
), ),
), ),
Padding( ),
SafeArea(
child: Padding(
padding: const EdgeInsets.only( padding: const EdgeInsets.only(
right: Constants.defaultPadding, right: Constants.defaultPadding,
left: Constants.defaultPadding, left: Constants.defaultPadding,
@ -125,6 +127,7 @@ class SignUpView extends StatelessWidget {
keyboardType: TextInputType.text, keyboardType: TextInputType.text,
scrollPadding: EdgeInsets.zero, scrollPadding: EdgeInsets.zero,
autocorrect: false, autocorrect: false,
enableSuggestions: false,
autofillHints: const [AutofillHints.email], autofillHints: const [AutofillHints.email],
validator: AuthCubit.get(context).emailAddressValidator, validator: AuthCubit.get(context).emailAddressValidator,
onTapOutside: (event) { onTapOutside: (event) {
@ -170,6 +173,7 @@ class SignUpView extends StatelessWidget {
keyboardType: TextInputType.text, keyboardType: TextInputType.text,
scrollPadding: EdgeInsets.zero, scrollPadding: EdgeInsets.zero,
autocorrect: false, autocorrect: false,
enableSuggestions: false,
autofillHints: const [AutofillHints.password], autofillHints: const [AutofillHints.password],
onChanged: (value) {}, onChanged: (value) {},
validator: AuthCubit.get(context).reEnterPasswordCheck, validator: AuthCubit.get(context).reEnterPasswordCheck,
@ -220,9 +224,9 @@ class SignUpView extends StatelessWidget {
), ),
), ),
), ),
) ),
], )
), ],
), ),
); );
}, },

View File

@ -23,7 +23,8 @@ part 'devices_state.dart';
class DevicesCubit extends Cubit<DevicesState> { class DevicesCubit extends Cubit<DevicesState> {
DevicesCubit._() : super(DevicesInitial()) { DevicesCubit._() : super(DevicesInitial()) {
if (HomeCubit.getInstance().selectedSpace != null) { if (HomeCubit.getInstance().selectedSpace != null &&
HomeCubit.getInstance().spaces!.isNotEmpty) {
// fetchGroups(HomeCubit.getInstance().selectedSpace!.id!); // fetchGroups(HomeCubit.getInstance().selectedSpace!.id!);
for (var room in HomeCubit.getInstance().selectedSpace!.rooms!) { for (var room in HomeCubit.getInstance().selectedSpace!.rooms!) {
fetchDevicesByRoomId(room.id!); fetchDevicesByRoomId(room.id!);

View File

@ -5,7 +5,6 @@ import 'package:syncrow_app/features/devices/bloc/acs_bloc/acs_state.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/ac_interface_controls.dart'; import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_interface_controls.dart';
import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_interface_temp_unit.dart'; import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_interface_temp_unit.dart';
import 'package:syncrow_app/generated/assets.dart';
class AcInterface extends StatelessWidget { class AcInterface extends StatelessWidget {
const AcInterface({super.key, required this.ac}); const AcInterface({super.key, required this.ac});
@ -31,43 +30,30 @@ class AcInterface extends StatelessWidget {
// extendBodyBehindAppBar: true, // extendBodyBehindAppBar: true,
// extendBody: true, // extendBody: true,
// body: // body:
Container( SingleChildScrollView(
width: MediaQuery.sizeOf(context).width, child: Column(
height: MediaQuery.sizeOf(context).height, crossAxisAlignment: CrossAxisAlignment.stretch,
decoration: const BoxDecoration( children: [
image: DecorationImage( ConstrainedBox(
image: AssetImage( constraints: const BoxConstraints(
Assets.assetsImagesBackground, maxHeight: 380,
),
child: AcInterfaceTempUnit(
acDevice: ac,
),
), ),
fit: BoxFit.cover, const SizedBox(
opacity: 0.4, height: 10,
), ),
), ConstrainedBox(
child: SingleChildScrollView( constraints: const BoxConstraints(
child: Column( maxHeight: 130,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
ConstrainedBox(
constraints: const BoxConstraints(
maxHeight: 380,
),
child: AcInterfaceTempUnit(
acDevice: ac,
),
), ),
const SizedBox( child: AcInterfaceControls(
height: 10, deviceModel: ac,
), ),
ConstrainedBox( ),
constraints: const BoxConstraints( ],
maxHeight: 130,
),
child: AcInterfaceControls(
deviceModel: ac,
),
),
],
),
), ),
); );
// ); // );

View File

@ -1,4 +1,5 @@
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_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/acs_bloc/acs_bloc.dart'; import 'package:syncrow_app/features/devices/bloc/acs_bloc/acs_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/acs_bloc/acs_event.dart'; import 'package:syncrow_app/features/devices/bloc/acs_bloc/acs_event.dart';
@ -8,9 +9,11 @@ import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_interface.dart'
import 'package:syncrow_app/features/devices/view/widgets/ACs/acs_list.dart'; import 'package:syncrow_app/features/devices/view/widgets/ACs/acs_list.dart';
import 'package:syncrow_app/features/devices/view/widgets/ACs/category_view_app_bar.dart'; import 'package:syncrow_app/features/devices/view/widgets/ACs/category_view_app_bar.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/resource_manager/color_manager.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/constants.dart';
import 'package:syncrow_app/generated/assets.dart'; import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/utils/resource_manager/font_manager.dart';
class ACsView extends StatelessWidget { class ACsView extends StatelessWidget {
final DeviceModel? deviceModel; final DeviceModel? deviceModel;
@ -27,17 +30,28 @@ class ACsView extends StatelessWidget {
// if (DevicesCubit.getInstance().getSelectedDevice() is DeviceModel) { // if (DevicesCubit.getInstance().getSelectedDevice() is DeviceModel) {
// selectedAC = DevicesCubit.getInstance().getSelectedDevice() as DeviceModel; // selectedAC = DevicesCubit.getInstance().getSelectedDevice() as DeviceModel;
// } // }
return Scaffold( return AnnotatedRegion(
backgroundColor: ColorsManager.backgroundColor, value: SystemUiOverlayStyle(
// extendBodyBehindAppBar: true, statusBarColor: ColorsManager.primaryColor.withOpacity(0.5),
// extendBody: true, statusBarIconBrightness: Brightness.light,
appBar: CategoryViewAppBar(
title: deviceModel?.name ?? '',
), ),
body: SafeArea( child: Scaffold(
child: Container( backgroundColor: ColorsManager.backgroundColor,
extendBodyBehindAppBar: true,
extendBody: true,
appBar: AppBar(
backgroundColor: Colors.transparent,
centerTitle: true,
title: BodyLarge(
text: deviceModel?.name ?? "",
fontColor: ColorsManager.primaryColor,
fontWeight: FontsManager.bold,
),
),
body: Container(
width: MediaQuery.sizeOf(context).width, width: MediaQuery.sizeOf(context).width,
height: MediaQuery.sizeOf(context).height, height: MediaQuery.sizeOf(context).height,
padding: const EdgeInsets.all(Constants.defaultPadding),
decoration: const BoxDecoration( decoration: const BoxDecoration(
image: DecorationImage( image: DecorationImage(
image: AssetImage( image: AssetImage(
@ -47,21 +61,16 @@ class ACsView extends StatelessWidget {
opacity: 0.4, opacity: 0.4,
), ),
), ),
child: Padding( child: state is AcsLoadingState
padding: const EdgeInsets.only( ? const Center(
top: Constants.defaultPadding, child: DefaultContainer(
left: Constants.defaultPadding, width: 50, height: 50, child: CircularProgressIndicator()),
right: Constants.defaultPadding, )
), : Container(
child: state is AcsLoadingState padding: const EdgeInsets.only(top: 25),
? const Center( alignment: AlignmentDirectional.center,
child: DefaultContainer( child: deviceModel != null ? AcInterface(ac: deviceModel!) : ACsList(),
width: 50, height: 50, child: CircularProgressIndicator()), ),
)
: SizedBox.expand(
child: deviceModel != null ? AcInterface(ac: deviceModel!) : ACsList(),
),
),
), ),
), ),
); );

View File

@ -3,7 +3,6 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'package:syncrow_app/features/devices/bloc/acs_bloc/acs_bloc.dart'; import 'package:syncrow_app/features/devices/bloc/acs_bloc/acs_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/acs_bloc/acs_state.dart'; import 'package:syncrow_app/features/devices/bloc/acs_bloc/acs_state.dart';
import 'package:syncrow_app/features/devices/bloc/devices_cubit.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/features/shared_widgets/text_widgets/body_large.dart';
import 'package:syncrow_app/utils/context_extension.dart'; import 'package:syncrow_app/utils/context_extension.dart';

View File

@ -20,8 +20,6 @@ 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/constants.dart';
import 'package:syncrow_app/utils/resource_manager/font_manager.dart'; import 'package:syncrow_app/utils/resource_manager/font_manager.dart';
import '../wall_sensor/wall_sensor_interface.dart';
class CeilingSensorInterface extends StatelessWidget { class CeilingSensorInterface extends StatelessWidget {
const CeilingSensorInterface({super.key, required this.ceilingSensor}); const CeilingSensorInterface({super.key, required this.ceilingSensor});
final DeviceModel ceilingSensor; final DeviceModel ceilingSensor;
@ -47,83 +45,86 @@ class CeilingSensorInterface extends StatelessWidget {
statusBarColor: ColorsManager.primaryColor.withOpacity(0.5), statusBarColor: ColorsManager.primaryColor.withOpacity(0.5),
statusBarIconBrightness: Brightness.light, statusBarIconBrightness: Brightness.light,
), ),
child: SafeArea( child: Scaffold(
child: Scaffold( backgroundColor: ColorsManager.backgroundColor,
backgroundColor: ColorsManager.backgroundColor, extendBodyBehindAppBar: true,
extendBodyBehindAppBar: true, extendBody: true,
extendBody: true, appBar: AppBar(
appBar: AppBar( backgroundColor: Colors.transparent,
backgroundColor: Colors.transparent, centerTitle: true,
centerTitle: true, title: BodyLarge(
title: BodyLarge( text: ceilingSensor.name ?? "",
text: ceilingSensor.name ?? "", fontColor: ColorsManager.primaryColor,
fontColor: ColorsManager.primaryColor, fontWeight: FontsManager.bold,
fontWeight: FontsManager.bold,
),
), ),
body: state is LoadingInitialState ),
? const Center( body: Container(
child: RefreshProgressIndicator(), width: MediaQuery.sizeOf(context).width,
) height: MediaQuery.sizeOf(context).height,
: Container( padding: const EdgeInsets.all(Constants.defaultPadding),
width: MediaQuery.sizeOf(context).width, decoration: const BoxDecoration(
height: MediaQuery.sizeOf(context).height, image: DecorationImage(
padding: const EdgeInsets.all(Constants.defaultPadding), image: AssetImage(
decoration: const BoxDecoration( Assets.assetsImagesBackground,
image: DecorationImage( ),
image: AssetImage( fit: BoxFit.cover,
Assets.assetsImagesBackground, opacity: 0.4,
), ),
fit: BoxFit.cover, ),
opacity: 0.4, child: state is LoadingInitialState
), ? const Center(
), child: RefreshProgressIndicator(),
child: Column( )
children: [ : SafeArea(
const Spacer(), child: Column(
Column( children: [
mainAxisAlignment: MainAxisAlignment.center, const Spacer(),
children: [ Column(
InkWell( mainAxisAlignment: MainAxisAlignment.center,
onTap: () { children: [
if ((ceilingSensor.isOnline ?? false) == false) { // InkWell(
ScaffoldMessenger.of(context).showSnackBar( // onTap: () {
const SnackBar( // if ((ceilingSensor.isOnline ?? false) == false) {
content: Text( // ScaffoldMessenger.of(context).showSnackBar(
'Device is offline', // const SnackBar(
), // content: Text(
backgroundColor: Colors.red, // 'Device is offline',
), // ),
); // backgroundColor: Colors.red,
return; // ),
} // );
String controlCode = 'sensitivity'; // return;
showDialog( // }
context: context, // String controlCode = 'sensitivity';
builder: (context) => ParameterControlDialog( // showDialog(
title: 'Sensitivity', // context: context,
sensor: ceilingSensor, // builder: (context) => ParameterControlDialog(
controlCode: controlCode, // title: 'Sensitivity',
value: ceilingSensor.status // sensor: ceilingSensor,
.firstWhere((element) => element.code == controlCode) // controlCode: controlCode,
.value as int, // value: ceilingSensor.status
min: ceilingSensor.functions // .firstWhere((element) => element.code == controlCode)
.firstWhere((element) => element.code == controlCode) // .value as int,
.values // min: ceilingSensor.functions
?.min ?? // .firstWhere((element) => element.code == controlCode)
0, // .values
max: ceilingSensor.functions // ?.min ??
.firstWhere((element) => element.code == controlCode) // 0,
.values // max: ceilingSensor.functions
?.max ?? // .firstWhere((element) => element.code == controlCode)
0, // .values
), // ?.max ??
); // 0,
}, // ),
child: SvgPicture.asset( // );
state == 'presence' // },
? Assets.assetsIconsPresenceSensorAssetsPresence // child:
: Assets.assetsIconsPresenceSensorAssetsPresenceSensorMotion, // ),
SvgPicture.asset(
ceilingSensorModel.presenceState.toLowerCase() == 'motion'
? Assets.assetsIconsPresenceSensorAssetsPresenceSensorMotion
: Assets.assetsIconsPresenceSensorAssetsPresence,
width: 100, width: 100,
height: 100, height: 100,
// colorFilter: ColorFilter.mode( // colorFilter: ColorFilter.mode(
@ -133,154 +134,153 @@ class CeilingSensorInterface extends StatelessWidget {
// BlendMode.srcIn, // BlendMode.srcIn,
// ), // ),
), ),
),
const SizedBox(
height: 10,
),
BodyMedium(
text: StringHelpers.toTitleCase(ceilingSensorModel.presenceState),
// (ceilingSensor.isOnline ?? false)
// ? StringHelpers.toTitleCase(ceilingSensor.status
// .firstWhere((element) =>
// element.code == 'presence_state')
// .value
// .toString())
// : "Offline",
style: context.bodyMedium.copyWith(
fontWeight: FontsManager.bold,
),
),
],
),
const Spacer(),
SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.min,
children: [
DefaultContainer(
padding: const EdgeInsets.symmetric(
vertical: 20,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Column(
mainAxisSize: MainAxisSize.min,
children: [
const Flexible(child: BodySmall(text: 'Sports Para')),
Flexible(
child: BodyLarge(
text: '0',
style: context.bodyLarge.copyWith(
fontWeight: FontsManager.bold,
),
),
),
],
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Container(
width: 1,
height: 45,
color: ColorsManager.greyColor,
),
),
Column(
mainAxisSize: MainAxisSize.min,
children: [
const Flexible(
child: BodySmall(
text: 'Detection Range',
textOverflow: TextOverflow.ellipsis,
)),
Flexible(
child: BodyLarge(
text: '0.0M',
textOverflow: TextOverflow.ellipsis,
style: context.bodyLarge.copyWith(
fontWeight: FontsManager.bold,
),
),
),
],
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Container(
width: 1,
height: 45,
color: ColorsManager.greyColor,
),
),
Column(
mainAxisSize: MainAxisSize.min,
children: [
const Flexible(
child: BodySmall(
text: 'Movement',
textOverflow: TextOverflow.ellipsis,
)),
Flexible(
child: BodyLarge(
text: 'none',
textOverflow: TextOverflow.ellipsis,
style: context.bodyLarge.copyWith(
fontWeight: FontsManager.bold,
),
),
),
],
),
],
)),
const SizedBox( const SizedBox(
height: 15, height: 10,
), ),
...List.generate( BodyMedium(
ceilingSensorButtons.length, text: StringHelpers.toTitleCase(ceilingSensorModel.presenceState),
(index) => DefaultContainer( // (ceilingSensor.isOnline ?? false)
margin: const EdgeInsets.only(bottom: 5), // ? StringHelpers.toTitleCase(ceilingSensor.status
padding: // .firstWhere((element) =>
const EdgeInsets.symmetric(vertical: 12, horizontal: 20), // element.code == 'presence_state')
onTap: () { // .value
if (ceilingSensorButtons[index]['page'] != null) { // .toString())
Navigator.push( // : "Offline",
context, style: context.bodyMedium.copyWith(
MaterialPageRoute( fontWeight: FontsManager.bold,
builder: (context) =>
ceilingSensorButtons[index]['page'] as Widget,
),
);
}
},
child: Row(
children: [
SvgPicture.asset(
ceilingSensorButtons[index]['icon'] as String,
// width: 30,
// height: 50,
),
const SizedBox(
width: 25,
),
BodyMedium(
text: ceilingSensorButtons[index]['title'] as String,
style: context.bodyMedium.copyWith(
fontWeight: FontsManager.bold,
),
),
],
),
), ),
), ),
], ],
), ),
), const Spacer(),
], SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.min,
children: [
DefaultContainer(
padding: const EdgeInsets.symmetric(
vertical: 20,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Column(
mainAxisSize: MainAxisSize.min,
children: [
const Flexible(child: BodySmall(text: 'Sports Para')),
Flexible(
child: BodyLarge(
text: '0',
style: context.bodyLarge.copyWith(
fontWeight: FontsManager.bold,
),
),
),
],
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Container(
width: 1,
height: 45,
color: ColorsManager.greyColor,
),
),
Column(
mainAxisSize: MainAxisSize.min,
children: [
const Flexible(
child: BodySmall(
text: 'Detection Range',
textOverflow: TextOverflow.ellipsis,
)),
Flexible(
child: BodyLarge(
text: '0.0M',
textOverflow: TextOverflow.ellipsis,
style: context.bodyLarge.copyWith(
fontWeight: FontsManager.bold,
),
),
),
],
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Container(
width: 1,
height: 45,
color: ColorsManager.greyColor,
),
),
Column(
mainAxisSize: MainAxisSize.min,
children: [
const Flexible(
child: BodySmall(
text: 'Movement',
textOverflow: TextOverflow.ellipsis,
)),
Flexible(
child: BodyLarge(
text: 'none',
textOverflow: TextOverflow.ellipsis,
style: context.bodyLarge.copyWith(
fontWeight: FontsManager.bold,
),
),
),
],
),
],
)),
const SizedBox(
height: 15,
),
...List.generate(
ceilingSensorButtons.length,
(index) => DefaultContainer(
margin: const EdgeInsets.only(bottom: 5),
padding:
const EdgeInsets.symmetric(vertical: 12, horizontal: 20),
onTap: () {
if (ceilingSensorButtons[index]['page'] != null) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
ceilingSensorButtons[index]['page'] as Widget,
),
);
}
},
child: Row(
children: [
SvgPicture.asset(
ceilingSensorButtons[index]['icon'] as String,
// width: 30,
// height: 50,
),
const SizedBox(
width: 25,
),
BodyMedium(
text: ceilingSensorButtons[index]['title'] as String,
style: context.bodyMedium.copyWith(
fontWeight: FontsManager.bold,
),
),
],
),
),
),
],
),
),
],
),
)), )),
),
), ),
); );
}), }),

View File

@ -15,53 +15,50 @@ class DoorLockGrid extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ConstrainedBox( return GridView.builder(
constraints: const BoxConstraints(maxHeight: 270), shrinkWrap: true,
child: GridView.builder( physics: const NeverScrollableScrollPhysics(),
// shrinkWrap: true, gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
physics: const NeverScrollableScrollPhysics(), crossAxisCount: 2,
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( mainAxisSpacing: 10,
crossAxisCount: 2, crossAxisSpacing: 10,
mainAxisSpacing: 10, childAspectRatio: 1.75 / 1,
crossAxisSpacing: 10, ),
childAspectRatio: 1.75 / 1, itemCount: 4,
), itemBuilder: (context, index) => DefaultContainer(
itemCount: 4, onTap: () {
itemBuilder: (context, index) => DefaultContainer( //TODO: remove checking after adding the pages
onTap: () { doorLockButtons[index]['page'] != null
//TODO: remove checking after adding the pages ? Navigator.of(context).push(
doorLockButtons[index]['page'] != null MaterialPageRoute(
? Navigator.of(context).push( builder: (context) => doorLockButtons[index]['page'] as Widget,
MaterialPageRoute(
builder: (context) => doorLockButtons[index]['page'] as Widget,
),
)
: null;
},
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
ConstrainedBox(
constraints: const BoxConstraints(maxHeight: 46, maxWidth: 50),
child: SvgPicture.asset(
doorLockButtons[index]['image'] as String,
),
),
const SizedBox(
height: 15,
),
Flexible(
child: FittedBox(
child: BodySmall(
text: doorLockButtons[index]['title'] as String,
// doorLockButtons.keys.elementAt(index),
textAlign: TextAlign.center,
), ),
)
: null;
},
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
ConstrainedBox(
constraints: const BoxConstraints(maxHeight: 46, maxWidth: 50),
child: SvgPicture.asset(
doorLockButtons[index]['image'] as String,
),
),
const SizedBox(
height: 15,
),
Flexible(
child: FittedBox(
child: BodySmall(
text: doorLockButtons[index]['title'] as String,
// doorLockButtons.keys.elementAt(index),
textAlign: TextAlign.center,
), ),
), ),
], ),
), ],
), ),
), ),
); );

View File

@ -9,7 +9,6 @@ import 'package:syncrow_app/features/devices/model/smart_door_model.dart';
import 'package:syncrow_app/features/devices/view/widgets/smart_door/door_button.dart'; import 'package:syncrow_app/features/devices/view/widgets/smart_door/door_button.dart';
import 'package:syncrow_app/features/devices/view/widgets/smart_door/door_grid.dart'; import 'package:syncrow_app/features/devices/view/widgets/smart_door/door_grid.dart';
import 'package:syncrow_app/features/devices/view/widgets/smart_door/door_status_bar.dart'; import 'package:syncrow_app/features/devices/view/widgets/smart_door/door_status_bar.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/features/shared_widgets/text_widgets/body_large.dart';
import 'package:syncrow_app/generated/assets.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/color_manager.dart';
@ -65,44 +64,43 @@ class DoorInterface extends StatelessWidget {
statusBarColor: ColorsManager.primaryColor.withOpacity(0.5), statusBarColor: ColorsManager.primaryColor.withOpacity(0.5),
statusBarIconBrightness: Brightness.light, statusBarIconBrightness: Brightness.light,
), ),
child: SafeArea( child: Scaffold(
child: Scaffold( backgroundColor: ColorsManager.backgroundColor,
backgroundColor: ColorsManager.backgroundColor, extendBodyBehindAppBar: true,
extendBodyBehindAppBar: true, extendBody: true,
extendBody: true, appBar: AppBar(
appBar: AppBar( backgroundColor: Colors.transparent,
backgroundColor: Colors.transparent, centerTitle: true,
centerTitle: true, title: BodyLarge(
title: BodyLarge( text: doorLock.name ?? "",
text: doorLock.name ?? "", fontColor: ColorsManager.primaryColor,
fontColor: ColorsManager.primaryColor, fontWeight: FontsManager.bold,
fontWeight: FontsManager.bold, ),
),
body: Container(
width: MediaQuery.sizeOf(context).width,
height: MediaQuery.sizeOf(context).height,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage(
Assets.assetsImagesBackground,
),
fit: BoxFit.cover,
opacity: 0.4,
), ),
), ),
body: state is LoadingInitialState child: SafeArea(
? const Center( child: Padding(
child: DefaultContainer( padding: EdgeInsets.only(
width: 50, height: 50, child: CircularProgressIndicator()), top: Constants.appBarHeight,
) left: Constants.defaultPadding,
: Container( right: Constants.defaultPadding,
width: MediaQuery.sizeOf(context).width, ),
height: MediaQuery.sizeOf(context).height, child: state is LoadingInitialState
decoration: const BoxDecoration( ? const Center(
image: DecorationImage( child: RefreshProgressIndicator(),
image: AssetImage( )
Assets.assetsImagesBackground, : Column(
),
fit: BoxFit.cover,
opacity: 0.4,
),
),
child: Padding(
padding: EdgeInsets.only(
top: Constants.appBarHeight,
left: Constants.defaultPadding,
right: Constants.defaultPadding,
),
child: Column(
children: [ children: [
DoorLockStatusBar( DoorLockStatusBar(
smartDoorModel: smartDoorModel, smartDoorModel: smartDoorModel,
@ -120,7 +118,7 @@ class DoorInterface extends StatelessWidget {
) )
], ],
)), )),
), ),
), ),
), ),
); );

View File

@ -20,32 +20,32 @@ class ThreeGangInterface extends StatelessWidget {
statusBarColor: ColorsManager.primaryColor.withOpacity(0.5), statusBarColor: ColorsManager.primaryColor.withOpacity(0.5),
statusBarIconBrightness: Brightness.light, statusBarIconBrightness: Brightness.light,
), ),
child: SafeArea( child: Scaffold(
child: Scaffold( backgroundColor: ColorsManager.backgroundColor,
backgroundColor: ColorsManager.backgroundColor, extendBodyBehindAppBar: true,
extendBodyBehindAppBar: true, extendBody: true,
extendBody: true, appBar: AppBar(
appBar: AppBar( backgroundColor: Colors.transparent,
backgroundColor: Colors.transparent, centerTitle: true,
centerTitle: true, title: BodyLarge(
title: BodyLarge( text: gangSwitch.name ?? "",
text: gangSwitch.name ?? "", fontColor: ColorsManager.primaryColor,
fontColor: ColorsManager.primaryColor, fontWeight: FontsManager.bold,
fontWeight: FontsManager.bold, ),
),
body: Container(
width: MediaQuery.sizeOf(context).width,
height: MediaQuery.sizeOf(context).height,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage(
Assets.assetsImagesBackground,
),
fit: BoxFit.cover,
opacity: 0.4,
), ),
), ),
body: Container( child: SafeArea(
width: MediaQuery.sizeOf(context).width,
height: MediaQuery.sizeOf(context).height,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage(
Assets.assetsImagesBackground,
),
fit: BoxFit.cover,
opacity: 0.4,
),
),
child: Padding( child: Padding(
padding: EdgeInsets.only( padding: EdgeInsets.only(
top: Constants.appBarHeight, top: Constants.appBarHeight,

View File

@ -15,9 +15,9 @@ class PresenceIndicator extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
SvgPicture.asset( SvgPicture.asset(
state == 'presence' state.toLowerCase() == 'motion'
? Assets.assetsIconsPresenceSensorAssetsPresence ? Assets.assetsIconsPresenceSensorAssetsPresenceSensorMotion
: Assets.assetsIconsPresenceSensorAssetsPresenceSensorMotion, : Assets.assetsIconsPresenceSensorAssetsPresence,
width: 100, width: 100,
height: 100, height: 100,
), ),

View File

@ -52,38 +52,38 @@ class WallMountedInterface extends StatelessWidget {
statusBarColor: ColorsManager.primaryColor.withOpacity(0.5), statusBarColor: ColorsManager.primaryColor.withOpacity(0.5),
statusBarIconBrightness: Brightness.light, statusBarIconBrightness: Brightness.light,
), ),
child: SafeArea( child: Scaffold(
child: Scaffold( backgroundColor: ColorsManager.backgroundColor,
backgroundColor: ColorsManager.backgroundColor, extendBodyBehindAppBar: true,
extendBodyBehindAppBar: true, extendBody: true,
extendBody: true, appBar: AppBar(
appBar: AppBar( backgroundColor: Colors.transparent,
backgroundColor: Colors.transparent, centerTitle: true,
centerTitle: true, title: BodyLarge(
title: BodyLarge( text: deviceModel.name ?? "",
text: deviceModel.name ?? "", fontColor: ColorsManager.primaryColor,
fontColor: ColorsManager.primaryColor, fontWeight: FontsManager.bold,
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,
), ),
), ),
body: Container( child: state is LoadingInitialState
width: MediaQuery.sizeOf(context).width, ? const Center(
height: MediaQuery.sizeOf(context).height, child: RefreshProgressIndicator(),
padding: const EdgeInsets.all(Constants.defaultPadding), )
decoration: const BoxDecoration( : SafeArea(
image: DecorationImage( child: Column(
image: AssetImage(
Assets.assetsImagesBackground,
),
fit: BoxFit.cover,
opacity: 0.4,
),
),
child: state is LoadingInitialState
? const Center(
child: RefreshProgressIndicator(),
)
: Column(
children: [ children: [
PresenceIndicator( PresenceIndicator(
state: wallSensorModel.presenceState, state: wallSensorModel.presenceState,
@ -94,7 +94,7 @@ class WallMountedInterface extends StatelessWidget {
), ),
], ],
), ),
), ),
), ),
), ),
); );

View File

@ -1,4 +1,5 @@
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/app_layout/bloc/home_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/menu/bloc/manage_unit_bloc/manage_unit_event.dart'; import 'package:syncrow_app/features/menu/bloc/manage_unit_bloc/manage_unit_event.dart';
import 'package:syncrow_app/features/menu/bloc/manage_unit_bloc/manage_unit_state.dart'; import 'package:syncrow_app/features/menu/bloc/manage_unit_bloc/manage_unit_state.dart';
@ -101,6 +102,7 @@ class ManageUnitBloc extends Bloc<ManageUnitEvent, ManageUnitState> {
final roomsList = await SpacesAPI.getRoomsBySpaceId(event.unitId); final roomsList = await SpacesAPI.getRoomsBySpaceId(event.unitId);
allDevices = await HomeManagementAPI.fetchDevicesByUserId(); allDevices = await HomeManagementAPI.fetchDevicesByUserId();
emit(FetchRoomsState(devicesList: allDevices, roomsList: roomsList)); emit(FetchRoomsState(devicesList: allDevices, roomsList: roomsList));
await HomeCubit.getInstance().fetchUnitsByUserId();
} else { } else {
emit(const ErrorState(message: 'Something went wrong')); emit(const ErrorState(message: 'Something went wrong'));
} }

View File

@ -40,8 +40,9 @@ class HomeSettingsView extends StatelessWidget {
Flexible( Flexible(
child: TextField( child: TextField(
textAlign: TextAlign.end, textAlign: TextAlign.end,
readOnly: true,
decoration: InputDecoration( decoration: InputDecoration(
hintText: 'Enter Name', hintText: space?.name ?? 'Enter Name',
hintStyle: context.bodyMedium.copyWith(color: Colors.grey), hintStyle: context.bodyMedium.copyWith(color: Colors.grey),
border: InputBorder.none, border: InputBorder.none,
), ),
@ -55,15 +56,16 @@ class HomeSettingsView extends StatelessWidget {
height: 1, height: 1,
color: ColorsManager.greyColor, color: ColorsManager.greyColor,
), ),
Container( GestureDetector(
width: MediaQuery.sizeOf(context).width, onTap: () {
child: GestureDetector( Navigator.of(context).push(CustomPageRoute(
onTap: () { builder: (context) => RoomsView(
Navigator.of(context).push(CustomPageRoute( unitId: space?.id ?? '',
builder: (context) => RoomsView( )));
unitId: space?.id ?? '', },
))); child: Container(
}, width: MediaQuery.sizeOf(context).width,
padding: const EdgeInsets.all(4),
child: const Row( child: const Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [

View File

@ -21,19 +21,16 @@ class HTTPInterceptor extends InterceptorsWrapper {
if (await validateResponse(response)) { if (await validateResponse(response)) {
super.onResponse(response, handler); super.onResponse(response, handler);
} else { } else {
handler.reject(DioException( handler.reject(DioException(requestOptions: response.requestOptions, response: response));
requestOptions: response.requestOptions, response: response));
} }
} }
@override @override
void onRequest( void onRequest(RequestOptions options, RequestInterceptorHandler handler) async {
RequestOptions options, RequestInterceptorHandler handler) async {
var storage = const FlutterSecureStorage(); var storage = const FlutterSecureStorage();
var token = await storage.read(key: Token.loginAccessTokenKey); var token = await storage.read(key: Token.loginAccessTokenKey);
if (checkHeaderExclusionListOfAddedParameters(options.path)) { if (checkHeaderExclusionListOfAddedParameters(options.path)) {
options.headers options.headers.putIfAbsent(HttpHeaders.authorizationHeader, () => "Bearer $token");
.putIfAbsent(HttpHeaders.authorizationHeader, () => "Bearer $token");
} }
// options.headers['Authorization'] = 'Bearer ${'${token!}123'}'; // options.headers['Authorization'] = 'Bearer ${'${token!}123'}';
super.onRequest(options, handler); super.onRequest(options, handler);
@ -42,12 +39,13 @@ class HTTPInterceptor extends InterceptorsWrapper {
@override @override
void onError(DioException err, ErrorInterceptorHandler handler) async { void onError(DioException err, ErrorInterceptorHandler handler) async {
ServerFailure failure = ServerFailure.fromDioError(err); ServerFailure failure = ServerFailure.fromDioError(err);
CustomSnackBar.displaySnackBar(failure.toString()); if (failure.toString().isNotEmpty) {
CustomSnackBar.displaySnackBar(failure.toString());
}
var storage = const FlutterSecureStorage(); var storage = const FlutterSecureStorage();
var token = await storage.read(key: Token.loginAccessTokenKey); var token = await storage.read(key: Token.loginAccessTokenKey);
if (err.response?.statusCode == 401 && token != null) { if (err.response?.statusCode == 401 && token != null) {
await AuthCubit.get(NavigationService.navigatorKey.currentContext!) await AuthCubit.get(NavigationService.navigatorKey.currentContext!).logout();
.logout();
} }
super.onError(err, handler); super.onError(err, handler);
} }

View File

@ -31,8 +31,8 @@ class ServerFailure extends Failure {
{ {
// var document = parser.parse(dioError.response!.data.toString()); // var document = parser.parse(dioError.response!.data.toString());
// var message = document.body!.text; // var message = document.body!.text;
return ServerFailure.fromResponse(dioError.response!.statusCode!, return ServerFailure.fromResponse(
dioError.response?.data['message'] ?? "Error"); dioError.response!.statusCode!, dioError.response?.data['message'] ?? "Error");
} }
case DioExceptionType.cancel: case DioExceptionType.cancel:
return ServerFailure("The request to ApiServer was canceled"); return ServerFailure("The request to ApiServer was canceled");
@ -64,7 +64,7 @@ class ServerFailure extends Failure {
} }
return ServerFailure(errors.join('\n')); return ServerFailure(errors.join('\n'));
case 404: case 404:
return ServerFailure("Your request not found, Please try later!"); return ServerFailure("");
case 500: case 500:
return ServerFailure(responseMessage); return ServerFailure(responseMessage);
default: default:

View File

@ -4,7 +4,7 @@ description: This is the mobile application project, developed with Flutter for
# pub.dev using `flutter pub publish`. This is preferred for private packages. # pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: "none" # Remove this line if you wish to publish to pub.dev publish_to: "none" # Remove this line if you wish to publish to pub.dev
version: 1.0.2+4 version: 1.0.4+6
environment: environment:
sdk: ">=3.0.6 <4.0.0" sdk: ">=3.0.6 <4.0.0"