diff --git a/assets/icons/delete_room_ic.svg b/assets/icons/delete_room_ic.svg
new file mode 100644
index 0000000..3ac2dbd
--- /dev/null
+++ b/assets/icons/delete_room_ic.svg
@@ -0,0 +1,6 @@
+
diff --git a/assets/icons/no_units_ic.svg b/assets/icons/no_units_ic.svg
new file mode 100644
index 0000000..f336e9d
--- /dev/null
+++ b/assets/icons/no_units_ic.svg
@@ -0,0 +1,15 @@
+
diff --git a/ios/Podfile.lock b/ios/Podfile.lock
index 20555ff..fadcbcd 100644
--- a/ios/Podfile.lock
+++ b/ios/Podfile.lock
@@ -120,9 +120,60 @@ PODS:
- nanopb/encode (= 2.30909.1)
- nanopb/decode (2.30909.1)
- nanopb/encode (2.30909.1)
+ - onesignal_flutter (5.2.0):
+ - Flutter
+ - OneSignalXCFramework (= 5.2.0)
+ - OneSignalXCFramework (5.2.0):
+ - OneSignalXCFramework/OneSignalComplete (= 5.2.0)
+ - OneSignalXCFramework/OneSignal (5.2.0):
+ - OneSignalXCFramework/OneSignalCore
+ - OneSignalXCFramework/OneSignalExtension
+ - OneSignalXCFramework/OneSignalLiveActivities
+ - OneSignalXCFramework/OneSignalNotifications
+ - OneSignalXCFramework/OneSignalOSCore
+ - OneSignalXCFramework/OneSignalOutcomes
+ - OneSignalXCFramework/OneSignalUser
+ - OneSignalXCFramework/OneSignalComplete (5.2.0):
+ - OneSignalXCFramework/OneSignal
+ - OneSignalXCFramework/OneSignalInAppMessages
+ - OneSignalXCFramework/OneSignalLocation
+ - OneSignalXCFramework/OneSignalCore (5.2.0)
+ - OneSignalXCFramework/OneSignalExtension (5.2.0):
+ - OneSignalXCFramework/OneSignalCore
+ - OneSignalXCFramework/OneSignalOutcomes
+ - OneSignalXCFramework/OneSignalInAppMessages (5.2.0):
+ - OneSignalXCFramework/OneSignalCore
+ - OneSignalXCFramework/OneSignalNotifications
+ - OneSignalXCFramework/OneSignalOSCore
+ - OneSignalXCFramework/OneSignalOutcomes
+ - OneSignalXCFramework/OneSignalUser
+ - OneSignalXCFramework/OneSignalLiveActivities (5.2.0):
+ - OneSignalXCFramework/OneSignalCore
+ - OneSignalXCFramework/OneSignalOSCore
+ - OneSignalXCFramework/OneSignalUser
+ - OneSignalXCFramework/OneSignalLocation (5.2.0):
+ - OneSignalXCFramework/OneSignalCore
+ - OneSignalXCFramework/OneSignalNotifications
+ - OneSignalXCFramework/OneSignalOSCore
+ - OneSignalXCFramework/OneSignalUser
+ - OneSignalXCFramework/OneSignalNotifications (5.2.0):
+ - OneSignalXCFramework/OneSignalCore
+ - OneSignalXCFramework/OneSignalExtension
+ - OneSignalXCFramework/OneSignalOutcomes
+ - OneSignalXCFramework/OneSignalOSCore (5.2.0):
+ - OneSignalXCFramework/OneSignalCore
+ - OneSignalXCFramework/OneSignalOutcomes (5.2.0):
+ - OneSignalXCFramework/OneSignalCore
+ - OneSignalXCFramework/OneSignalUser (5.2.0):
+ - OneSignalXCFramework/OneSignalCore
+ - OneSignalXCFramework/OneSignalNotifications
+ - OneSignalXCFramework/OneSignalOSCore
+ - OneSignalXCFramework/OneSignalOutcomes
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS
+ - permission_handler_apple (9.3.0):
+ - Flutter
- PromisesObjC (2.3.1)
- PromisesSwift (2.3.1):
- PromisesObjC (= 2.3.1)
@@ -142,7 +193,9 @@ DEPENDENCIES:
- Flutter (from `Flutter`)
- flutter_localization (from `.symlinks/plugins/flutter_localization/ios`)
- flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`)
+ - onesignal_flutter (from `.symlinks/plugins/onesignal_flutter/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
+ - permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- sqflite (from `.symlinks/plugins/sqflite/darwin`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
@@ -161,6 +214,7 @@ SPEC REPOS:
- GoogleDataTransport
- GoogleUtilities
- nanopb
+ - OneSignalXCFramework
- PromisesObjC
- PromisesSwift
@@ -177,8 +231,12 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/flutter_localization/ios"
flutter_secure_storage:
:path: ".symlinks/plugins/flutter_secure_storage/ios"
+ onesignal_flutter:
+ :path: ".symlinks/plugins/onesignal_flutter/ios"
path_provider_foundation:
:path: ".symlinks/plugins/path_provider_foundation/darwin"
+ permission_handler_apple:
+ :path: ".symlinks/plugins/permission_handler_apple/ios"
shared_preferences_foundation:
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
sqflite:
@@ -205,7 +263,10 @@ SPEC CHECKSUMS:
GoogleDataTransport: 57c22343ab29bc686febbf7cbb13bad167c2d8fe
GoogleUtilities: 0759d1a57ebb953965c2dfe0ba4c82e95ccc2e34
nanopb: d4d75c12cd1316f4a64e3c6963f879ecd4b5e0d5
+ onesignal_flutter: 5ce68a29861960168e81101cb1bd685d264361de
+ OneSignalXCFramework: bdf74fdc06888f9466dc21e826fe1549ed143095
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
+ permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2
PromisesObjC: c50d2056b5253dadbd6c2bea79b0674bd5a52fa4
PromisesSwift: 28dca69a9c40779916ac2d6985a0192a5cb4a265
shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695
diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj
index 04db647..acba072 100644
--- a/ios/Runner.xcodeproj/project.pbxproj
+++ b/ios/Runner.xcodeproj/project.pbxproj
@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
- objectVersion = 60;
+ objectVersion = 54;
objects = {
/* Begin PBXBuildFile section */
@@ -202,6 +202,7 @@
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
315A05630CF83C532DBBCBF2 /* [CP] Embed Pods Frameworks */,
0D61909C49A20C9AA28568EA /* FlutterFire: "flutterfire upload-crashlytics-symbols" */,
+ 3724F7A126D8469D5B04D144 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
@@ -309,6 +310,23 @@
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
+ 3724F7A126D8469D5B04D144 /* [CP] Copy Pods Resources */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputFileListPaths = (
+ "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
+ );
+ name = "[CP] Copy Pods Resources";
+ outputFileListPaths = (
+ "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
+ showEnvVarsInLog = 0;
+ };
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
diff --git a/lib/features/app_layout/bloc/home_cubit.dart b/lib/features/app_layout/bloc/home_cubit.dart
index 1574ded..38e307b 100644
--- a/lib/features/app_layout/bloc/home_cubit.dart
+++ b/lib/features/app_layout/bloc/home_cubit.dart
@@ -22,6 +22,7 @@ import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/navigation/navigation_service.dart';
import 'package:syncrow_app/services/api/spaces_api.dart';
import 'package:syncrow_app/utils/helpers/custom_page_route.dart';
+import 'package:syncrow_app/utils/helpers/snack_bar.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
import 'package:syncrow_app/utils/resource_manager/constants.dart';
@@ -198,7 +199,7 @@ class HomeCubit extends Cubit {
try {
spaces = await SpacesAPI.getUnitsByUserId();
} catch (failure) {
- emitSafe(GetSpacesError(failure.toString()));
+ emitSafe(GetSpacesError("No units found"));
return;
}
diff --git a/lib/features/auth/bloc/auth_cubit.dart b/lib/features/auth/bloc/auth_cubit.dart
index 98b0fe5..8098dc2 100644
--- a/lib/features/auth/bloc/auth_cubit.dart
+++ b/lib/features/auth/bloc/auth_cubit.dart
@@ -19,11 +19,6 @@ class AuthCubit extends Cubit {
final TextEditingController emailController = TextEditingController();
final TextEditingController passwordController = TextEditingController();
- // final TextEditingController emailSignUpController = TextEditingController();
- // final TextEditingController fullNameController = TextEditingController();
- // final TextEditingController passwordSignUpController = TextEditingController();
- // final TextEditingController reEnterPasswordSignUpController = TextEditingController();
-
String fullName = '';
String email = '';
String signUpPassword = '';
@@ -51,6 +46,10 @@ class AuthCubit extends Cubit {
static Token token = Token.emptyConstructor();
+ setOtpCode(String value) {
+ otpCode = value;
+ }
+
/////////////////////////////////////VALIDATORS/////////////////////////////////////
String? passwordValidator(String? value) {
if (value != null) {
@@ -64,9 +63,6 @@ class AuthCubit extends Cubit {
}
}
}
- if (signUpFormKey.currentState != null) {
- signUpFormKey.currentState!.save();
- }
return null;
}
@@ -94,19 +90,16 @@ class AuthCubit extends Cubit {
if (parts.any((part) => part.length < 2 || part.length > 30)) {
return 'Full name parts must be between 2 and 30 characters long';
}
- if (signUpFormKey.currentState != null) {
- signUpFormKey.currentState!.save();
- }
return null;
}
- String reEnterPasswordCheck(String? value) {
+ String? reEnterPasswordCheck(String? value) {
passwordValidator(value);
if (signUpPassword == value) {
- if (signUpFormKey.currentState != null) {
- signUpFormKey.currentState!.save();
- }
- return '';
+ // if (signUpFormKey.currentState != null) {
+ // signUpFormKey.currentState!.save();
+ // }
+ return null;
} else {
return 'Passwords do not match';
}
@@ -115,9 +108,6 @@ class AuthCubit extends Cubit {
String? emailAddressValidator(String? value) {
if (value != null && value.isNotEmpty && value != "") {
if (checkValidityOfEmail(value)) {
- if (signUpFormKey.currentState != null) {
- signUpFormKey.currentState!.save();
- }
return null;
} else {
return 'Please enter a valid email';
@@ -204,14 +194,47 @@ class AuthCubit extends Cubit {
}
if (response) {
maskedEmail = maskEmail(email);
- final response = await AuthenticationAPI.sendOtp(body: {'email': email, 'type': 'PASSWORD'});
- otpCode = response['otp'];
- emit(AuthSignUpSuccess());
+ await sendOtp();
} else {
emit(AuthLoginError(message: 'Something went wrong'));
}
}
+ sendOtp() async {
+ try {
+ final response =
+ await AuthenticationAPI.sendOtp(body: {'email': email, 'type': 'VERIFICATION'});
+ // otpCode = response['otp'];
+ emit(AuthSignUpSuccess());
+ } catch (_) {
+ emit(AuthLoginError(message: 'Something went wrong'));
+ }
+ }
+
+ verifyOtp() async {
+ emit(AuthLoginLoading());
+ try {
+ final response = await AuthenticationAPI.verifyPassCode(
+ body: {'email': email, 'type': 'VERIFICATION', 'otpCode': otpCode});
+ if (response['statusCode'] == 200) {
+ emailController.text = email;
+ passwordController.text = signUpPassword;
+ await login();
+ emit(AuthOtpSuccess());
+ } else {
+ emit(AuthLoginError(message: 'Something went wrong'));
+ }
+ // if (otpCode == '654321') {
+ // emit(AuthOtpSuccess());
+ // } else {
+ // emit(AuthLoginError(message: 'Otp is not correct'));
+ // }
+ } catch (failure) {
+ emit(AuthLoginError(message: failure.toString()));
+ return;
+ }
+ }
+
logout() async {
emit(AuthLogoutLoading());
try {
diff --git a/lib/features/auth/view/login_view.dart b/lib/features/auth/view/login_view.dart
index f98de48..7864972 100644
--- a/lib/features/auth/view/login_view.dart
+++ b/lib/features/auth/view/login_view.dart
@@ -1,4 +1,5 @@
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/auth/bloc/auth_cubit.dart';
@@ -18,6 +19,8 @@ class LoginView extends StatelessWidget {
@override
Widget build(BuildContext context) {
+ SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
+ statusBarBrightness: Brightness.light, statusBarIconBrightness: Brightness.light));
return BlocConsumer(
listener: (context, state) {
if (state is AuthError) {
@@ -31,9 +34,9 @@ class LoginView extends StatelessWidget {
}
},
builder: (context, state) {
- return SafeArea(
- child: Scaffold(
- body: Stack(
+ return Scaffold(
+ body: SafeArea(
+ child: Stack(
children: [
Container(
width: MediaQuery.sizeOf(context).width,
diff --git a/lib/features/auth/view/otp_view.dart b/lib/features/auth/view/otp_view.dart
index 034c034..f788d00 100644
--- a/lib/features/auth/view/otp_view.dart
+++ b/lib/features/auth/view/otp_view.dart
@@ -1,35 +1,33 @@
import 'package:flutter/material.dart';
+import 'package:flutter/widgets.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/svg.dart';
import 'package:pin_code_fields/pin_code_fields.dart';
import 'package:syncrow_app/features/auth/bloc/auth_cubit.dart';
import 'package:syncrow_app/features/shared_widgets/default_button.dart';
-import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/title_medium.dart';
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/navigation/routing_constants.dart';
import 'package:syncrow_app/utils/context_extension.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/styles_manager.dart';
class OtpView extends StatelessWidget {
const OtpView({super.key});
@override
Widget build(BuildContext context) {
- final formKey = AuthCubit.get(context).signUpFormKey;
+ String maskedEmail = AuthCubit.get(context).maskEmail(AuthCubit.get(context).email);
return BlocConsumer(
listener: (context, state) {
- if (state is AuthError) {
- } else if (state is AuthOtpSuccess) {
- Navigator.popAndPushNamed(context, Routes.homeRoute);
+ if (state is AuthOtpSuccess) {
+ Navigator.pushNamedAndRemoveUntil(context, Routes.homeRoute, (value) => false);
}
},
builder: (context, state) {
- return SafeArea(
- child: Scaffold(
- body: Stack(
+ return Scaffold(
+ body: SafeArea(
+ child: Stack(
children: [
Container(
width: MediaQuery.sizeOf(context).width,
@@ -96,7 +94,7 @@ class OtpView extends StatelessWidget {
),
children: [
TextSpan(
- text: ' ex******e@email.com',
+ text: ' $maskedEmail',
style: Theme.of(context).textTheme.titleSmall!.copyWith(
color: Colors.black,
fontWeight: FontsManager.bold,
@@ -116,20 +114,19 @@ class OtpView extends StatelessWidget {
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- SizedBox(
+ const SizedBox(
height: 40,
),
PinCodeTextField(
key: const Key('pin_code_text_field'),
appContext: context,
- length: 4,
+ length: 6,
+ obscuringCharacter: '-',
cursorHeight: 25,
- backgroundColor: Colors.transparent,
keyboardType: TextInputType.number,
autoFocus: true,
+ backgroundColor: Colors.transparent,
animationDuration: const Duration(milliseconds: 30),
- // controller: AuthCubit.get(context).emailController,
- // cursorColor: KeysperColors.primaryBase,
beforeTextPaste: (text) {
// Allow pasting only if all characters are numeric
return int.tryParse(text!) != null;
@@ -137,11 +134,11 @@ class OtpView extends StatelessWidget {
textStyle: Theme.of(context)
.textTheme
.headlineMedium!
- .copyWith(color: Colors.black),
+ .copyWith(color: Colors.white),
hintStyle: Theme.of(context)
.textTheme
.headlineMedium!
- .copyWith(color: Colors.grey),
+ .copyWith(color: Colors.white),
enablePinAutofill: true,
pinTheme: PinTheme(
borderRadius: BorderRadius.circular(8),
@@ -152,24 +149,28 @@ class OtpView extends StatelessWidget {
errorBorderWidth: 1,
borderWidth: 1,
errorBorderColor: Colors.red,
- activeColor: Colors.white,
- inactiveColor: Colors.white,
- activeFillColor: Colors.white,
- inactiveFillColor: Colors.white,
- selectedFillColor: Colors.white,
+ activeColor: state is AuthLoginError ? Colors.red : Colors.white,
+ inactiveColor:
+ state is AuthLoginError ? Colors.red : Colors.white,
+ activeFillColor:
+ state is AuthLoginError ? Colors.red : Colors.white,
+ inactiveFillColor:
+ state is AuthLoginError ? Colors.red : Colors.white,
+ selectedFillColor:
+ state is AuthLoginError ? Colors.red : Colors.white,
disabledColor: Colors.white,
- fieldHeight: 50,
- fieldWidth: 50,
+ fieldHeight: 56,
+ fieldWidth: MediaQuery.sizeOf(context).width > 340 ? 40 : 20,
+ // fieldWidth: 40,
selectedColor: Colors.white,
shape: PinCodeFieldShape.box,
),
- onChanged: (value) async {
- // otpCode = value;
- // await bloc.onOTPChanged(value);
+ onChanged: (value) {
+ AuthCubit.get(context).setOtpCode(value);
},
onCompleted: (value) {},
- onSubmitted: (value) async {
- // await bloc.onOTPSubmitted();
+ onSubmitted: (value) {
+ // AuthCubit.get(context).setOtpCode(value);
},
),
const SizedBox(height: 40),
@@ -192,11 +193,35 @@ class OtpView extends StatelessWidget {
'Verify',
),
onPressed: () {
- if (formKey.currentState!.validate()) {
- if ((state is! AuthLoading)) {
- AuthCubit.get(context).signUp();
- FocusScope.of(context).unfocus();
- }
+ if ((state is! AuthLoading)) {
+ AuthCubit.get(context).verifyOtp();
+ FocusScope.of(context).unfocus();
+ }
+ },
+ ),
+ ),
+ const SizedBox(
+ width: 4,
+ ),
+ Expanded(
+ child: DefaultButton(
+ isDone: state is AuthLoginSuccess,
+ isLoading: state is AuthLoading,
+ customButtonStyle: ButtonStyle(
+ backgroundColor: MaterialStateProperty.all(
+ Colors.black.withOpacity(.25),
+ ),
+ foregroundColor: MaterialStateProperty.all(
+ Colors.white,
+ ),
+ ),
+ child: const Text(
+ 'Resend',
+ ),
+ onPressed: () async {
+ if ((state is! AuthLoading)) {
+ await AuthCubit.get(context).sendOtp();
+ FocusScope.of(context).unfocus();
}
},
),
diff --git a/lib/features/auth/view/sign_up_view.dart b/lib/features/auth/view/sign_up_view.dart
index 2c9c497..e6f27c9 100644
--- a/lib/features/auth/view/sign_up_view.dart
+++ b/lib/features/auth/view/sign_up_view.dart
@@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/svg.dart';
import 'package:syncrow_app/features/auth/bloc/auth_cubit.dart';
-import 'package:syncrow_app/features/auth/view/widgets/login_form.dart';
import 'package:syncrow_app/features/shared_widgets/default_button.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/title_medium.dart';
@@ -26,13 +25,14 @@ class SignUpView extends StatelessWidget {
}
},
builder: (context, state) {
- return SafeArea(
- child: Scaffold(
- body: Stack(
+ return Scaffold(
+ body: SafeArea(
+ child: Stack(
children: [
Container(
width: MediaQuery.sizeOf(context).width,
height: MediaQuery.sizeOf(context).height,
+ padding: const EdgeInsets.symmetric(vertical: 24),
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage(
@@ -86,6 +86,7 @@ class SignUpView extends StatelessWidget {
),
Form(
key: formKey,
+ autovalidateMode: AutovalidateMode.disabled,
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -95,7 +96,7 @@ class SignUpView extends StatelessWidget {
fontColor: Colors.white,
),
TextFormField(
- // autovalidateMode: AutovalidateMode.onUserInteraction,
+ autovalidateMode: AutovalidateMode.disabled,
textInputAction: TextInputAction.done,
keyboardType: TextInputType.name,
scrollPadding: EdgeInsets.zero,
@@ -109,6 +110,7 @@ class SignUpView extends StatelessWidget {
onChanged: (value) {
AuthCubit.get(context).fullName = value;
},
+ onTap: () {},
decoration: defaultInputDecoration(context, hint: "Full Name"),
),
const SizedBox(height: 16),
@@ -117,6 +119,7 @@ class SignUpView extends StatelessWidget {
fontColor: Colors.white,
),
TextFormField(
+ autovalidateMode: AutovalidateMode.disabled,
textInputAction: TextInputAction.done,
keyboardType: TextInputType.text,
scrollPadding: EdgeInsets.zero,
@@ -138,6 +141,7 @@ class SignUpView extends StatelessWidget {
fontColor: Colors.white,
),
TextFormField(
+ autovalidateMode: AutovalidateMode.disabled,
textInputAction: TextInputAction.done,
keyboardType: TextInputType.text,
scrollPadding: EdgeInsets.zero,
@@ -160,6 +164,7 @@ class SignUpView extends StatelessWidget {
fontColor: Colors.white,
),
TextFormField(
+ autovalidateMode: AutovalidateMode.disabled,
textInputAction: TextInputAction.done,
keyboardType: TextInputType.text,
scrollPadding: EdgeInsets.zero,
@@ -220,6 +225,5 @@ class SignUpView extends StatelessWidget {
);
},
);
- ;
}
}
diff --git a/lib/features/dashboard/view/dashboard_view.dart b/lib/features/dashboard/view/dashboard_view.dart
index 3e7346d..601552b 100644
--- a/lib/features/dashboard/view/dashboard_view.dart
+++ b/lib/features/dashboard/view/dashboard_view.dart
@@ -1,9 +1,9 @@
-import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
-import 'package:flutter/widgets.dart';
+import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
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/create_unit.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/title_medium.dart';
import 'package:syncrow_app/utils/resource_manager/strings_manager.dart';
@@ -14,37 +14,39 @@ class DashboardView extends StatelessWidget {
@override
Widget build(BuildContext context) {
- 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,
+ return HomeCubit.getInstance().spaces?.isEmpty ?? true
+ ? const CreateUnitWidget()
+ : SingleChildScrollView(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
- Consumption(),
- SizedBox(height: 20),
- CarbonEmission(),
+ 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(),
+ ],
+ ),
+ ),
],
),
- ),
- ],
- ),
- );
+ );
}
}
diff --git a/lib/features/devices/view/widgets/devices_view_body.dart b/lib/features/devices/view/widgets/devices_view_body.dart
index 61c4f5b..e1cb7ec 100644
--- a/lib/features/devices/view/widgets/devices_view_body.dart
+++ b/lib/features/devices/view/widgets/devices_view_body.dart
@@ -7,6 +7,7 @@ import 'package:syncrow_app/features/devices/view/widgets/devices_view_header.da
import 'package:syncrow_app/features/devices/view/widgets/room_page.dart';
import 'package:syncrow_app/features/devices/view/widgets/rooms_slider.dart';
import 'package:syncrow_app/features/devices/view/widgets/wizard_page.dart';
+import 'package:syncrow_app/features/shared_widgets/create_unit.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
class DevicesViewBody extends StatelessWidget {
@@ -23,59 +24,56 @@ class DevicesViewBody extends StatelessWidget {
state is DevicesCategoriesLoading) {
return const Center(child: CircularProgressIndicator());
} else {
- return Column(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- const DevicesViewHeader(),
- const RoomsSlider(),
- const SizedBox(
- height: 10,
- ),
- Expanded(
- child: PageView(
- controller: HomeCubit.getInstance().devicesPageController,
- onPageChanged: (index) {
- HomeCubit.getInstance().devicesPageChanged(index);
- },
+ return HomeCubit.getInstance().spaces?.isEmpty ?? true
+ ? const CreateUnitWidget()
+ : Column(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
- const WizardPage(),
- if (HomeCubit.getInstance().selectedSpace != null)
- if (HomeCubit.getInstance().selectedSpace!.rooms != null)
- ...HomeCubit.getInstance().selectedSpace!.rooms!.map(
- (room) {
- return RoomPage(
- room: room,
- );
- },
- )
- ],
- ),
- ),
- HomeCubit.getInstance().selectedSpace != null
- ? Padding(
- padding: const EdgeInsets.symmetric(
- vertical: 7,
- ),
- child: SmoothPageIndicator(
- controller:
- HomeCubit.getInstance().devicesPageController,
- count: HomeCubit.getInstance()
- .selectedSpace!
- .rooms!
- .length +
- 1,
- effect: const WormEffect(
- paintStyle: PaintingStyle.stroke,
- dotHeight: 8,
- dotWidth: 8,
- ),
- ),
- )
- : const Center(
- child: BodyLarge(text: 'No Home Found'),
+ const DevicesViewHeader(),
+ const RoomsSlider(),
+ const SizedBox(
+ height: 10,
),
- ],
- );
+ Expanded(
+ child: PageView(
+ controller: HomeCubit.getInstance().devicesPageController,
+ onPageChanged: (index) {
+ HomeCubit.getInstance().devicesPageChanged(index);
+ },
+ children: [
+ const WizardPage(),
+ if (HomeCubit.getInstance().selectedSpace != null)
+ if (HomeCubit.getInstance().selectedSpace!.rooms != null)
+ ...HomeCubit.getInstance().selectedSpace!.rooms!.map(
+ (room) {
+ return RoomPage(
+ room: room,
+ );
+ },
+ )
+ ],
+ ),
+ ),
+ HomeCubit.getInstance().selectedSpace != null
+ ? Padding(
+ padding: const EdgeInsets.symmetric(
+ vertical: 7,
+ ),
+ child: SmoothPageIndicator(
+ controller: HomeCubit.getInstance().devicesPageController,
+ count: HomeCubit.getInstance().selectedSpace!.rooms!.length + 1,
+ effect: const WormEffect(
+ paintStyle: PaintingStyle.stroke,
+ dotHeight: 8,
+ dotWidth: 8,
+ ),
+ ),
+ )
+ : const Center(
+ child: BodyLarge(text: 'No Home Found'),
+ ),
+ ],
+ );
}
},
);
diff --git a/lib/features/menu/bloc/create_unit_bloc/create_unit_bloc.dart b/lib/features/menu/bloc/create_unit_bloc/create_unit_bloc.dart
new file mode 100644
index 0000000..cf04d2c
--- /dev/null
+++ b/lib/features/menu/bloc/create_unit_bloc/create_unit_bloc.dart
@@ -0,0 +1,42 @@
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:syncrow_app/features/menu/bloc/create_unit_bloc/create_unit_event.dart';
+import 'package:syncrow_app/features/menu/bloc/create_unit_bloc/create_unit_state.dart';
+import 'package:syncrow_app/utils/helpers/snack_bar.dart';
+
+class CreateUnitBloc extends Bloc {
+ List rooms = [];
+ String unitName = '';
+ String locationName = '';
+
+ CreateUnitBloc() : super(InitialState()) {
+ on(_createRoom);
+ on(_removeRoom);
+ }
+
+ void _createRoom(CreateRoomEvent event, Emitter emit) async {
+ try {
+ emit(LoadingState());
+ if (rooms.contains(event.roomName)) {
+ emit(const ErrorState(message: 'This name is already exist'));
+ emit(CreateRoomState(roomList: rooms));
+ return;
+ }
+ rooms.add(event.roomName);
+ emit(CreateRoomState(roomList: rooms));
+ } catch (e) {
+ emit(const ErrorState(message: 'Something went wrong'));
+ return;
+ }
+ }
+
+ void _removeRoom(RemoveRoomEvent event, Emitter emit) {
+ try {
+ emit(LoadingState());
+ rooms.removeWhere((element) => element == event.roomName);
+ emit(CreateRoomState(roomList: rooms));
+ } catch (e) {
+ emit(const ErrorState(message: 'Something went wrong'));
+ return;
+ }
+ }
+}
diff --git a/lib/features/menu/bloc/create_unit_bloc/create_unit_event.dart b/lib/features/menu/bloc/create_unit_bloc/create_unit_event.dart
new file mode 100644
index 0000000..3b82e6d
--- /dev/null
+++ b/lib/features/menu/bloc/create_unit_bloc/create_unit_event.dart
@@ -0,0 +1,30 @@
+import 'package:equatable/equatable.dart';
+
+abstract class CreateUnitEvent extends Equatable {
+ const CreateUnitEvent();
+
+ @override
+ List