From d0e7d12279dce309d83254ac892edbf741178109 Mon Sep 17 00:00:00 2001 From: faris Aljohari <83524184+farisaljohari@users.noreply.github.com> Date: Tue, 3 Sep 2024 17:06:28 +0300 Subject: [PATCH 01/18] test deploy --- .../azure-static-web-apps-salmon-ocean-0c2902310.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/azure-static-web-apps-salmon-ocean-0c2902310.yml b/.github/workflows/azure-static-web-apps-salmon-ocean-0c2902310.yml index d556b9e5..7e75f945 100644 --- a/.github/workflows/azure-static-web-apps-salmon-ocean-0c2902310.yml +++ b/.github/workflows/azure-static-web-apps-salmon-ocean-0c2902310.yml @@ -48,9 +48,9 @@ jobs: azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_ZEALOUS_MUSHROOM_0D31A3303 }} repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) action: "upload" - app_location: "." # Root of your Flutter project - api_location: "" # API source code path - optional - output_location: "build/web" # Path to the built web app content directory + app_location: "build/web" # App source code path + api_location: "" # Api source code path - optional + output_location: "build/web" # Built app content directory - optional close_pull_request_job: if: github.event_name == 'pull_request' && github.event.action == 'closed' From c7b1ed5b8e5a143d6d3f6efea46597efa9d0fd6a Mon Sep 17 00:00:00 2001 From: Abdullah Alassaf Date: Wed, 4 Sep 2024 00:50:16 +0300 Subject: [PATCH 02/18] Added staging base url --- .../azure-static-web-apps-salmon-ocean-0c2902310.yml | 10 +--------- lib/utils/constants/api_const.dart | 3 ++- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/.github/workflows/azure-static-web-apps-salmon-ocean-0c2902310.yml b/.github/workflows/azure-static-web-apps-salmon-ocean-0c2902310.yml index 7e75f945..59699a36 100644 --- a/.github/workflows/azure-static-web-apps-salmon-ocean-0c2902310.yml +++ b/.github/workflows/azure-static-web-apps-salmon-ocean-0c2902310.yml @@ -26,20 +26,12 @@ jobs: with: flutter-version: '3.22.2' # Specify the Flutter version you want to use - - name: Load Environment Variables - run: | - echo "Loading environment variables from .env.production" - cat .env.production | grep -v '^#' >> $GITHUB_ENV - - name: Install dependencies run: flutter pub get - name: Build Flutter Web App run: | - flutter build web --release \ - --dart-define=ENV_NAME=${{ env.ENV_NAME }} \ - --dart-define=BASE_URL=${{ env.BASE_URL }} \ - --dart-define=FLAVOR=production + flutter build web - name: Build And Deploy id: builddeploy diff --git a/lib/utils/constants/api_const.dart b/lib/utils/constants/api_const.dart index 5d24b501..7a7e20a7 100644 --- a/lib/utils/constants/api_const.dart +++ b/lib/utils/constants/api_const.dart @@ -1,7 +1,8 @@ import 'package:flutter_dotenv/flutter_dotenv.dart'; abstract class ApiEndpoints { - static String baseUrl = dotenv.env['BASE_URL'] ?? ''; + // static String baseUrl = dotenv.env['BASE_URL'] ?? ''; + static String baseUrl = 'https://syncrow-staging.azurewebsites.net'; static const String signUp = '/authentication/user/signup'; static const String login = '/authentication/user/login'; static const String forgetPassword = '/authentication/user/forget-password'; From e6d0e95ddce02801653584c10867101bead0de5b Mon Sep 17 00:00:00 2001 From: Abdullah Alassaf Date: Wed, 4 Sep 2024 01:07:31 +0300 Subject: [PATCH 03/18] Updated github workflowf file --- .../azure-static-web-apps-salmon-ocean-0c2902310.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/azure-static-web-apps-salmon-ocean-0c2902310.yml b/.github/workflows/azure-static-web-apps-salmon-ocean-0c2902310.yml index 59699a36..f67ed4ec 100644 --- a/.github/workflows/azure-static-web-apps-salmon-ocean-0c2902310.yml +++ b/.github/workflows/azure-static-web-apps-salmon-ocean-0c2902310.yml @@ -40,9 +40,9 @@ jobs: azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_ZEALOUS_MUSHROOM_0D31A3303 }} repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) action: "upload" - app_location: "build/web" # App source code path + app_location: "/build/web" # App source code path api_location: "" # Api source code path - optional - output_location: "build/web" # Built app content directory - optional + output_location: "/build/web" # Built app content directory - optional close_pull_request_job: if: github.event_name == 'pull_request' && github.event.action == 'closed' From 2969e936d0d1270e9f71d3df7d2427d341850103 Mon Sep 17 00:00:00 2001 From: faris Aljohari <83524184+farisaljohari@users.noreply.github.com> Date: Wed, 4 Sep 2024 16:51:55 +0300 Subject: [PATCH 04/18] ci: add Azure Static Web Apps workflow file on-behalf-of: @Azure opensource@microsoft.com --- ...e-static-web-apps-mango-bush-01e607f10.yml | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/azure-static-web-apps-mango-bush-01e607f10.yml diff --git a/.github/workflows/azure-static-web-apps-mango-bush-01e607f10.yml b/.github/workflows/azure-static-web-apps-mango-bush-01e607f10.yml new file mode 100644 index 00000000..26258a8c --- /dev/null +++ b/.github/workflows/azure-static-web-apps-mango-bush-01e607f10.yml @@ -0,0 +1,46 @@ +name: Azure Static Web Apps CI/CD + +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened, closed] + branches: + - main + +jobs: + build_and_deploy_job: + if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') + runs-on: ubuntu-latest + name: Build and Deploy Job + steps: + - uses: actions/checkout@v3 + with: + submodules: true + lfs: false + - name: Build And Deploy + id: builddeploy + uses: Azure/static-web-apps-deploy@v1 + with: + azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_MANGO_BUSH_01E607F10 }} + repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) + action: "upload" + ###### Repository/Build Configurations - These values can be configured to match your app requirements. ###### + # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig + app_location: "/web" # App source code path + api_location: "" # Api source code path - optional + output_location: "/web" # Built app content directory - optional + ###### End of Repository/Build Configurations ###### + + close_pull_request_job: + if: github.event_name == 'pull_request' && github.event.action == 'closed' + runs-on: ubuntu-latest + name: Close Pull Request Job + steps: + - name: Close Pull Request + id: closepullrequest + uses: Azure/static-web-apps-deploy@v1 + with: + azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_MANGO_BUSH_01E607F10 }} + action: "close" From 96bf262466726cd54fbb0254dfb15b5bc8336b18 Mon Sep 17 00:00:00 2001 From: faris Aljohari <83524184+farisaljohari@users.noreply.github.com> Date: Wed, 4 Sep 2024 16:55:06 +0300 Subject: [PATCH 05/18] setup new staging --- ...e-static-web-apps-mango-bush-01e607f10.yml | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/azure-static-web-apps-mango-bush-01e607f10.yml b/.github/workflows/azure-static-web-apps-mango-bush-01e607f10.yml index 26258a8c..10b22a27 100644 --- a/.github/workflows/azure-static-web-apps-mango-bush-01e607f10.yml +++ b/.github/workflows/azure-static-web-apps-mango-bush-01e607f10.yml @@ -15,10 +15,24 @@ jobs: runs-on: ubuntu-latest name: Build and Deploy Job steps: - - uses: actions/checkout@v3 + + - name: Checkout Code + uses: actions/checkout@v3 with: submodules: true lfs: false + + - name: Set up Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: '3.22.2' # Specify the Flutter version you want to use + + - name: Install dependencies + run: flutter pub get + + - name: Build Flutter Web App + run: flutter build web + - name: Build And Deploy id: builddeploy uses: Azure/static-web-apps-deploy@v1 @@ -28,9 +42,9 @@ jobs: action: "upload" ###### Repository/Build Configurations - These values can be configured to match your app requirements. ###### # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig - app_location: "/web" # App source code path + app_location: "/build/web" # App source code path api_location: "" # Api source code path - optional - output_location: "/web" # Built app content directory - optional + output_location: "/build/web" # Built app content directory - optional ###### End of Repository/Build Configurations ###### close_pull_request_job: From 5f4aa93e01942adfd6203ccf1cc30f033568d8f4 Mon Sep 17 00:00:00 2001 From: faris Aljohari <83524184+farisaljohari@users.noreply.github.com> Date: Wed, 4 Sep 2024 17:01:28 +0300 Subject: [PATCH 06/18] remove last workflows --- ...static-web-apps-salmon-ocean-0c2902310.yml | 57 ---------------- ...ic-web-apps-zealous-mushroom-0d31a3303.yml | 65 ------------------- 2 files changed, 122 deletions(-) delete mode 100644 .github/workflows/azure-static-web-apps-salmon-ocean-0c2902310.yml delete mode 100644 .github/workflows/azure-static-web-apps-zealous-mushroom-0d31a3303.yml diff --git a/.github/workflows/azure-static-web-apps-salmon-ocean-0c2902310.yml b/.github/workflows/azure-static-web-apps-salmon-ocean-0c2902310.yml deleted file mode 100644 index f67ed4ec..00000000 --- a/.github/workflows/azure-static-web-apps-salmon-ocean-0c2902310.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: Azure Static Web Apps CI/CD - -on: - push: - branches: - - main - pull_request: - types: [opened, synchronize, reopened, closed] - branches: - - main - -jobs: - build_and_deploy_job: - if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') - runs-on: ubuntu-latest - name: Build and Deploy Job - steps: - - name: Checkout Code - uses: actions/checkout@v3 - with: - submodules: true - lfs: false - - - name: Set up Flutter - uses: subosito/flutter-action@v2 - with: - flutter-version: '3.22.2' # Specify the Flutter version you want to use - - - name: Install dependencies - run: flutter pub get - - - name: Build Flutter Web App - run: | - flutter build web - - - name: Build And Deploy - id: builddeploy - uses: Azure/static-web-apps-deploy@v1 - with: - azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_ZEALOUS_MUSHROOM_0D31A3303 }} - repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) - action: "upload" - app_location: "/build/web" # App source code path - api_location: "" # Api source code path - optional - output_location: "/build/web" # Built app content directory - optional - - close_pull_request_job: - if: github.event_name == 'pull_request' && github.event.action == 'closed' - runs-on: ubuntu-latest - name: Close Pull Request Job - steps: - - name: Close Pull Request - id: closepullrequest - uses: Azure/static-web-apps-deploy@v1 - with: - azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_ZEALOUS_MUSHROOM_0D31A3303 }} - action: "close" diff --git a/.github/workflows/azure-static-web-apps-zealous-mushroom-0d31a3303.yml b/.github/workflows/azure-static-web-apps-zealous-mushroom-0d31a3303.yml deleted file mode 100644 index 95a05014..00000000 --- a/.github/workflows/azure-static-web-apps-zealous-mushroom-0d31a3303.yml +++ /dev/null @@ -1,65 +0,0 @@ -name: Azure Static Web Apps CI/CD - -on: - push: - branches: - - dev - pull_request: - types: [opened, synchronize, reopened, closed] - branches: - - dev - -jobs: - build_and_deploy_job: - if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') - runs-on: ubuntu-latest - name: Build and Deploy Job - steps: - - name: Checkout Code - uses: actions/checkout@v3 - with: - submodules: true - lfs: false - - - name: Set up Flutter - uses: subosito/flutter-action@v2 - with: - flutter-version: '3.22.2' # Specify the Flutter version you want to use - - - name: Load Environment Variables - run: | - echo "Loading environment variables from .env.development" - cat .env.development | grep -v '^#' >> $GITHUB_ENV - - - name: Install dependencies - run: flutter pub get - - - name: Build Flutter Web App - run: | - flutter build web --release \ - --dart-define=ENV_NAME=${{ env.ENV_NAME }} \ - --dart-define=BASE_URL=${{ env.BASE_URL }} \ - --dart-define=FLAVOR=development - - - name: Build And Deploy - id: builddeploy - uses: Azure/static-web-apps-deploy@v1 - with: - azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_ZEALOUS_MUSHROOM_0D31A3303 }} - repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) - action: "upload" - app_location: "build/web" # App source code path - api_location: "" # Api source code path - optional - output_location: "build/web" # Built app content directory - optional - - close_pull_request_job: - if: github.event_name == 'pull_request' && github.event.action == 'closed' - runs-on: ubuntu-latest - name: Close Pull Request Job - steps: - - name: Close Pull Request - id: closepullrequest - uses: Azure/static-web-apps-deploy@v1 - with: - azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_ZEALOUS_MUSHROOM_0D31A3303 }} - action: "close" From fd497d57972d41d5e25c9ef8f2d1f95a73b93b76 Mon Sep 17 00:00:00 2001 From: Abdullah Alassaf Date: Wed, 4 Sep 2024 17:05:13 +0300 Subject: [PATCH 07/18] Updated the pipeline --- ...e-static-web-apps-mango-bush-01e607f10.yml | 2 +- lib/services/access_mang_api.dart | 1 - lib/services/auth_api.dart | 29 +++++++++---------- lib/utils/constants/api_const.dart | 3 +- 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/.github/workflows/azure-static-web-apps-mango-bush-01e607f10.yml b/.github/workflows/azure-static-web-apps-mango-bush-01e607f10.yml index 10b22a27..a600bd1e 100644 --- a/.github/workflows/azure-static-web-apps-mango-bush-01e607f10.yml +++ b/.github/workflows/azure-static-web-apps-mango-bush-01e607f10.yml @@ -31,7 +31,7 @@ jobs: run: flutter pub get - name: Build Flutter Web App - run: flutter build web + run: flutter build web --release --dart-define=FLAVOR=production - name: Build And Deploy id: builddeploy diff --git a/lib/services/access_mang_api.dart b/lib/services/access_mang_api.dart index b99b75a9..103f6121 100644 --- a/lib/services/access_mang_api.dart +++ b/lib/services/access_mang_api.dart @@ -1,5 +1,4 @@ import 'dart:convert'; -import 'package:flutter/cupertino.dart'; import 'package:syncrow_web/pages/access_management/model/password_model.dart'; import 'package:syncrow_web/pages/visitor_password/model/device_model.dart'; import 'package:syncrow_web/pages/visitor_password/model/schedule_model.dart'; diff --git a/lib/services/auth_api.dart b/lib/services/auth_api.dart index a09fa7ba..44a4e7cf 100644 --- a/lib/services/auth_api.dart +++ b/lib/services/auth_api.dart @@ -1,5 +1,4 @@ import 'package:dio/dio.dart'; -import 'package:flutter/foundation.dart'; import 'package:syncrow_web/pages/auth/model/region_model.dart'; import 'package:syncrow_web/pages/auth/model/token.dart'; import 'package:syncrow_web/services/api/http_service.dart'; @@ -25,8 +24,7 @@ class AuthenticationAPI { path: ApiEndpoints.forgetPassword, body: {"email": email, "password": password}, showServerMessage: true, - expectedResponseModel: (json) { - }); + expectedResponseModel: (json) {}); return response; } @@ -64,19 +62,18 @@ class AuthenticationAPI { } static Future verifyOtp({required String email, required String otpCode}) async { - final response = await HTTPService().post( - path: ApiEndpoints.verifyOtp, - body: {"email": email, "type": "PASSWORD", "otpCode": otpCode}, - showServerMessage: true, - expectedResponseModel: (json) { - if (json['message'] == 'Otp Verified Successfully') { - return true; - } else { - return false; - } - }); - return response; - + final response = await HTTPService().post( + path: ApiEndpoints.verifyOtp, + body: {"email": email, "type": "PASSWORD", "otpCode": otpCode}, + showServerMessage: true, + expectedResponseModel: (json) { + if (json['message'] == 'Otp Verified Successfully') { + return true; + } else { + return false; + } + }); + return response; } static Future> fetchRegion() async { diff --git a/lib/utils/constants/api_const.dart b/lib/utils/constants/api_const.dart index 7a7e20a7..5d24b501 100644 --- a/lib/utils/constants/api_const.dart +++ b/lib/utils/constants/api_const.dart @@ -1,8 +1,7 @@ import 'package:flutter_dotenv/flutter_dotenv.dart'; abstract class ApiEndpoints { - // static String baseUrl = dotenv.env['BASE_URL'] ?? ''; - static String baseUrl = 'https://syncrow-staging.azurewebsites.net'; + static String baseUrl = dotenv.env['BASE_URL'] ?? ''; static const String signUp = '/authentication/user/signup'; static const String login = '/authentication/user/login'; static const String forgetPassword = '/authentication/user/forget-password'; From 0b628c85a57f28ce22b2c6ab355be726fd6c6e65 Mon Sep 17 00:00:00 2001 From: hannathkadher Date: Wed, 4 Dec 2024 10:36:41 +0400 Subject: [PATCH 08/18] updated create community dialog to mange edit/create --- .../widgets/blank_community_widget.dart | 2 + .../community_structure_header_widget.dart | 84 ++++++++++++------- .../widgets/community_structure_widget.dart | 2 + .../dialogs/create_community_dialog.dart | 35 ++++++-- 4 files changed, 88 insertions(+), 35 deletions(-) diff --git a/lib/pages/spaces_management/widgets/blank_community_widget.dart b/lib/pages/spaces_management/widgets/blank_community_widget.dart index 6b97c956..a57f3c18 100644 --- a/lib/pages/spaces_management/widgets/blank_community_widget.dart +++ b/lib/pages/spaces_management/widgets/blank_community_widget.dart @@ -72,6 +72,7 @@ class _BlankCommunityWidgetState extends State { showDialog( context: parentContext, builder: (context) => CreateCommunityDialog( + isEditMode: false, communities: widget.communities, onCreateCommunity: (String communityName, String description) { parentContext.read().add( @@ -84,4 +85,5 @@ class _BlankCommunityWidgetState extends State { ), ); } + } diff --git a/lib/pages/spaces_management/widgets/community_structure_header_widget.dart b/lib/pages/spaces_management/widgets/community_structure_header_widget.dart index a940ecf6..72d6228e 100644 --- a/lib/pages/spaces_management/widgets/community_structure_header_widget.dart +++ b/lib/pages/spaces_management/widgets/community_structure_header_widget.dart @@ -1,10 +1,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:syncrow_web/pages/common/buttons/default_button.dart'; +import 'package:syncrow_web/pages/spaces_management/model/community_model.dart'; +import 'package:syncrow_web/pages/spaces_management/widgets/dialogs/create_community_dialog.dart'; import 'package:syncrow_web/utils/color_manager.dart'; import 'package:syncrow_web/utils/constants/assets.dart'; -class CommunityStructureHeader extends StatelessWidget { +class CommunityStructureHeader extends StatefulWidget { final String? communityName; final bool isEditingName; final bool isSave; @@ -13,19 +15,28 @@ class CommunityStructureHeader extends StatelessWidget { final VoidCallback onDelete; final VoidCallback onEditName; final ValueChanged onNameSubmitted; + final List communities; + final CommunityModel? community; - const CommunityStructureHeader({ - Key? key, - required this.communityName, - required this.isSave, - required this.isEditingName, - required this.nameController, - required this.onSave, - required this.onDelete, - required this.onEditName, - required this.onNameSubmitted, - }) : super(key: key); + const CommunityStructureHeader( + {super.key, + required this.communityName, + required this.isSave, + required this.isEditingName, + required this.nameController, + required this.onSave, + required this.onDelete, + required this.onEditName, + required this.onNameSubmitted, + this.community, + required this.communities}); + @override + State createState() => + _CommunityStructureHeaderState(); +} + +class _CommunityStructureHeaderState extends State { @override Widget build(BuildContext context) { final theme = Theme.of(context); @@ -60,47 +71,62 @@ class CommunityStructureHeader extends StatelessWidget { ); } + void _showCreateCommunityDialog(BuildContext parentContext) { + showDialog( + context: parentContext, + builder: (context) => CreateCommunityDialog( + isEditMode: true, + communities: widget.communities, + communityToEdit: widget.community, + onCreateCommunity: (String communityName, String description) { + widget.onNameSubmitted(communityName); + }, + ), + ); + } + Widget _buildCommunityInfo(ThemeData theme, double screenWidth) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Community Structure', - style: theme.textTheme.headlineLarge?.copyWith(color: ColorsManager.blackColor), + style: theme.textTheme.headlineLarge + ?.copyWith(color: ColorsManager.blackColor), ), - if (communityName != null) + if (widget.communityName != null) Row( children: [ Expanded( child: Row( children: [ - if (!isEditingName) + if (!widget.isEditingName) Flexible( child: Text( - communityName!, - style: - theme.textTheme.bodyLarge?.copyWith(color: ColorsManager.blackColor), + widget.communityName!, + style: theme.textTheme.bodyLarge + ?.copyWith(color: ColorsManager.blackColor), overflow: TextOverflow.ellipsis, maxLines: 1, ), ), - if (isEditingName) + if (widget.isEditingName) SizedBox( width: screenWidth * 0.1, child: TextField( - controller: nameController, + controller: widget.nameController, decoration: const InputDecoration( border: InputBorder.none, isDense: true, ), - style: - theme.textTheme.bodyLarge?.copyWith(color: ColorsManager.blackColor), - onSubmitted: onNameSubmitted, + style: theme.textTheme.bodyLarge + ?.copyWith(color: ColorsManager.blackColor), + onSubmitted: widget.onNameSubmitted, ), ), const SizedBox(width: 2), GestureDetector( - onTap: onEditName, + onTap: () => _showCreateCommunityDialog(context), child: SvgPicture.asset( Assets.iconEdit, width: 16, @@ -110,7 +136,7 @@ class CommunityStructureHeader extends StatelessWidget { ], ), ), - if (isSave) ...[ + if (widget.isSave) ...[ const SizedBox(width: 8), _buildActionButtons(theme), ], @@ -127,8 +153,9 @@ class CommunityStructureHeader extends StatelessWidget { children: [ _buildButton( label: "Save", - icon: const Icon(Icons.save, size: 18, color: ColorsManager.spaceColor), - onPressed: onSave, + icon: const Icon(Icons.save, + size: 18, color: ColorsManager.spaceColor), + onPressed: widget.onSave, theme: theme), ], ); @@ -159,7 +186,8 @@ class CommunityStructureHeader extends StatelessWidget { Flexible( child: Text( label, - style: theme.textTheme.bodySmall?.copyWith(color: ColorsManager.blackColor), + style: theme.textTheme.bodySmall + ?.copyWith(color: ColorsManager.blackColor), overflow: TextOverflow.ellipsis, maxLines: 1, ), diff --git a/lib/pages/spaces_management/widgets/community_structure_widget.dart b/lib/pages/spaces_management/widgets/community_structure_widget.dart index 22f0d218..3789b3c9 100644 --- a/lib/pages/spaces_management/widgets/community_structure_widget.dart +++ b/lib/pages/spaces_management/widgets/community_structure_widget.dart @@ -119,7 +119,9 @@ class _CommunityStructureAreaState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ CommunityStructureHeader( + communities: widget.communities, communityName: widget.selectedCommunity?.name, + community: widget.selectedCommunity, isSave: isSave(spaces), isEditingName: isEditingName, nameController: _nameController, diff --git a/lib/pages/spaces_management/widgets/dialogs/create_community_dialog.dart b/lib/pages/spaces_management/widgets/dialogs/create_community_dialog.dart index 19ca8a99..e2208713 100644 --- a/lib/pages/spaces_management/widgets/dialogs/create_community_dialog.dart +++ b/lib/pages/spaces_management/widgets/dialogs/create_community_dialog.dart @@ -7,9 +7,16 @@ import 'package:syncrow_web/utils/color_manager.dart'; class CreateCommunityDialog extends StatefulWidget { final Function(String name, String description) onCreateCommunity; final List communities; + final bool isEditMode; + final CommunityModel? communityToEdit; - const CreateCommunityDialog( - {super.key, required this.onCreateCommunity, required this.communities}); + const CreateCommunityDialog({ + super.key, + required this.onCreateCommunity, + required this.communities, + required this.isEditMode, + this.communityToEdit, + }); @override CreateCommunityDialogState createState() => CreateCommunityDialogState(); @@ -19,6 +26,16 @@ class CreateCommunityDialogState extends State { String enteredName = ''; bool isNameFieldExist = false; bool isNameEmpty = false; + late TextEditingController nameController; + + @override + void initState() { + super.initState(); + // Initialize fields for edit mode or set defaults for create mode + nameController = TextEditingController( + text: widget.isEditMode ? widget.communityToEdit?.name ?? '' : '', + ); + } @override Widget build(BuildContext context) { @@ -52,9 +69,9 @@ class CreateCommunityDialogState extends State { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ - const Text( - 'Community Name', - style: TextStyle( + Text( + widget.isEditMode ? 'Edit Community Name' : 'Community Name', + style: const TextStyle( fontSize: 20, fontWeight: FontWeight.bold, ), @@ -62,11 +79,14 @@ class CreateCommunityDialogState extends State { const SizedBox(height: 16), // Input field for the community name TextField( + controller: nameController, onChanged: (value) { setState(() { enteredName = value.trim(); isNameFieldExist = widget.communities.any( - (community) => community.name == enteredName, + (community) => + community.name == enteredName && + widget.communityToEdit != community, ); if (value.isEmpty) { isNameEmpty = true; @@ -99,7 +119,8 @@ class CreateCommunityDialogState extends State { borderSide: BorderSide( color: isNameFieldExist || isNameEmpty ? ColorsManager.red - : ColorsManager.boxColor, width: 1), + : ColorsManager.boxColor, + width: 1), borderRadius: BorderRadius.circular(10), ), focusedBorder: OutlineInputBorder( From 9bddd151bbaa841d156e6f7773f417482ba5e6a2 Mon Sep 17 00:00:00 2001 From: hannathkadher Date: Wed, 4 Dec 2024 11:05:46 +0400 Subject: [PATCH 09/18] added bloc for create community --- .../bloc/space_management_bloc.dart | 10 +- .../bloc/space_management_event.dart | 4 +- .../bloc/space_management_state.dart | 6 +- .../model/community_model.dart | 2 +- .../model/connection_model.dart | 2 +- .../{ => all_spaces}/model/product_model.dart | 0 .../model/selected_product_model.dart | 0 .../model/space_data_model.dart | 0 .../{ => all_spaces}/model/space_model.dart | 6 +- .../model/space_response_model.dart | 0 .../view/spaces_management_page.dart | 14 +- .../widgets/add_device_type_widget.dart | 6 +- .../widgets/blank_community_widget.dart | 10 +- .../community_structure_header_widget.dart | 9 +- .../widgets/community_structure_widget.dart | 26 +-- .../widgets/community_tile.dart | 0 .../widgets/counter_widget.dart | 0 .../widgets/curved_line_painter.dart | 2 +- .../widgets/dialogs/create_space_dialog.dart | 12 +- .../widgets/dialogs/delete_dialogue.dart | 0 .../dialogs/icon_selection_dialog.dart | 0 .../gradient_canvas_border_widget.dart | 0 .../widgets/hoverable_button.dart | 0 .../widgets/loaded_space_widget.dart | 12 +- .../widgets/plus_button_widget.dart | 0 .../widgets/sidebar_widget.dart | 12 +- .../widgets/space_card_widget.dart | 0 .../widgets/space_container_widget.dart | 0 .../widgets/space_tile_widget.dart | 0 .../widgets/space_widget.dart | 0 .../bloc/community_dialog_bloc.dart | 21 ++ .../bloc/community_dialog_event.dart | 15 ++ .../bloc/community_dialog_state.dart | 21 ++ .../view/create_community_dialog.dart | 166 +++++++++++++++ .../dialogs/create_community_dialog.dart | 198 ------------------ lib/services/product_api.dart | 2 +- lib/services/space_mana_api.dart | 8 +- lib/utils/app_routes.dart | 4 +- 38 files changed, 297 insertions(+), 271 deletions(-) rename lib/pages/spaces_management/{ => all_spaces}/bloc/space_management_bloc.dart (95%) rename lib/pages/spaces_management/{ => all_spaces}/bloc/space_management_event.dart (93%) rename lib/pages/spaces_management/{ => all_spaces}/bloc/space_management_state.dart (82%) rename lib/pages/spaces_management/{ => all_spaces}/model/community_model.dart (93%) rename lib/pages/spaces_management/{ => all_spaces}/model/connection_model.dart (89%) rename lib/pages/spaces_management/{ => all_spaces}/model/product_model.dart (100%) rename lib/pages/spaces_management/{ => all_spaces}/model/selected_product_model.dart (100%) rename lib/pages/spaces_management/{ => all_spaces}/model/space_data_model.dart (100%) rename lib/pages/spaces_management/{ => all_spaces}/model/space_model.dart (93%) rename lib/pages/spaces_management/{ => all_spaces}/model/space_response_model.dart (100%) rename lib/pages/spaces_management/{ => all_spaces}/view/spaces_management_page.dart (77%) rename lib/pages/spaces_management/{ => all_spaces}/widgets/add_device_type_widget.dart (96%) rename lib/pages/spaces_management/{ => all_spaces}/widgets/blank_community_widget.dart (85%) rename lib/pages/spaces_management/{ => all_spaces}/widgets/community_structure_header_widget.dart (94%) rename lib/pages/spaces_management/{ => all_spaces}/widgets/community_structure_widget.dart (93%) rename lib/pages/spaces_management/{ => all_spaces}/widgets/community_tile.dart (100%) rename lib/pages/spaces_management/{ => all_spaces}/widgets/counter_widget.dart (100%) rename lib/pages/spaces_management/{ => all_spaces}/widgets/curved_line_painter.dart (95%) rename lib/pages/spaces_management/{ => all_spaces}/widgets/dialogs/create_space_dialog.dart (96%) rename lib/pages/spaces_management/{ => all_spaces}/widgets/dialogs/delete_dialogue.dart (100%) rename lib/pages/spaces_management/{ => all_spaces}/widgets/dialogs/icon_selection_dialog.dart (100%) rename lib/pages/spaces_management/{ => all_spaces}/widgets/gradient_canvas_border_widget.dart (100%) rename lib/pages/spaces_management/{ => all_spaces}/widgets/hoverable_button.dart (100%) rename lib/pages/spaces_management/{ => all_spaces}/widgets/loaded_space_widget.dart (73%) rename lib/pages/spaces_management/{ => all_spaces}/widgets/plus_button_widget.dart (100%) rename lib/pages/spaces_management/{ => all_spaces}/widgets/sidebar_widget.dart (92%) rename lib/pages/spaces_management/{ => all_spaces}/widgets/space_card_widget.dart (100%) rename lib/pages/spaces_management/{ => all_spaces}/widgets/space_container_widget.dart (100%) rename lib/pages/spaces_management/{ => all_spaces}/widgets/space_tile_widget.dart (100%) rename lib/pages/spaces_management/{ => all_spaces}/widgets/space_widget.dart (100%) create mode 100644 lib/pages/spaces_management/create_community/bloc/community_dialog_bloc.dart create mode 100644 lib/pages/spaces_management/create_community/bloc/community_dialog_event.dart create mode 100644 lib/pages/spaces_management/create_community/bloc/community_dialog_state.dart create mode 100644 lib/pages/spaces_management/create_community/view/create_community_dialog.dart delete mode 100644 lib/pages/spaces_management/widgets/dialogs/create_community_dialog.dart diff --git a/lib/pages/spaces_management/bloc/space_management_bloc.dart b/lib/pages/spaces_management/all_spaces/bloc/space_management_bloc.dart similarity index 95% rename from lib/pages/spaces_management/bloc/space_management_bloc.dart rename to lib/pages/spaces_management/all_spaces/bloc/space_management_bloc.dart index dc661dab..a171f2a7 100644 --- a/lib/pages/spaces_management/bloc/space_management_bloc.dart +++ b/lib/pages/spaces_management/all_spaces/bloc/space_management_bloc.dart @@ -1,9 +1,9 @@ import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:syncrow_web/pages/spaces_management/model/community_model.dart'; -import 'package:syncrow_web/pages/spaces_management/model/product_model.dart'; -import 'package:syncrow_web/pages/spaces_management/model/space_model.dart'; -import 'package:syncrow_web/pages/spaces_management/bloc/space_management_event.dart'; -import 'package:syncrow_web/pages/spaces_management/bloc/space_management_state.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/bloc/space_management_event.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/bloc/space_management_state.dart'; import 'package:syncrow_web/services/product_api.dart'; import 'package:syncrow_web/services/space_mana_api.dart'; diff --git a/lib/pages/spaces_management/bloc/space_management_event.dart b/lib/pages/spaces_management/all_spaces/bloc/space_management_event.dart similarity index 93% rename from lib/pages/spaces_management/bloc/space_management_event.dart rename to lib/pages/spaces_management/all_spaces/bloc/space_management_event.dart index 7b95f262..9e3dcc74 100644 --- a/lib/pages/spaces_management/bloc/space_management_event.dart +++ b/lib/pages/spaces_management/all_spaces/bloc/space_management_event.dart @@ -1,7 +1,7 @@ import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; -import 'package:syncrow_web/pages/spaces_management/model/community_model.dart'; -import 'package:syncrow_web/pages/spaces_management/model/space_model.dart'; // Import for Offset +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart'; // Import for Offset abstract class SpaceManagementEvent extends Equatable { const SpaceManagementEvent(); diff --git a/lib/pages/spaces_management/bloc/space_management_state.dart b/lib/pages/spaces_management/all_spaces/bloc/space_management_state.dart similarity index 82% rename from lib/pages/spaces_management/bloc/space_management_state.dart rename to lib/pages/spaces_management/all_spaces/bloc/space_management_state.dart index 0a1cfe4d..eca8c16f 100644 --- a/lib/pages/spaces_management/bloc/space_management_state.dart +++ b/lib/pages/spaces_management/all_spaces/bloc/space_management_state.dart @@ -1,7 +1,7 @@ import 'package:equatable/equatable.dart'; -import 'package:syncrow_web/pages/spaces_management/model/community_model.dart'; -import 'package:syncrow_web/pages/spaces_management/model/product_model.dart'; -import 'package:syncrow_web/pages/spaces_management/model/space_model.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart'; abstract class SpaceManagementState extends Equatable { const SpaceManagementState(); diff --git a/lib/pages/spaces_management/model/community_model.dart b/lib/pages/spaces_management/all_spaces/model/community_model.dart similarity index 93% rename from lib/pages/spaces_management/model/community_model.dart rename to lib/pages/spaces_management/all_spaces/model/community_model.dart index b61b780b..14d9d729 100644 --- a/lib/pages/spaces_management/model/community_model.dart +++ b/lib/pages/spaces_management/all_spaces/model/community_model.dart @@ -1,5 +1,5 @@ import 'package:syncrow_web/pages/auth/model/region_model.dart'; -import 'package:syncrow_web/pages/spaces_management/model/space_model.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart'; class CommunityModel { final String uuid; diff --git a/lib/pages/spaces_management/model/connection_model.dart b/lib/pages/spaces_management/all_spaces/model/connection_model.dart similarity index 89% rename from lib/pages/spaces_management/model/connection_model.dart rename to lib/pages/spaces_management/all_spaces/model/connection_model.dart index 650781d6..a774efe2 100644 --- a/lib/pages/spaces_management/model/connection_model.dart +++ b/lib/pages/spaces_management/all_spaces/model/connection_model.dart @@ -1,4 +1,4 @@ -import 'package:syncrow_web/pages/spaces_management/model/space_model.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart'; class Connection { final SpaceModel startSpace; diff --git a/lib/pages/spaces_management/model/product_model.dart b/lib/pages/spaces_management/all_spaces/model/product_model.dart similarity index 100% rename from lib/pages/spaces_management/model/product_model.dart rename to lib/pages/spaces_management/all_spaces/model/product_model.dart diff --git a/lib/pages/spaces_management/model/selected_product_model.dart b/lib/pages/spaces_management/all_spaces/model/selected_product_model.dart similarity index 100% rename from lib/pages/spaces_management/model/selected_product_model.dart rename to lib/pages/spaces_management/all_spaces/model/selected_product_model.dart diff --git a/lib/pages/spaces_management/model/space_data_model.dart b/lib/pages/spaces_management/all_spaces/model/space_data_model.dart similarity index 100% rename from lib/pages/spaces_management/model/space_data_model.dart rename to lib/pages/spaces_management/all_spaces/model/space_data_model.dart diff --git a/lib/pages/spaces_management/model/space_model.dart b/lib/pages/spaces_management/all_spaces/model/space_model.dart similarity index 93% rename from lib/pages/spaces_management/model/space_model.dart rename to lib/pages/spaces_management/all_spaces/model/space_model.dart index 3e38d931..df6550f8 100644 --- a/lib/pages/spaces_management/model/space_model.dart +++ b/lib/pages/spaces_management/all_spaces/model/space_model.dart @@ -1,7 +1,7 @@ import 'dart:ui'; -import 'package:syncrow_web/pages/spaces_management/model/community_model.dart'; -import 'package:syncrow_web/pages/spaces_management/model/connection_model.dart'; -import 'package:syncrow_web/pages/spaces_management/model/selected_product_model.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/connection_model.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/selected_product_model.dart'; import 'package:syncrow_web/utils/constants/assets.dart'; import 'package:uuid/uuid.dart'; diff --git a/lib/pages/spaces_management/model/space_response_model.dart b/lib/pages/spaces_management/all_spaces/model/space_response_model.dart similarity index 100% rename from lib/pages/spaces_management/model/space_response_model.dart rename to lib/pages/spaces_management/all_spaces/model/space_response_model.dart diff --git a/lib/pages/spaces_management/view/spaces_management_page.dart b/lib/pages/spaces_management/all_spaces/view/spaces_management_page.dart similarity index 77% rename from lib/pages/spaces_management/view/spaces_management_page.dart rename to lib/pages/spaces_management/all_spaces/view/spaces_management_page.dart index 8b37b876..8cad58b2 100644 --- a/lib/pages/spaces_management/view/spaces_management_page.dart +++ b/lib/pages/spaces_management/all_spaces/view/spaces_management_page.dart @@ -1,13 +1,13 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:syncrow_web/pages/device_managment/shared/navigate_home_grid_view.dart'; -import 'package:syncrow_web/pages/spaces_management/bloc/space_management_bloc.dart'; -import 'package:syncrow_web/pages/spaces_management/bloc/space_management_event.dart'; -import 'package:syncrow_web/pages/spaces_management/bloc/space_management_state.dart'; -import 'package:syncrow_web/pages/spaces_management/model/community_model.dart'; -import 'package:syncrow_web/pages/spaces_management/model/product_model.dart'; -import 'package:syncrow_web/pages/spaces_management/model/space_model.dart'; -import 'package:syncrow_web/pages/spaces_management/widgets/loaded_space_widget.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/bloc/space_management_bloc.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/bloc/space_management_event.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/bloc/space_management_state.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/loaded_space_widget.dart'; import 'package:syncrow_web/services/product_api.dart'; import 'package:syncrow_web/services/space_mana_api.dart'; import 'package:syncrow_web/web_layout/web_scaffold.dart'; diff --git a/lib/pages/spaces_management/widgets/add_device_type_widget.dart b/lib/pages/spaces_management/all_spaces/widgets/add_device_type_widget.dart similarity index 96% rename from lib/pages/spaces_management/widgets/add_device_type_widget.dart rename to lib/pages/spaces_management/all_spaces/widgets/add_device_type_widget.dart index 08c08997..40759b58 100644 --- a/lib/pages/spaces_management/widgets/add_device_type_widget.dart +++ b/lib/pages/spaces_management/all_spaces/widgets/add_device_type_widget.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:syncrow_web/pages/common/buttons/default_button.dart'; -import 'package:syncrow_web/pages/spaces_management/model/product_model.dart'; -import 'package:syncrow_web/pages/spaces_management/model/selected_product_model.dart'; -import 'package:syncrow_web/pages/spaces_management/widgets/counter_widget.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/selected_product_model.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/counter_widget.dart'; import 'package:syncrow_web/utils/color_manager.dart'; import 'package:syncrow_web/utils/constants/assets.dart'; import 'package:syncrow_web/utils/extension/build_context_x.dart'; diff --git a/lib/pages/spaces_management/widgets/blank_community_widget.dart b/lib/pages/spaces_management/all_spaces/widgets/blank_community_widget.dart similarity index 85% rename from lib/pages/spaces_management/widgets/blank_community_widget.dart rename to lib/pages/spaces_management/all_spaces/widgets/blank_community_widget.dart index a57f3c18..999c27bd 100644 --- a/lib/pages/spaces_management/widgets/blank_community_widget.dart +++ b/lib/pages/spaces_management/all_spaces/widgets/blank_community_widget.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:syncrow_web/pages/spaces_management/bloc/space_management_bloc.dart'; -import 'package:syncrow_web/pages/spaces_management/bloc/space_management_event.dart'; -import 'package:syncrow_web/pages/spaces_management/model/community_model.dart'; -import 'package:syncrow_web/pages/spaces_management/widgets/dialogs/create_community_dialog.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/bloc/space_management_bloc.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/bloc/space_management_event.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart'; +import 'package:syncrow_web/pages/spaces_management/create_community/view/create_community_dialog.dart'; import 'package:syncrow_web/utils/color_manager.dart'; class BlankCommunityWidget extends StatefulWidget { @@ -73,7 +73,7 @@ class _BlankCommunityWidgetState extends State { context: parentContext, builder: (context) => CreateCommunityDialog( isEditMode: false, - communities: widget.communities, + existingCommunityNames: widget.communities.map((community) => community.name).toList(), onCreateCommunity: (String communityName, String description) { parentContext.read().add( CreateCommunityEvent( diff --git a/lib/pages/spaces_management/widgets/community_structure_header_widget.dart b/lib/pages/spaces_management/all_spaces/widgets/community_structure_header_widget.dart similarity index 94% rename from lib/pages/spaces_management/widgets/community_structure_header_widget.dart rename to lib/pages/spaces_management/all_spaces/widgets/community_structure_header_widget.dart index 72d6228e..63306581 100644 --- a/lib/pages/spaces_management/widgets/community_structure_header_widget.dart +++ b/lib/pages/spaces_management/all_spaces/widgets/community_structure_header_widget.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:syncrow_web/pages/common/buttons/default_button.dart'; -import 'package:syncrow_web/pages/spaces_management/model/community_model.dart'; -import 'package:syncrow_web/pages/spaces_management/widgets/dialogs/create_community_dialog.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart'; +import 'package:syncrow_web/pages/spaces_management/create_community/view/create_community_dialog.dart'; import 'package:syncrow_web/utils/color_manager.dart'; import 'package:syncrow_web/utils/constants/assets.dart'; @@ -76,8 +76,9 @@ class _CommunityStructureHeaderState extends State { context: parentContext, builder: (context) => CreateCommunityDialog( isEditMode: true, - communities: widget.communities, - communityToEdit: widget.community, + existingCommunityNames: + widget.communities.map((community) => community.name).toList(), + initialName: widget.community?.name ?? '', onCreateCommunity: (String communityName, String description) { widget.onNameSubmitted(communityName); }, diff --git a/lib/pages/spaces_management/widgets/community_structure_widget.dart b/lib/pages/spaces_management/all_spaces/widgets/community_structure_widget.dart similarity index 93% rename from lib/pages/spaces_management/widgets/community_structure_widget.dart rename to lib/pages/spaces_management/all_spaces/widgets/community_structure_widget.dart index 3789b3c9..c11563da 100644 --- a/lib/pages/spaces_management/widgets/community_structure_widget.dart +++ b/lib/pages/spaces_management/all_spaces/widgets/community_structure_widget.dart @@ -4,19 +4,19 @@ import 'package:flutter_bloc/flutter_bloc.dart'; // Syncrow project imports import 'package:syncrow_web/pages/common/buttons/add_space_button.dart'; -import 'package:syncrow_web/pages/spaces_management/bloc/space_management_bloc.dart'; -import 'package:syncrow_web/pages/spaces_management/bloc/space_management_event.dart'; -import 'package:syncrow_web/pages/spaces_management/model/product_model.dart'; -import 'package:syncrow_web/pages/spaces_management/model/selected_product_model.dart'; -import 'package:syncrow_web/pages/spaces_management/model/space_model.dart'; -import 'package:syncrow_web/pages/spaces_management/model/community_model.dart'; -import 'package:syncrow_web/pages/spaces_management/model/connection_model.dart'; -import 'package:syncrow_web/pages/spaces_management/widgets/blank_community_widget.dart'; -import 'package:syncrow_web/pages/spaces_management/widgets/community_structure_header_widget.dart'; -import 'package:syncrow_web/pages/spaces_management/widgets/dialogs/create_space_dialog.dart'; -import 'package:syncrow_web/pages/spaces_management/widgets/curved_line_painter.dart'; -import 'package:syncrow_web/pages/spaces_management/widgets/space_card_widget.dart'; -import 'package:syncrow_web/pages/spaces_management/widgets/space_container_widget.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/bloc/space_management_bloc.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/bloc/space_management_event.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/selected_product_model.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/connection_model.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/blank_community_widget.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/community_structure_header_widget.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/dialogs/create_space_dialog.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/curved_line_painter.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/space_card_widget.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/space_container_widget.dart'; import 'package:syncrow_web/utils/color_manager.dart'; class CommunityStructureArea extends StatefulWidget { diff --git a/lib/pages/spaces_management/widgets/community_tile.dart b/lib/pages/spaces_management/all_spaces/widgets/community_tile.dart similarity index 100% rename from lib/pages/spaces_management/widgets/community_tile.dart rename to lib/pages/spaces_management/all_spaces/widgets/community_tile.dart diff --git a/lib/pages/spaces_management/widgets/counter_widget.dart b/lib/pages/spaces_management/all_spaces/widgets/counter_widget.dart similarity index 100% rename from lib/pages/spaces_management/widgets/counter_widget.dart rename to lib/pages/spaces_management/all_spaces/widgets/counter_widget.dart diff --git a/lib/pages/spaces_management/widgets/curved_line_painter.dart b/lib/pages/spaces_management/all_spaces/widgets/curved_line_painter.dart similarity index 95% rename from lib/pages/spaces_management/widgets/curved_line_painter.dart rename to lib/pages/spaces_management/all_spaces/widgets/curved_line_painter.dart index 263f0edc..2b85acfd 100644 --- a/lib/pages/spaces_management/widgets/curved_line_painter.dart +++ b/lib/pages/spaces_management/all_spaces/widgets/curved_line_painter.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:syncrow_web/pages/spaces_management/model/connection_model.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/connection_model.dart'; import 'package:syncrow_web/utils/color_manager.dart'; class CurvedLinePainter extends CustomPainter { diff --git a/lib/pages/spaces_management/widgets/dialogs/create_space_dialog.dart b/lib/pages/spaces_management/all_spaces/widgets/dialogs/create_space_dialog.dart similarity index 96% rename from lib/pages/spaces_management/widgets/dialogs/create_space_dialog.dart rename to lib/pages/spaces_management/all_spaces/widgets/dialogs/create_space_dialog.dart index 028729b8..e0853e3a 100644 --- a/lib/pages/spaces_management/widgets/dialogs/create_space_dialog.dart +++ b/lib/pages/spaces_management/all_spaces/widgets/dialogs/create_space_dialog.dart @@ -2,12 +2,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:syncrow_web/pages/common/buttons/cancel_button.dart'; import 'package:syncrow_web/pages/common/buttons/default_button.dart'; -import 'package:syncrow_web/pages/spaces_management/model/product_model.dart'; -import 'package:syncrow_web/pages/spaces_management/model/selected_product_model.dart'; -import 'package:syncrow_web/pages/spaces_management/model/space_model.dart'; -import 'package:syncrow_web/pages/spaces_management/widgets/add_device_type_widget.dart'; -import 'package:syncrow_web/pages/spaces_management/widgets/dialogs/icon_selection_dialog.dart'; -import 'package:syncrow_web/pages/spaces_management/widgets/hoverable_button.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/selected_product_model.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/add_device_type_widget.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/dialogs/icon_selection_dialog.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/hoverable_button.dart'; import 'package:syncrow_web/utils/color_manager.dart'; import 'package:syncrow_web/utils/constants/assets.dart'; import 'package:syncrow_web/utils/constants/space_icon_const.dart'; diff --git a/lib/pages/spaces_management/widgets/dialogs/delete_dialogue.dart b/lib/pages/spaces_management/all_spaces/widgets/dialogs/delete_dialogue.dart similarity index 100% rename from lib/pages/spaces_management/widgets/dialogs/delete_dialogue.dart rename to lib/pages/spaces_management/all_spaces/widgets/dialogs/delete_dialogue.dart diff --git a/lib/pages/spaces_management/widgets/dialogs/icon_selection_dialog.dart b/lib/pages/spaces_management/all_spaces/widgets/dialogs/icon_selection_dialog.dart similarity index 100% rename from lib/pages/spaces_management/widgets/dialogs/icon_selection_dialog.dart rename to lib/pages/spaces_management/all_spaces/widgets/dialogs/icon_selection_dialog.dart diff --git a/lib/pages/spaces_management/widgets/gradient_canvas_border_widget.dart b/lib/pages/spaces_management/all_spaces/widgets/gradient_canvas_border_widget.dart similarity index 100% rename from lib/pages/spaces_management/widgets/gradient_canvas_border_widget.dart rename to lib/pages/spaces_management/all_spaces/widgets/gradient_canvas_border_widget.dart diff --git a/lib/pages/spaces_management/widgets/hoverable_button.dart b/lib/pages/spaces_management/all_spaces/widgets/hoverable_button.dart similarity index 100% rename from lib/pages/spaces_management/widgets/hoverable_button.dart rename to lib/pages/spaces_management/all_spaces/widgets/hoverable_button.dart diff --git a/lib/pages/spaces_management/widgets/loaded_space_widget.dart b/lib/pages/spaces_management/all_spaces/widgets/loaded_space_widget.dart similarity index 73% rename from lib/pages/spaces_management/widgets/loaded_space_widget.dart rename to lib/pages/spaces_management/all_spaces/widgets/loaded_space_widget.dart index 6b149701..7ce56914 100644 --- a/lib/pages/spaces_management/widgets/loaded_space_widget.dart +++ b/lib/pages/spaces_management/all_spaces/widgets/loaded_space_widget.dart @@ -1,10 +1,10 @@ import 'package:flutter/material.dart'; -import 'package:syncrow_web/pages/spaces_management/model/community_model.dart'; -import 'package:syncrow_web/pages/spaces_management/model/product_model.dart'; -import 'package:syncrow_web/pages/spaces_management/model/space_model.dart'; -import 'package:syncrow_web/pages/spaces_management/widgets/community_structure_widget.dart'; -import 'package:syncrow_web/pages/spaces_management/widgets/gradient_canvas_border_widget.dart'; -import 'package:syncrow_web/pages/spaces_management/widgets/sidebar_widget.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/community_structure_widget.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/gradient_canvas_border_widget.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/sidebar_widget.dart'; class LoadedSpaceView extends StatefulWidget { final List communities; diff --git a/lib/pages/spaces_management/widgets/plus_button_widget.dart b/lib/pages/spaces_management/all_spaces/widgets/plus_button_widget.dart similarity index 100% rename from lib/pages/spaces_management/widgets/plus_button_widget.dart rename to lib/pages/spaces_management/all_spaces/widgets/plus_button_widget.dart diff --git a/lib/pages/spaces_management/widgets/sidebar_widget.dart b/lib/pages/spaces_management/all_spaces/widgets/sidebar_widget.dart similarity index 92% rename from lib/pages/spaces_management/widgets/sidebar_widget.dart rename to lib/pages/spaces_management/all_spaces/widgets/sidebar_widget.dart index e11be2c2..a58d73e9 100644 --- a/lib/pages/spaces_management/widgets/sidebar_widget.dart +++ b/lib/pages/spaces_management/all_spaces/widgets/sidebar_widget.dart @@ -2,12 +2,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_svg/svg.dart'; import 'package:syncrow_web/common/search_bar.dart'; -import 'package:syncrow_web/pages/spaces_management/bloc/space_management_bloc.dart'; -import 'package:syncrow_web/pages/spaces_management/bloc/space_management_event.dart'; -import 'package:syncrow_web/pages/spaces_management/model/community_model.dart'; -import 'package:syncrow_web/pages/spaces_management/model/space_model.dart'; -import 'package:syncrow_web/pages/spaces_management/widgets/community_tile.dart'; -import 'package:syncrow_web/pages/spaces_management/widgets/space_tile_widget.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/bloc/space_management_bloc.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/bloc/space_management_event.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/community_tile.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/space_tile_widget.dart'; import 'package:syncrow_web/utils/color_manager.dart'; import 'package:syncrow_web/utils/constants/assets.dart'; import 'package:syncrow_web/utils/style.dart'; diff --git a/lib/pages/spaces_management/widgets/space_card_widget.dart b/lib/pages/spaces_management/all_spaces/widgets/space_card_widget.dart similarity index 100% rename from lib/pages/spaces_management/widgets/space_card_widget.dart rename to lib/pages/spaces_management/all_spaces/widgets/space_card_widget.dart diff --git a/lib/pages/spaces_management/widgets/space_container_widget.dart b/lib/pages/spaces_management/all_spaces/widgets/space_container_widget.dart similarity index 100% rename from lib/pages/spaces_management/widgets/space_container_widget.dart rename to lib/pages/spaces_management/all_spaces/widgets/space_container_widget.dart diff --git a/lib/pages/spaces_management/widgets/space_tile_widget.dart b/lib/pages/spaces_management/all_spaces/widgets/space_tile_widget.dart similarity index 100% rename from lib/pages/spaces_management/widgets/space_tile_widget.dart rename to lib/pages/spaces_management/all_spaces/widgets/space_tile_widget.dart diff --git a/lib/pages/spaces_management/widgets/space_widget.dart b/lib/pages/spaces_management/all_spaces/widgets/space_widget.dart similarity index 100% rename from lib/pages/spaces_management/widgets/space_widget.dart rename to lib/pages/spaces_management/all_spaces/widgets/space_widget.dart diff --git a/lib/pages/spaces_management/create_community/bloc/community_dialog_bloc.dart b/lib/pages/spaces_management/create_community/bloc/community_dialog_bloc.dart new file mode 100644 index 00000000..724ed51a --- /dev/null +++ b/lib/pages/spaces_management/create_community/bloc/community_dialog_bloc.dart @@ -0,0 +1,21 @@ +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'community_dialog_event.dart'; +import 'community_dialog_state.dart'; + +class CommunityDialogBloc extends Bloc { + final List existingCommunityNames; + + CommunityDialogBloc(this.existingCommunityNames) + : super(CommunityDialogInitial()) { + on((event, emit) { + final trimmedName = event.name.trim(); + final isNameValid = !existingCommunityNames.contains(trimmedName); + final isNameEmpty = trimmedName.isEmpty; + + emit(CommunityNameValidationState( + isNameValid: isNameValid, + isNameEmpty: isNameEmpty, + )); + }); + } +} diff --git a/lib/pages/spaces_management/create_community/bloc/community_dialog_event.dart b/lib/pages/spaces_management/create_community/bloc/community_dialog_event.dart new file mode 100644 index 00000000..74f4fa5c --- /dev/null +++ b/lib/pages/spaces_management/create_community/bloc/community_dialog_event.dart @@ -0,0 +1,15 @@ +import 'package:equatable/equatable.dart'; + +abstract class CommunityDialogEvent extends Equatable { + @override + List get props => []; +} + +class ValidateCommunityNameEvent extends CommunityDialogEvent { + final String name; + + ValidateCommunityNameEvent(this.name); + + @override + List get props => [name]; +} diff --git a/lib/pages/spaces_management/create_community/bloc/community_dialog_state.dart b/lib/pages/spaces_management/create_community/bloc/community_dialog_state.dart new file mode 100644 index 00000000..8b61c1c7 --- /dev/null +++ b/lib/pages/spaces_management/create_community/bloc/community_dialog_state.dart @@ -0,0 +1,21 @@ +import 'package:equatable/equatable.dart'; + +abstract class CommunityDialogState extends Equatable { + @override + List get props => []; +} + +class CommunityDialogInitial extends CommunityDialogState {} + +class CommunityNameValidationState extends CommunityDialogState { + final bool isNameValid; + final bool isNameEmpty; + + CommunityNameValidationState({ + required this.isNameValid, + required this.isNameEmpty, + }); + + @override + List get props => [isNameValid, isNameEmpty]; +} diff --git a/lib/pages/spaces_management/create_community/view/create_community_dialog.dart b/lib/pages/spaces_management/create_community/view/create_community_dialog.dart new file mode 100644 index 00000000..94a8c054 --- /dev/null +++ b/lib/pages/spaces_management/create_community/view/create_community_dialog.dart @@ -0,0 +1,166 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:syncrow_web/pages/spaces_management/create_community/bloc/community_dialog_bloc.dart'; +import 'package:syncrow_web/pages/spaces_management/create_community/bloc/community_dialog_event.dart'; +import 'package:syncrow_web/pages/spaces_management/create_community/bloc/community_dialog_state.dart'; +import 'package:syncrow_web/utils/color_manager.dart'; +import 'package:syncrow_web/pages/common/buttons/cancel_button.dart'; +import 'package:syncrow_web/pages/common/buttons/default_button.dart'; + +class CreateCommunityDialog extends StatelessWidget { + final Function(String name, String description) onCreateCommunity; + final List existingCommunityNames; + final bool isEditMode; + final String? initialName; + + const CreateCommunityDialog({ + super.key, + required this.onCreateCommunity, + required this.existingCommunityNames, + required this.isEditMode, + this.initialName, + }); + + @override + Widget build(BuildContext context) { + final nameController = + TextEditingController(text: isEditMode ? initialName : ''); + + return BlocProvider( + create: (_) => CommunityDialogBloc(existingCommunityNames), + child: Dialog( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(20), + ), + backgroundColor: ColorsManager.transparentColor, + child: Stack( + children: [ + Container( + width: MediaQuery.of(context).size.width * 0.3, + padding: const EdgeInsets.all(20), + decoration: BoxDecoration( + color: ColorsManager.whiteColors, + borderRadius: BorderRadius.circular(20), + boxShadow: [ + BoxShadow( + color: ColorsManager.blackColor.withOpacity(0.25), + blurRadius: 20, + spreadRadius: 5, + offset: const Offset(0, 5), + ), + ], + ), + child: SingleChildScrollView( + child: BlocBuilder( + builder: (context, state) { + bool isNameValid = true; + bool isNameEmpty = false; + + if (state is CommunityNameValidationState) { + isNameValid = state.isNameValid; + isNameEmpty = state.isNameEmpty; + } + + return Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + isEditMode ? 'Edit Community Name' : 'Community Name', + style: const TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 16), + TextField( + controller: nameController, + onChanged: (value) { + context + .read() + .add(ValidateCommunityNameEvent(value)); + }, + style: const TextStyle( + color: ColorsManager.blackColor, + ), + decoration: InputDecoration( + hintText: 'Please enter the community name', + filled: true, + fillColor: ColorsManager.boxColor, + border: OutlineInputBorder( + borderSide: BorderSide( + color: isNameValid && !isNameEmpty + ? ColorsManager.boxColor + : ColorsManager.red, + width: 1, + ), + borderRadius: BorderRadius.circular(10), + ), + ), + ), + if (!isNameValid) + Padding( + padding: const EdgeInsets.only(top: 8.0), + child: Text( + '*Name already exists.', + style: Theme.of(context) + .textTheme + .bodySmall + ?.copyWith(color: ColorsManager.red), + ), + ), + if (isNameEmpty) + Padding( + padding: const EdgeInsets.only(top: 8.0), + child: Text( + '*Name should not be empty.', + style: Theme.of(context) + .textTheme + .bodySmall + ?.copyWith(color: ColorsManager.red), + ), + ), + const SizedBox(height: 24), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: CancelButton( + label: 'Cancel', + onPressed: () => Navigator.of(context).pop(), + ), + ), + const SizedBox(width: 16), + Expanded( + child: DefaultButton( + onPressed: () { + if (isNameValid && !isNameEmpty) { + onCreateCommunity( + nameController.text.trim(), + "", + ); + Navigator.of(context).pop(); + } + }, + backgroundColor: isNameValid && !isNameEmpty + ? ColorsManager.secondaryColor + : ColorsManager.lightGrayColor, + borderRadius: 10, + foregroundColor: ColorsManager.whiteColors, + child: const Text('OK'), + ), + ), + ], + ), + ], + ); + }, + ), + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/pages/spaces_management/widgets/dialogs/create_community_dialog.dart b/lib/pages/spaces_management/widgets/dialogs/create_community_dialog.dart deleted file mode 100644 index e2208713..00000000 --- a/lib/pages/spaces_management/widgets/dialogs/create_community_dialog.dart +++ /dev/null @@ -1,198 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:syncrow_web/pages/common/buttons/cancel_button.dart'; -import 'package:syncrow_web/pages/common/buttons/default_button.dart'; -import 'package:syncrow_web/pages/spaces_management/model/community_model.dart'; -import 'package:syncrow_web/utils/color_manager.dart'; - -class CreateCommunityDialog extends StatefulWidget { - final Function(String name, String description) onCreateCommunity; - final List communities; - final bool isEditMode; - final CommunityModel? communityToEdit; - - const CreateCommunityDialog({ - super.key, - required this.onCreateCommunity, - required this.communities, - required this.isEditMode, - this.communityToEdit, - }); - - @override - CreateCommunityDialogState createState() => CreateCommunityDialogState(); -} - -class CreateCommunityDialogState extends State { - String enteredName = ''; - bool isNameFieldExist = false; - bool isNameEmpty = false; - late TextEditingController nameController; - - @override - void initState() { - super.initState(); - // Initialize fields for edit mode or set defaults for create mode - nameController = TextEditingController( - text: widget.isEditMode ? widget.communityToEdit?.name ?? '' : '', - ); - } - - @override - Widget build(BuildContext context) { - final screenWidth = MediaQuery.of(context).size.width; - - return Dialog( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(20), - ), - backgroundColor: - ColorsManager.transparentColor, // Transparent for shadow effect - child: Stack( - children: [ - // Background container with shadow and rounded corners - Container( - width: screenWidth * 0.3, - padding: const EdgeInsets.all(20), - decoration: BoxDecoration( - color: ColorsManager.whiteColors, - borderRadius: BorderRadius.circular(20), - boxShadow: [ - BoxShadow( - color: ColorsManager.blackColor.withOpacity(0.25), - blurRadius: 20, - spreadRadius: 5, - offset: const Offset(0, 5), - ), - ], - ), - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - widget.isEditMode ? 'Edit Community Name' : 'Community Name', - style: const TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 16), - // Input field for the community name - TextField( - controller: nameController, - onChanged: (value) { - setState(() { - enteredName = value.trim(); - isNameFieldExist = widget.communities.any( - (community) => - community.name == enteredName && - widget.communityToEdit != community, - ); - if (value.isEmpty) { - isNameEmpty = true; - } else { - isNameEmpty = false; - } - }); - }, - style: const TextStyle( - color: ColorsManager.blackColor, - ), - decoration: InputDecoration( - hintText: 'Please enter the community name', - filled: true, - fillColor: ColorsManager.boxColor, - hintStyle: const TextStyle( - fontSize: 14, - color: ColorsManager.grayBorder, - fontWeight: FontWeight.w400, - ), - border: OutlineInputBorder( - borderSide: BorderSide( - color: isNameFieldExist || isNameEmpty - ? ColorsManager.red - : ColorsManager.boxColor, - width: 1), - borderRadius: BorderRadius.circular(10), - ), - enabledBorder: OutlineInputBorder( - borderSide: BorderSide( - color: isNameFieldExist || isNameEmpty - ? ColorsManager.red - : ColorsManager.boxColor, - width: 1), - borderRadius: BorderRadius.circular(10), - ), - focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(10), - borderSide: BorderSide( - color: isNameFieldExist || isNameEmpty - ? ColorsManager.red - : ColorsManager.boxColor, - width: 1), - ), - ), - ), - if (isNameFieldExist) - Padding( - padding: const EdgeInsets.only(top: 8.0), - child: Text( - '*Name already exists.', - style: Theme.of(context) - .textTheme - .bodySmall - ?.copyWith(color: ColorsManager.red), - ), - ), - if (isNameEmpty) - Padding( - padding: const EdgeInsets.only(top: 8.0), - child: Text( - '*Name should not be empty.', - style: Theme.of(context) - .textTheme - .bodySmall - ?.copyWith(color: ColorsManager.red), - ), - ), - const SizedBox(height: 24), - // Action buttons - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - child: CancelButton( - label: 'Cancel', - onPressed: () => Navigator.of(context).pop(), - ), - ), - const SizedBox(width: 16), - Expanded( - child: DefaultButton( - onPressed: () { - if (enteredName.isNotEmpty && !isNameFieldExist) { - widget.onCreateCommunity( - enteredName, - "", - ); - Navigator.of(context).pop(); - } - }, - backgroundColor: isNameFieldExist || isNameEmpty - ? ColorsManager.lightGrayColor - : ColorsManager.secondaryColor, - borderRadius: 10, - foregroundColor: ColorsManager.whiteColors, - child: const Text('OK'), - ), - ), - ], - ), - ], - ), - ), - ], - ), - ); - } -} diff --git a/lib/services/product_api.dart b/lib/services/product_api.dart index f33a4135..02c9f143 100644 --- a/lib/services/product_api.dart +++ b/lib/services/product_api.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:syncrow_web/pages/spaces_management/model/product_model.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart'; import 'package:syncrow_web/services/api/http_service.dart'; import 'package:syncrow_web/utils/constants/api_const.dart'; diff --git a/lib/services/space_mana_api.dart b/lib/services/space_mana_api.dart index 5d2464e6..55875bfa 100644 --- a/lib/services/space_mana_api.dart +++ b/lib/services/space_mana_api.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; -import 'package:syncrow_web/pages/spaces_management/model/community_model.dart'; -import 'package:syncrow_web/pages/spaces_management/model/selected_product_model.dart'; -import 'package:syncrow_web/pages/spaces_management/model/space_model.dart'; -import 'package:syncrow_web/pages/spaces_management/model/space_response_model.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/selected_product_model.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_response_model.dart'; import 'package:syncrow_web/services/api/http_service.dart'; import 'package:syncrow_web/utils/constants/api_const.dart'; diff --git a/lib/utils/app_routes.dart b/lib/utils/app_routes.dart index 20a89e21..31329d8a 100644 --- a/lib/utils/app_routes.dart +++ b/lib/utils/app_routes.dart @@ -3,7 +3,7 @@ import 'package:syncrow_web/pages/access_management/view/access_management.dart' import 'package:syncrow_web/pages/auth/view/login_page.dart'; import 'package:syncrow_web/pages/device_managment/all_devices/view/device_managment_page.dart'; import 'package:syncrow_web/pages/home/view/home_page.dart'; -import 'package:syncrow_web/pages/spaces_management/view/spaces_management_page.dart'; +import 'package:syncrow_web/pages/spaces_management/all_spaces/view/spaces_management_page.dart'; import 'package:syncrow_web/pages/visitor_password/view/visitor_password_dialog.dart'; import 'package:syncrow_web/utils/constants/routes_const.dart'; @@ -32,7 +32,7 @@ class AppRoutes { ), GoRoute( path: RoutesConst.spacesManagementPage, - builder: (context, state) => SpaceManagementPage()), + builder: (context, state) => const SpaceManagementPage()), ]; } } From d423a3eb5949a5f57f01d8b97823af9702d8ae05 Mon Sep 17 00:00:00 2001 From: hannathkadher Date: Wed, 4 Dec 2024 11:14:02 +0400 Subject: [PATCH 10/18] added focused border --- .../view/create_community_dialog.dart | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/pages/spaces_management/create_community/view/create_community_dialog.dart b/lib/pages/spaces_management/create_community/view/create_community_dialog.dart index 94a8c054..1a5460d1 100644 --- a/lib/pages/spaces_management/create_community/view/create_community_dialog.dart +++ b/lib/pages/spaces_management/create_community/view/create_community_dialog.dart @@ -67,12 +67,9 @@ class CreateCommunityDialog extends StatelessWidget { children: [ Text( isEditMode ? 'Edit Community Name' : 'Community Name', - style: const TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold, - ), + style: Theme.of(context).textTheme.headlineMedium, ), - const SizedBox(height: 16), + const SizedBox(height: 18), TextField( controller: nameController, onChanged: (value) { @@ -87,7 +84,7 @@ class CreateCommunityDialog extends StatelessWidget { hintText: 'Please enter the community name', filled: true, fillColor: ColorsManager.boxColor, - border: OutlineInputBorder( + enabledBorder: OutlineInputBorder( borderSide: BorderSide( color: isNameValid && !isNameEmpty ? ColorsManager.boxColor @@ -96,6 +93,13 @@ class CreateCommunityDialog extends StatelessWidget { ), borderRadius: BorderRadius.circular(10), ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: const BorderSide( + color: ColorsManager.boxColor, + width: 1.5, + ), + ), ), ), if (!isNameValid) From 26f50d59ddebf12adf52a3ca963b40c98ed5b633 Mon Sep 17 00:00:00 2001 From: Abdullah Alassaf Date: Thu, 5 Dec 2024 11:19:22 +0300 Subject: [PATCH 11/18] Bug fixes --- .../bloc/routine_bloc/routine_bloc.dart | 20 +-- .../routiens/widgets/then_container.dart | 116 +++++++----------- 2 files changed, 56 insertions(+), 80 deletions(-) diff --git a/lib/pages/routiens/bloc/routine_bloc/routine_bloc.dart b/lib/pages/routiens/bloc/routine_bloc/routine_bloc.dart index c1f3b39d..89781032 100644 --- a/lib/pages/routiens/bloc/routine_bloc/routine_bloc.dart +++ b/lib/pages/routiens/bloc/routine_bloc/routine_bloc.dart @@ -1050,7 +1050,9 @@ class RoutineBloc extends Bloc { final automationDetails = await SceneApi.getAutomationDetails(event.automationId); - final Map> deviceCards = {}; + final Map> deviceIfCards = {}; + final Map> deviceThenCards = {}; + final Map> updatedFunctions = Map>.from(state.selectedFunctions); @@ -1066,8 +1068,8 @@ class RoutineBloc extends Bloc { final deviceId = condition.entityId; - if (!deviceCards.containsKey(deviceId)) { - deviceCards[deviceId] = { + if (!deviceIfCards.containsKey(deviceId)) { + deviceIfCards[deviceId] = { 'entityId': condition.entityId, 'deviceId': condition.entityId, 'uniqueCustomId': const Uuid().v4(), @@ -1080,7 +1082,7 @@ class RoutineBloc extends Bloc { }; } - final cardData = deviceCards[deviceId]!; + final cardData = deviceIfCards[deviceId]!; final uniqueCustomId = cardData['uniqueCustomId'].toString(); if (!updatedFunctions.containsKey(uniqueCustomId)) { @@ -1117,8 +1119,8 @@ class RoutineBloc extends Bloc { final deviceId = action.actionExecutor == 'delay' ? '${action.entityId}_delay' : action.entityId; - if (!deviceCards.containsKey(deviceId)) { - deviceCards[deviceId] = { + if (!deviceThenCards.containsKey(deviceId)) { + deviceThenCards[deviceId] = { 'entityId': action.entityId, 'deviceId': action.actionExecutor == 'delay' ? 'delay' : action.entityId, 'uniqueCustomId': const Uuid().v4(), @@ -1143,7 +1145,7 @@ class RoutineBloc extends Bloc { }; } - final cardData = deviceCards[deviceId]!; + final cardData = deviceThenCards[deviceId]!; final uniqueCustomId = cardData['uniqueCustomId'].toString(); if (!updatedFunctions.containsKey(uniqueCustomId)) { @@ -1192,8 +1194,8 @@ class RoutineBloc extends Bloc { } } - final ifItems = deviceCards.values.where((card) => card['type'] == 'condition').toList(); - final thenItems = deviceCards.values + final ifItems = deviceIfCards.values.where((card) => card['type'] == 'condition').toList(); + final thenItems = deviceThenCards.values .where((card) => card['type'] == 'action' || card['type'] == 'automation' || card['type'] == 'scene') .toList(); diff --git a/lib/pages/routiens/widgets/then_container.dart b/lib/pages/routiens/widgets/then_container.dart index 8a12e443..4746561a 100644 --- a/lib/pages/routiens/widgets/then_container.dart +++ b/lib/pages/routiens/widgets/then_container.dart @@ -26,9 +26,7 @@ class ThenContainer extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - const Text('THEN', - style: TextStyle( - fontSize: 18, fontWeight: FontWeight.bold)), + const Text('THEN', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)), const SizedBox(height: 16), state.isLoading && state.isUpdate == true ? const Center( @@ -41,17 +39,12 @@ class ThenContainer extends StatelessWidget { state.thenItems.length, (index) => GestureDetector( onTap: () async { - if (state.thenItems[index] - ['deviceId'] == - 'delay') { - final result = await DelayHelper - .showDelayPickerDialog(context, - state.thenItems[index]); + if (state.thenItems[index]['deviceId'] == 'delay') { + final result = await DelayHelper.showDelayPickerDialog( + context, state.thenItems[index]); if (result != null) { - context - .read() - .add(AddToThenContainer({ + context.read().add(AddToThenContainer({ ...state.thenItems[index], 'imagePath': Assets.delay, 'title': 'Delay', @@ -60,79 +53,58 @@ class ThenContainer extends StatelessWidget { return; } - if (state.thenItems[index]['type'] == - 'automation') { + if (state.thenItems[index]['type'] == 'automation') { final result = await showDialog( context: context, - builder: (BuildContext context) => - AutomationDialog( + builder: (BuildContext context) => AutomationDialog( automationName: - state.thenItems[index] - ['name'] ?? - 'Automation', + state.thenItems[index]['name'] ?? 'Automation', automationId: - state.thenItems[index] - ['deviceId'] ?? - '', - uniqueCustomId: - state.thenItems[index] - ['uniqueCustomId'], + state.thenItems[index]['deviceId'] ?? '', + uniqueCustomId: state.thenItems[index] + ['uniqueCustomId'], ), ); if (result != null) { - context - .read() - .add(AddToThenContainer({ + context.read().add(AddToThenContainer({ ...state.thenItems[index], - 'imagePath': - Assets.automation, - 'title': - state.thenItems[index] - ['name'] ?? - state.thenItems[index] - ['title'], + 'imagePath': Assets.automation, + 'title': state.thenItems[index]['name'] ?? + state.thenItems[index]['title'], })); } return; } - final result = await DeviceDialogHelper - .showDeviceDialog( - context, state.thenItems[index], - removeComparetors: true); + final result = await DeviceDialogHelper.showDeviceDialog( + context, state.thenItems[index], + removeComparetors: true); if (result != null) { - context.read().add( - AddToThenContainer( - state.thenItems[index])); + context + .read() + .add(AddToThenContainer(state.thenItems[index])); } else if (!['AC', '1G', '2G', '3G'] - .contains(state.thenItems[index] - ['productType'])) { - context.read().add( - AddToThenContainer( - state.thenItems[index])); + .contains(state.thenItems[index]['productType'])) { + context + .read() + .add(AddToThenContainer(state.thenItems[index])); } }, child: DraggableCard( - imagePath: state.thenItems[index] - ['imagePath'] ?? - '', - title: state.thenItems[index] - ['title'] ?? - '', + imagePath: state.thenItems[index]['imagePath'] ?? '', + title: state.thenItems[index]['title'] ?? '', deviceData: state.thenItems[index], - padding: const EdgeInsets.symmetric( - horizontal: 4, vertical: 8), + padding: + const EdgeInsets.symmetric(horizontal: 4, vertical: 8), isFromThen: true, isFromIf: false, onRemove: () { - context.read().add( - RemoveDragCard( - index: index, - isFromThen: true, - key: state.thenItems[index] - ['uniqueCustomId'])); + context.read().add(RemoveDragCard( + index: index, + isFromThen: true, + key: state.thenItems[index]['uniqueCustomId'])); }, ), ))), @@ -151,9 +123,14 @@ class ThenContainer extends StatelessWidget { return; } + if (state.automationId == mutableData['deviceId'] || + state.sceneId == mutableData['deviceId']) { + return; + } + if (mutableData['type'] == 'automation') { - int index = state.thenItems.indexWhere( - (item) => item['deviceId'] == mutableData['deviceId']); + int index = + state.thenItems.indexWhere((item) => item['deviceId'] == mutableData['deviceId']); if (index != -1) { return; } @@ -178,8 +155,8 @@ class ThenContainer extends StatelessWidget { } if (mutableData['type'] == 'tap_to_run' && state.isAutomation) { - int index = state.thenItems.indexWhere( - (item) => item['deviceId'] == mutableData['deviceId']); + int index = + state.thenItems.indexWhere((item) => item['deviceId'] == mutableData['deviceId']); if (index != -1) { return; } @@ -197,8 +174,7 @@ class ThenContainer extends StatelessWidget { } if (mutableData['deviceId'] == 'delay') { - final result = - await DelayHelper.showDelayPickerDialog(context, mutableData); + final result = await DelayHelper.showDelayPickerDialog(context, mutableData); if (result != null) { context.read().add(AddToThenContainer({ @@ -210,13 +186,11 @@ class ThenContainer extends StatelessWidget { return; } - final result = await DeviceDialogHelper.showDeviceDialog( - context, mutableData, + final result = await DeviceDialogHelper.showDeviceDialog(context, mutableData, removeComparetors: true); if (result != null) { context.read().add(AddToThenContainer(mutableData)); - } else if (!['AC', '1G', '2G', '3G'] - .contains(mutableData['productType'])) { + } else if (!['AC', '1G', '2G', '3G'].contains(mutableData['productType'])) { context.read().add(AddToThenContainer(mutableData)); } }, From 246098b83a5a535b80b36debb2a9e9520c6e3efc Mon Sep 17 00:00:00 2001 From: Abdullah Alassaf Date: Thu, 5 Dec 2024 12:42:53 +0300 Subject: [PATCH 12/18] Read icon from fetch scene api --- .../bloc/routine_bloc/routine_bloc.dart | 3 ++ .../routiens/helper/save_routine_helper.dart | 2 +- .../models/routine_details_model.dart | 52 +++++++++---------- lib/pages/routiens/widgets/dragable_card.dart | 22 ++++---- 4 files changed, 37 insertions(+), 42 deletions(-) diff --git a/lib/pages/routiens/bloc/routine_bloc/routine_bloc.dart b/lib/pages/routiens/bloc/routine_bloc/routine_bloc.dart index 89781032..a90ea116 100644 --- a/lib/pages/routiens/bloc/routine_bloc/routine_bloc.dart +++ b/lib/pages/routiens/bloc/routine_bloc/routine_bloc.dart @@ -758,6 +758,8 @@ class RoutineBloc extends Bloc { thenItems: [], selectedFunctions: {}, scenes: [], + sceneId: '', + automationId: '', automations: [], isLoading: false, errorMessage: '', @@ -1142,6 +1144,7 @@ class RoutineBloc extends Bloc { : action.type == 'automation' ? 'automation' : 'action', + 'icon': action.icon ?? '' }; } diff --git a/lib/pages/routiens/helper/save_routine_helper.dart b/lib/pages/routiens/helper/save_routine_helper.dart index 280c539a..d73a69a7 100644 --- a/lib/pages/routiens/helper/save_routine_helper.dart +++ b/lib/pages/routiens/helper/save_routine_helper.dart @@ -101,7 +101,7 @@ class SaveRoutineHelper { final functions = state.selectedFunctions[item['uniqueCustomId']] ?? []; return ListTile( - leading: item['type'] == 'tap_to_run' + leading: item['type'] == 'tap_to_run' || item['type'] == 'scene' ? Image.memory( base64Decode(item['icon']), width: 22, diff --git a/lib/pages/routiens/models/routine_details_model.dart b/lib/pages/routiens/models/routine_details_model.dart index 169bd237..8a4a1202 100644 --- a/lib/pages/routiens/models/routine_details_model.dart +++ b/lib/pages/routiens/models/routine_details_model.dart @@ -48,8 +48,7 @@ class RoutineDetailsModel { spaceUuid: spaceUuid, automationName: name, decisionExpr: decisionExpr, - effectiveTime: - effectiveTime ?? EffectiveTime(start: '', end: '', loops: ''), + effectiveTime: effectiveTime ?? EffectiveTime(start: '', end: '', loops: ''), conditions: conditions?.map((c) => c.toCondition()).toList() ?? [], actions: actions.map((a) => a.toAutomationAction()).toList(), ); @@ -64,8 +63,7 @@ class RoutineDetailsModel { if (iconId != null) 'iconUuid': iconId, if (showInDevice != null) 'showInDevice': showInDevice, if (effectiveTime != null) 'effectiveTime': effectiveTime!.toMap(), - if (conditions != null) - 'conditions': conditions!.map((x) => x.toMap()).toList(), + if (conditions != null) 'conditions': conditions!.map((x) => x.toMap()).toList(), if (type != null) 'type': type, if (sceneId != null) 'sceneId': sceneId, if (automationId != null) 'automationId': automationId, @@ -82,12 +80,10 @@ class RoutineDetailsModel { ), iconId: map['iconUuid'], showInDevice: map['showInDevice'], - effectiveTime: map['effectiveTime'] != null - ? EffectiveTime.fromMap(map['effectiveTime']) - : null, + effectiveTime: + map['effectiveTime'] != null ? EffectiveTime.fromMap(map['effectiveTime']) : null, conditions: map['conditions'] != null - ? List.from( - map['conditions'].map((x) => RoutineCondition.fromMap(x))) + ? List.from(map['conditions'].map((x) => RoutineCondition.fromMap(x))) : null, type: map['type'], sceneId: map['sceneId'], @@ -108,15 +104,16 @@ class RoutineAction { final RoutineExecutorProperty? executorProperty; final String productType; final String? type; + final String? icon; - RoutineAction({ - required this.entityId, - required this.actionExecutor, - required this.productType, - this.executorProperty, - this.name, - this.type, - }); + RoutineAction( + {required this.entityId, + required this.actionExecutor, + required this.productType, + this.executorProperty, + this.name, + this.type, + this.icon}); CreateSceneAction toCreateSceneAction() { return CreateSceneAction( @@ -140,22 +137,21 @@ class RoutineAction { 'actionExecutor': actionExecutor, if (type != null) 'type': type, if (name != null) 'name': name, - if (executorProperty != null) - 'executorProperty': executorProperty!.toMap(), + if (executorProperty != null) 'executorProperty': executorProperty!.toMap(), }; } factory RoutineAction.fromMap(Map map) { return RoutineAction( - entityId: map['entityId'] ?? '', - actionExecutor: map['actionExecutor'] ?? '', - productType: map['productType'] ?? '', - name: map['name'] ?? '', - type: map['type'] ?? '', - executorProperty: map['executorProperty'] != null - ? RoutineExecutorProperty.fromMap(map['executorProperty']) - : null, - ); + entityId: map['entityId'] ?? '', + actionExecutor: map['actionExecutor'] ?? '', + productType: map['productType'] ?? '', + name: map['name'] ?? '', + type: map['type'] ?? '', + executorProperty: map['executorProperty'] != null + ? RoutineExecutorProperty.fromMap(map['executorProperty']) + : null, + icon: map['icon']); } } diff --git a/lib/pages/routiens/widgets/dragable_card.dart b/lib/pages/routiens/widgets/dragable_card.dart index e26d3d12..56961892 100644 --- a/lib/pages/routiens/widgets/dragable_card.dart +++ b/lib/pages/routiens/widgets/dragable_card.dart @@ -32,18 +32,17 @@ class DraggableCard extends StatelessWidget { Widget build(BuildContext context) { return BlocBuilder( builder: (context, state) { - final deviceFunctions = - state.selectedFunctions[deviceData['uniqueCustomId']] ?? []; + final deviceFunctions = state.selectedFunctions[deviceData['uniqueCustomId']] ?? []; - int index = state.thenItems.indexWhere( - (item) => item['uniqueCustomId'] == deviceData['uniqueCustomId']); + int index = state.thenItems + .indexWhere((item) => item['uniqueCustomId'] == deviceData['uniqueCustomId']); if (index != -1) { return _buildCardContent(context, deviceFunctions, padding: padding); } - int ifIndex = state.ifItems.indexWhere( - (item) => item['uniqueCustomId'] == deviceData['uniqueCustomId']); + int ifIndex = state.ifItems + .indexWhere((item) => item['uniqueCustomId'] == deviceData['uniqueCustomId']); if (ifIndex != -1) { return _buildCardContent(context, deviceFunctions, padding: padding); @@ -53,8 +52,7 @@ class DraggableCard extends StatelessWidget { data: deviceData, feedback: Transform.rotate( angle: -0.1, - child: - _buildCardContent(context, deviceFunctions, padding: padding), + child: _buildCardContent(context, deviceFunctions, padding: padding), ), childWhenDragging: _buildGreyContainer(), child: _buildCardContent(context, deviceFunctions, padding: padding), @@ -63,8 +61,7 @@ class DraggableCard extends StatelessWidget { ); } - Widget _buildCardContent( - BuildContext context, List deviceFunctions, + Widget _buildCardContent(BuildContext context, List deviceFunctions, {EdgeInsetsGeometry? padding}) { return Stack( children: [ @@ -93,7 +90,7 @@ class DraggableCard extends StatelessWidget { ), ), padding: const EdgeInsets.all(8), - child: deviceData['type'] == 'tap_to_run' + child: deviceData['type'] == 'tap_to_run' || deviceData['type'] == 'scene' ? Image.memory( base64Decode(deviceData['icon']), ) @@ -162,8 +159,7 @@ class DraggableCard extends StatelessWidget { } String _formatFunctionValue(DeviceFunctionData function) { - if (function.functionCode == 'temp_set' || - function.functionCode == 'temp_current') { + if (function.functionCode == 'temp_set' || function.functionCode == 'temp_current') { return '${(function.value / 10).toStringAsFixed(0)}°C'; } else if (function.functionCode.contains('countdown')) { final seconds = function.value.toInt(); From aff7ceeac4a36f522c46289587750b7da5fe4680 Mon Sep 17 00:00:00 2001 From: hannathkadher Date: Mon, 9 Dec 2024 10:02:20 +0400 Subject: [PATCH 13/18] added condition to check parent name --- .../widgets/dialogs/create_space_dialog.dart | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/pages/spaces_management/all_spaces/widgets/dialogs/create_space_dialog.dart b/lib/pages/spaces_management/all_spaces/widgets/dialogs/create_space_dialog.dart index e0853e3a..496c1147 100644 --- a/lib/pages/spaces_management/all_spaces/widgets/dialogs/create_space_dialog.dart +++ b/lib/pages/spaces_management/all_spaces/widgets/dialogs/create_space_dialog.dart @@ -133,13 +133,7 @@ class CreateSpaceDialogState extends State { isNameFieldInvalid = value.isEmpty; if (!isNameFieldInvalid) { - if ((widget.parentSpace?.children.any( - (child) => child.name == value) ?? - false) || - (widget.parentSpace?.name == value) || - (widget.editSpace?.children.any( - (child) => child.name == value) ?? - false)) { + if (_isNameConflict(value)) { isNameFieldExist = true; isOkButtonEnabled = false; } else { @@ -387,7 +381,13 @@ class CreateSpaceDialogState extends State { ); } - + bool _isNameConflict(String value) { + return (widget.parentSpace?.children.any((child) => child.name == value) ?? + false) || + (widget.editSpace?.parent?.name == value) || + (widget.editSpace?.children.any((child) => child.name == value) ?? + false); + } String _mapIconToProduct(String uuid, List products) { // Find the product with the matching UUID From 4055265b0aa58affa17c5b2015429abf72abd747 Mon Sep 17 00:00:00 2001 From: hannathkadher Date: Mon, 9 Dec 2024 10:02:57 +0400 Subject: [PATCH 14/18] for create --- .../all_spaces/widgets/dialogs/create_space_dialog.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pages/spaces_management/all_spaces/widgets/dialogs/create_space_dialog.dart b/lib/pages/spaces_management/all_spaces/widgets/dialogs/create_space_dialog.dart index 496c1147..f6a02833 100644 --- a/lib/pages/spaces_management/all_spaces/widgets/dialogs/create_space_dialog.dart +++ b/lib/pages/spaces_management/all_spaces/widgets/dialogs/create_space_dialog.dart @@ -384,6 +384,7 @@ class CreateSpaceDialogState extends State { bool _isNameConflict(String value) { return (widget.parentSpace?.children.any((child) => child.name == value) ?? false) || + (widget.parentSpace?.name == value) || (widget.editSpace?.parent?.name == value) || (widget.editSpace?.children.any((child) => child.name == value) ?? false); From dd5fe10a217bbb32392be3122840d27655ce0652 Mon Sep 17 00:00:00 2001 From: hannathkadher Date: Mon, 9 Dec 2024 10:03:40 +0400 Subject: [PATCH 15/18] removed print --- .../all_spaces/bloc/space_management_bloc.dart | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/pages/spaces_management/all_spaces/bloc/space_management_bloc.dart b/lib/pages/spaces_management/all_spaces/bloc/space_management_bloc.dart index a171f2a7..ffa5687e 100644 --- a/lib/pages/spaces_management/all_spaces/bloc/space_management_bloc.dart +++ b/lib/pages/spaces_management/all_spaces/bloc/space_management_bloc.dart @@ -309,8 +309,6 @@ class SpaceManagementBloc await _api.deleteSpace(communityUuid, parent.uuid!); } } catch (e) { - print( - 'Error deleting space ${parent.name} (UUID: ${parent.uuid}, Community UUID: $communityUuid): $e'); rethrow; // Decide whether to stop execution or continue } } @@ -342,7 +340,6 @@ class SpaceManagementBloc space.uuid = response?.uuid; } } catch (e) { - print('Error creating space ${space.name}: $e'); rethrow; // Stop further execution on failure } } From 4896b6c59372b2920545134916f71045d67064b3 Mon Sep 17 00:00:00 2001 From: hannathkadher Date: Tue, 10 Dec 2024 09:50:42 +0400 Subject: [PATCH 16/18] changed endpoint for communtiies and spaces, hardcoded p[roject value for now --- lib/services/routines_api.dart | 4 +++- lib/services/space_mana_api.dart | 33 ++++++++++++++++++++--------- lib/utils/constants/api_const.dart | 28 ++++++++++++------------ lib/utils/constants/temp_const.dart | 3 +++ 4 files changed, 43 insertions(+), 25 deletions(-) create mode 100644 lib/utils/constants/temp_const.dart diff --git a/lib/services/routines_api.dart b/lib/services/routines_api.dart index ffc8a8c7..7be3ff11 100644 --- a/lib/services/routines_api.dart +++ b/lib/services/routines_api.dart @@ -6,6 +6,7 @@ import 'package:syncrow_web/pages/routiens/models/routine_details_model.dart'; import 'package:syncrow_web/pages/routiens/models/routine_model.dart'; import 'package:syncrow_web/services/api/http_service.dart'; import 'package:syncrow_web/utils/constants/api_const.dart'; +import 'package:syncrow_web/utils/constants/temp_const.dart'; class SceneApi { static final HTTPService _httpService = HTTPService(); @@ -76,7 +77,8 @@ class SceneApi { final response = await _httpService.get( path: ApiEndpoints.getUnitScenes .replaceAll('{spaceUuid}', unitId) - .replaceAll('{communityUuid}', communityId), + .replaceAll('{communityUuid}', communityId) + .replaceAll('{projectId}', TempConst.projectId), queryParameters: {'showInHomePage': showInDevice}, showServerMessage: false, expectedResponseModel: (json) { diff --git a/lib/services/space_mana_api.dart b/lib/services/space_mana_api.dart index 55875bfa..def94441 100644 --- a/lib/services/space_mana_api.dart +++ b/lib/services/space_mana_api.dart @@ -5,6 +5,7 @@ import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_response_model.dart'; import 'package:syncrow_web/services/api/http_service.dart'; import 'package:syncrow_web/utils/constants/api_const.dart'; +import 'package:syncrow_web/utils/constants/temp_const.dart'; class CommunitySpaceManagementApi { // Community Management APIs @@ -15,7 +16,8 @@ class CommunitySpaceManagementApi { while (hasNext) { await HTTPService().get( - path: ApiEndpoints.getCommunityList, + path: ApiEndpoints.getCommunityList + .replaceAll('{projectId}', TempConst.projectId), queryParameters: {'page': page}, expectedResponseModel: (json) { List jsonData = json['data']; @@ -59,7 +61,8 @@ class CommunitySpaceManagementApi { String name, String description) async { try { final response = await HTTPService().post( - path: ApiEndpoints.createCommunity, + path: ApiEndpoints.createCommunity + .replaceAll('{projectId}', TempConst.projectId), body: { 'name': name, 'description': description, @@ -79,7 +82,8 @@ class CommunitySpaceManagementApi { try { final response = await HTTPService().put( path: ApiEndpoints.updateCommunity - .replaceAll('{communityId}', communityId), + .replaceAll('{communityId}', communityId) + .replaceAll('{projectId}', TempConst.projectId), body: { 'name': name, }, @@ -98,7 +102,8 @@ class CommunitySpaceManagementApi { try { final response = await HTTPService().delete( path: ApiEndpoints.deleteCommunity - .replaceAll('{communityId}', communityId), + .replaceAll('{communityId}', communityId) + .replaceAll('{projectId}', TempConst.projectId), expectedResponseModel: (json) { return json['success'] ?? false; }, @@ -113,7 +118,9 @@ class CommunitySpaceManagementApi { Future fetchSpaces(String communityId) async { try { final response = await HTTPService().get( - path: ApiEndpoints.listSpaces.replaceAll('{communityId}', communityId), + path: ApiEndpoints.listSpaces + .replaceAll('{communityId}', communityId) + .replaceAll('{projectId}', TempConst.projectId), expectedResponseModel: (json) { return SpacesResponse.fromJson(json); }, @@ -139,7 +146,8 @@ class CommunitySpaceManagementApi { final response = await HTTPService().get( path: ApiEndpoints.getSpace .replaceAll('{communityId}', communityId) - .replaceAll('{spaceId}', spaceId), + .replaceAll('{spaceId}', spaceId) + .replaceAll('{projectId}', TempConst.projectId), expectedResponseModel: (json) { return SpaceModel.fromJson(json); }, @@ -175,7 +183,9 @@ class CommunitySpaceManagementApi { body['parentUuid'] = parentId; } final response = await HTTPService().post( - path: ApiEndpoints.createSpace.replaceAll('{communityId}', communityId), + path: ApiEndpoints.createSpace + .replaceAll('{communityId}', communityId) + .replaceAll('{projectId}', TempConst.projectId), body: body, expectedResponseModel: (json) { return SpaceModel.fromJson(json['data']); @@ -216,7 +226,8 @@ class CommunitySpaceManagementApi { final response = await HTTPService().put( path: ApiEndpoints.updateSpace .replaceAll('{communityId}', communityId) - .replaceAll('{spaceId}', spaceId), + .replaceAll('{spaceId}', spaceId) + .replaceAll('{projectId}', TempConst.projectId), body: body, expectedResponseModel: (json) { return SpaceModel.fromJson(json['data']); @@ -234,7 +245,8 @@ class CommunitySpaceManagementApi { final response = await HTTPService().delete( path: ApiEndpoints.deleteSpace .replaceAll('{communityId}', communityId) - .replaceAll('{spaceId}', spaceId), + .replaceAll('{spaceId}', spaceId) + .replaceAll('{projectId}', TempConst.projectId), expectedResponseModel: (json) { return json['success'] ?? false; }, @@ -250,7 +262,8 @@ class CommunitySpaceManagementApi { try { final response = await HTTPService().get( path: ApiEndpoints.getSpaceHierarchy - .replaceAll('{communityId}', communityId), + .replaceAll('{communityId}', communityId) + .replaceAll('{projectId}', TempConst.projectId), expectedResponseModel: (json) { final spaceModels = (json['data'] as List) .map((spaceJson) => SpaceModel.fromJson(spaceJson)) diff --git a/lib/utils/constants/api_const.dart b/lib/utils/constants/api_const.dart index 007b488d..b8d23259 100644 --- a/lib/utils/constants/api_const.dart +++ b/lib/utils/constants/api_const.dart @@ -36,21 +36,21 @@ abstract class ApiEndpoints { static const String getDeviceLogs = '/device/report-logs/{uuid}?code={code}'; // Space Module - static const String createSpace = '/communities/{communityId}/spaces'; - static const String listSpaces = '/communities/{communityId}/spaces'; - static const String deleteSpace = '/communities/{communityId}/spaces/{spaceId}'; - static const String updateSpace = '/communities/{communityId}/spaces/{spaceId}'; - static const String getSpace = '/communities/{communityId}/spaces/{spaceId}'; - static const String getSpaceHierarchy = '/communities/{communityId}/spaces'; + static const String createSpace = '/projects/{projectId}/communities/{communityId}/spaces'; + static const String listSpaces = '/projects/{projectId}/communities/{communityId}/spaces'; + static const String deleteSpace = '/projects/{projectId}/communities/{communityId}/spaces/{spaceId}'; + static const String updateSpace = '/projects/{projectId}/communities/{communityId}/spaces/{spaceId}'; + static const String getSpace = '/projects/{projectId}/communities/{communityId}/spaces/{spaceId}'; + static const String getSpaceHierarchy = '/projects/{projectId}/communities/{communityId}/spaces'; // Community Module - static const String createCommunity = '/communities'; - static const String getCommunityList = '/communities'; - static const String getCommunityById = '/communities/{communityId}'; - static const String updateCommunity = '/communities/{communityId}'; - static const String deleteCommunity = '/communities/{communityId}'; - static const String getUserCommunities = '/communities/user/{userUuid}'; - static const String createUserCommunity = '/communities/user'; + static const String createCommunity = '/projects/{projectId}/communities'; + static const String getCommunityList = '/projects/{projectId}/communities'; + static const String getCommunityById = '/projects/{projectId}/communities/{communityId}'; + static const String updateCommunity = '/projects/{projectId}/communities/{communityId}'; + static const String deleteCommunity = '/projects/{projectId}communities/{communityId}'; + static const String getUserCommunities = '/projects/{projectId}/communities/user/{userUuid}'; + static const String createUserCommunity = '/projects/{projectId}/communities/user'; static const String getDeviceLogsByDate = '/device/report-logs/{uuid}?code={code}&startTime={startTime}&endTime={endTime}'; @@ -68,7 +68,7 @@ abstract class ApiEndpoints { static const String getIconScene = '/scene/icon'; static const String createScene = '/scene/tap-to-run'; static const String createAutomation = '/automation'; - static const String getUnitScenes = '/communities/{communityUuid}/spaces/{spaceUuid}/scenes'; + static const String getUnitScenes = '/projects/{projectId}/communities/{communityUuid}/spaces/{spaceUuid}/scenes'; static const String getAutomationDetails = '/automation/details/{automationId}'; static const String getScene = '/scene/tap-to-run/{sceneId}'; static const String deleteScene = '/scene/tap-to-run/{sceneId}'; diff --git a/lib/utils/constants/temp_const.dart b/lib/utils/constants/temp_const.dart new file mode 100644 index 00000000..e5847b98 --- /dev/null +++ b/lib/utils/constants/temp_const.dart @@ -0,0 +1,3 @@ +class TempConst { + static const projectId = '0e62577c-06fa-41b9-8a92-99a21fbaf51c'; +} From c362973c941eab96153f4b3c74facc1b1e0090d0 Mon Sep 17 00:00:00 2001 From: Abdullah Alassaf Date: Tue, 17 Dec 2024 01:55:08 +0300 Subject: [PATCH 17/18] Hide unused widgets --- .../view/access_management.dart | 73 +++--- lib/pages/auth/bloc/auth_bloc.dart | 40 +-- lib/pages/auth/view/login_web_page.dart | 4 +- .../ac/view/ac_device_batch_control.dart | 14 +- .../view/ceiling_sensor_batch_control.dart | 4 +- .../view/curtain_batch_status_view.dart | 11 +- .../view/door_lock_batch_control_view.dart | 27 +- .../view/garage_door_batch_control_view.dart | 19 +- .../gateway/view/gateway_batch_control.dart | 23 +- .../view/main_door_sensor_batch_view.dart | 24 +- .../one_gang_glass_batch_control_view.dart | 19 +- .../view/wall_light_batch_control.dart | 22 +- .../view/power_clamp_batch_control_view.dart | 29 +-- .../shared/batch_control/firmware_update.dart | 244 +++++++++--------- .../sos/view/sos_batch_control_view.dart | 19 +- ..._gang_glass_switch_batch_control_view.dart | 10 +- .../view/living_room_batch_controls.dart | 23 +- ..._gang_glass_switch_batch_control_view.dart | 14 +- .../view/wall_light_batch_control.dart | 16 +- .../view/wall_sensor_batch_control.dart | 4 +- .../view/water_heater_batch_control.dart | 20 +- .../view/water_leak_batch_control_view.dart | 29 +-- lib/pages/home/bloc/home_bloc.dart | 70 ++--- lib/pages/home/view/home_page_web.dart | 2 +- lib/utils/user_drop_down_menu.dart | 46 ++-- 25 files changed, 378 insertions(+), 428 deletions(-) diff --git a/lib/pages/access_management/view/access_management.dart b/lib/pages/access_management/view/access_management.dart index bed27eea..9fe3a722 100644 --- a/lib/pages/access_management/view/access_management.dart +++ b/lib/pages/access_management/view/access_management.dart @@ -11,7 +11,7 @@ import 'package:syncrow_web/pages/common/filter/filter_widget.dart'; import 'package:syncrow_web/pages/common/text_field/custom_web_textfield.dart'; import 'package:syncrow_web/pages/device_managment/shared/navigate_home_grid_view.dart'; import 'package:syncrow_web/pages/visitor_password/view/visitor_password_dialog.dart'; -import 'package:syncrow_web/utils/color_manager.dart'; +// import 'package:syncrow_web/utils/color_manager.dart'; import 'package:syncrow_web/utils/constants/app_enum.dart'; import 'package:syncrow_web/utils/constants/assets.dart'; import 'package:syncrow_web/utils/extension/build_context_x.dart'; @@ -27,8 +27,7 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout { final isLargeScreen = isLargeScreenSize(context); final isSmallScreen = isSmallScreenSize(context); final isHalfMediumScreen = isHafMediumScreenSize(context); - final padding = - isLargeScreen ? const EdgeInsets.all(30) : const EdgeInsets.all(15); + final padding = isLargeScreen ? const EdgeInsets.all(30) : const EdgeInsets.all(15); return WebScaffold( enableMenuSidebar: false, @@ -40,8 +39,7 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout { ), rightBody: const NavigateHomeGridView(), scaffoldBody: BlocProvider( - create: (BuildContext context) => - AccessBloc()..add(FetchTableData()), + create: (BuildContext context) => AccessBloc()..add(FetchTableData()), child: BlocConsumer( listener: (context, state) {}, builder: (context, state) { @@ -95,14 +93,11 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout { return [ item.passwordName, item.passwordType.value, - accessBloc - .timestampToDate(item.effectiveTime), - accessBloc - .timestampToDate(item.invalidTime), + accessBloc.timestampToDate(item.effectiveTime), + accessBloc.timestampToDate(item.invalidTime), item.deviceName.toString(), item.authorizerEmail.toString(), - accessBloc - .timestampToDate(item.invalidTime), + accessBloc.timestampToDate(item.invalidTime), item.passwordStatus.value, ]; }).toList(), @@ -113,8 +108,7 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout { }))); } - Wrap _buildVisitorAdminPasswords( - BuildContext context, AccessBloc accessBloc) { + Wrap _buildVisitorAdminPasswords(BuildContext context, AccessBloc accessBloc) { return Wrap( spacing: 10, runSpacing: 10, @@ -140,23 +134,22 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout { borderRadius: 8, child: Text( 'Create Visitor Password ', - style: context.textTheme.titleSmall! - .copyWith(color: Colors.white, fontSize: 12), - )), - ), - Container( - width: 133, - height: 42, - decoration: containerDecoration, - child: DefaultButton( - borderRadius: 8, - backgroundColor: ColorsManager.whiteColors, - child: Text( - 'Admin Password', - style: context.textTheme.titleSmall! - .copyWith(color: Colors.black, fontSize: 12), + style: context.textTheme.titleSmall!.copyWith(color: Colors.white, fontSize: 12), )), ), + // Container( + // width: 133, + // height: 42, + // decoration: containerDecoration, + // child: DefaultButton( + // borderRadius: 8, + // backgroundColor: ColorsManager.whiteColors, + // child: Text( + // 'Admin Password', + // style: context.textTheme.titleSmall! + // .copyWith(color: Colors.black, fontSize: 12), + // )), + // ), ], ); } @@ -179,10 +172,8 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout { description: '', onSubmitted: (value) { accessBloc.add(FilterDataEvent( - emailAuthorizer: - accessBloc.emailAuthorizer.text.toLowerCase(), - selectedTabIndex: - BlocProvider.of(context).selectedIndex, + emailAuthorizer: accessBloc.emailAuthorizer.text.toLowerCase(), + selectedTabIndex: BlocProvider.of(context).selectedIndex, passwordName: accessBloc.passwordName.text.toLowerCase(), startTime: accessBloc.effectiveTimeTimeStamp, endTime: accessBloc.expirationTimeTimeStamp)); @@ -200,10 +191,8 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout { description: '', onSubmitted: (value) { accessBloc.add(FilterDataEvent( - emailAuthorizer: - accessBloc.emailAuthorizer.text.toLowerCase(), - selectedTabIndex: - BlocProvider.of(context).selectedIndex, + emailAuthorizer: accessBloc.emailAuthorizer.text.toLowerCase(), + selectedTabIndex: BlocProvider.of(context).selectedIndex, passwordName: accessBloc.passwordName.text.toLowerCase(), startTime: accessBloc.effectiveTimeTimeStamp, endTime: accessBloc.expirationTimeTimeStamp)); @@ -232,8 +221,7 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout { onSearch: () { accessBloc.add(FilterDataEvent( emailAuthorizer: accessBloc.emailAuthorizer.text.toLowerCase(), - selectedTabIndex: - BlocProvider.of(context).selectedIndex, + selectedTabIndex: BlocProvider.of(context).selectedIndex, passwordName: accessBloc.passwordName.text.toLowerCase(), startTime: accessBloc.effectiveTimeTimeStamp, endTime: accessBloc.expirationTimeTimeStamp)); @@ -261,10 +249,8 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout { description: '', onSubmitted: (value) { accessBloc.add(FilterDataEvent( - emailAuthorizer: - accessBloc.emailAuthorizer.text.toLowerCase(), - selectedTabIndex: - BlocProvider.of(context).selectedIndex, + emailAuthorizer: accessBloc.emailAuthorizer.text.toLowerCase(), + selectedTabIndex: BlocProvider.of(context).selectedIndex, passwordName: accessBloc.passwordName.text.toLowerCase(), startTime: accessBloc.effectiveTimeTimeStamp, endTime: accessBloc.expirationTimeTimeStamp)); @@ -288,8 +274,7 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout { onSearch: () { accessBloc.add(FilterDataEvent( emailAuthorizer: accessBloc.emailAuthorizer.text.toLowerCase(), - selectedTabIndex: - BlocProvider.of(context).selectedIndex, + selectedTabIndex: BlocProvider.of(context).selectedIndex, passwordName: accessBloc.passwordName.text.toLowerCase(), startTime: accessBloc.effectiveTimeTimeStamp, endTime: accessBloc.expirationTimeTimeStamp)); diff --git a/lib/pages/auth/bloc/auth_bloc.dart b/lib/pages/auth/bloc/auth_bloc.dart index 60cc2f86..95ecb0ad 100644 --- a/lib/pages/auth/bloc/auth_bloc.dart +++ b/lib/pages/auth/bloc/auth_bloc.dart @@ -31,8 +31,7 @@ class AuthBloc extends Bloc { ////////////////////////////// forget password ////////////////////////////////// final TextEditingController forgetEmailController = TextEditingController(); - final TextEditingController forgetPasswordController = - TextEditingController(); + final TextEditingController forgetPasswordController = TextEditingController(); final TextEditingController forgetOtp = TextEditingController(); final forgetFormKey = GlobalKey(); final forgetEmailKey = GlobalKey(); @@ -49,8 +48,7 @@ class AuthBloc extends Bloc { return; } _remainingTime = 1; - add(UpdateTimerEvent( - remainingTime: _remainingTime, isButtonEnabled: false)); + add(UpdateTimerEvent(remainingTime: _remainingTime, isButtonEnabled: false)); try { forgetEmailValidate = ''; _remainingTime = (await AuthenticationAPI.sendOtp( @@ -86,8 +84,7 @@ class AuthBloc extends Bloc { _timer?.cancel(); add(const UpdateTimerEvent(remainingTime: 0, isButtonEnabled: true)); } else { - add(UpdateTimerEvent( - remainingTime: _remainingTime, isButtonEnabled: false)); + add(UpdateTimerEvent(remainingTime: _remainingTime, isButtonEnabled: false)); } }); } @@ -97,8 +94,7 @@ class AuthBloc extends Bloc { emit(const TimerState(isButtonEnabled: true, remainingTime: 0)); } - Future changePassword( - ChangePasswordEvent event, Emitter emit) async { + Future changePassword(ChangePasswordEvent event, Emitter emit) async { emit(LoadingForgetState()); try { var response = await AuthenticationAPI.verifyOtp( @@ -114,8 +110,7 @@ class AuthBloc extends Bloc { } } on DioException catch (e) { final errorData = e.response!.data; - String errorMessage = - errorData['error']['message'] ?? 'something went wrong'; + String errorMessage = errorData['error']['message'] ?? 'something went wrong'; validate = errorMessage; emit(AuthInitialState()); } @@ -129,16 +124,14 @@ class AuthBloc extends Bloc { } void _onUpdateTimer(UpdateTimerEvent event, Emitter emit) { - emit(TimerState( - isButtonEnabled: event.isButtonEnabled, - remainingTime: event.remainingTime)); + emit(TimerState(isButtonEnabled: event.isButtonEnabled, remainingTime: event.remainingTime)); } ///////////////////////////////////// login ///////////////////////////////////// final TextEditingController loginEmailController = TextEditingController(); final TextEditingController loginPasswordController = TextEditingController(); final loginFormKey = GlobalKey(); - bool isChecked = false; + bool isChecked = true; bool obscureText = true; String newPassword = ''; String maskedEmail = ''; @@ -163,9 +156,7 @@ class AuthBloc extends Bloc { token = await AuthenticationAPI.loginWithEmail( model: LoginWithEmailModel( - email: event.username, - password: event.password, - regionUuid: event.regionUuid), + email: event.username, password: event.password, regionUuid: event.regionUuid), ); } catch (failure) { validate = 'Invalid Credentials!'; @@ -175,8 +166,7 @@ class AuthBloc extends Bloc { if (token.accessTokenIsNotEmpty) { FlutterSecureStorage storage = const FlutterSecureStorage(); - await storage.write( - key: Token.loginAccessTokenKey, value: token.accessToken); + await storage.write(key: Token.loginAccessTokenKey, value: token.accessToken); const FlutterSecureStorage().write( key: UserModel.userUuidKey, value: Token.decodeToken(token.accessToken)['uuid'].toString()); @@ -334,14 +324,12 @@ class AuthBloc extends Bloc { static Future getTokenAndValidate() async { try { const storage = FlutterSecureStorage(); - final firstLaunch = await SharedPreferencesHelper.readBoolFromSP( - StringsManager.firstLaunch) ?? - true; + final firstLaunch = + await SharedPreferencesHelper.readBoolFromSP(StringsManager.firstLaunch) ?? true; if (firstLaunch) { storage.deleteAll(); } - await SharedPreferencesHelper.saveBoolToSP( - StringsManager.firstLaunch, false); + await SharedPreferencesHelper.saveBoolToSP(StringsManager.firstLaunch, false); final value = await storage.read(key: Token.loginAccessTokenKey) ?? ''; if (value.isEmpty) { return 'Token not found'; @@ -394,9 +382,7 @@ class AuthBloc extends Bloc { final String formattedTime = [ if (days > 0) '${days}d', // Append 'd' for days if (days > 0 || hours > 0) - hours - .toString() - .padLeft(2, '0'), // Show hours if there are days or hours + hours.toString().padLeft(2, '0'), // Show hours if there are days or hours minutes.toString().padLeft(2, '0'), seconds.toString().padLeft(2, '0'), ].join(':'); diff --git a/lib/pages/auth/view/login_web_page.dart b/lib/pages/auth/view/login_web_page.dart index 555f8f4a..303dac76 100644 --- a/lib/pages/auth/view/login_web_page.dart +++ b/lib/pages/auth/view/login_web_page.dart @@ -163,8 +163,8 @@ class _LoginWebPageState extends State with HelperResponsiveLayout _buildPasswordField(context, loginBloc), const SizedBox(height: 20), _buildForgotPassword(context), - const SizedBox(height: 20), - _buildCheckbox(context, loginBloc, size), + // const SizedBox(height: 20), + // _buildCheckbox(context, loginBloc, size), const SizedBox(height: 20.0), _buildSignInButton(context, loginBloc, size), const SizedBox(height: 15.0), diff --git a/lib/pages/device_managment/ac/view/ac_device_batch_control.dart b/lib/pages/device_managment/ac/view/ac_device_batch_control.dart index 2da394c7..3005c1c5 100644 --- a/lib/pages/device_managment/ac/view/ac_device_batch_control.dart +++ b/lib/pages/device_managment/ac/view/ac_device_batch_control.dart @@ -8,7 +8,7 @@ import 'package:syncrow_web/pages/device_managment/ac/view/batch_control_list/ba import 'package:syncrow_web/pages/device_managment/ac/view/batch_control_list/batch_fan_speed.dart'; import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_reset_model.dart'; import 'package:syncrow_web/pages/device_managment/shared/batch_control/factory_reset.dart'; -import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart'; +// import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart'; import 'package:syncrow_web/pages/device_managment/shared/toggle_widget.dart'; import 'package:syncrow_web/utils/color_manager.dart'; import 'package:syncrow_web/utils/constants/assets.dart'; @@ -26,7 +26,8 @@ class AcDeviceBatchControlView extends StatelessWidget with HelperResponsiveLayo final isLarge = isLargeScreenSize(context); final isMedium = isMediumScreenSize(context); return BlocProvider( - create: (context) => AcBloc(deviceId: devicesIds.first)..add(AcFetchBatchStatusEvent(devicesIds)), + create: (context) => + AcBloc(deviceId: devicesIds.first)..add(AcFetchBatchStatusEvent(devicesIds)), child: BlocBuilder( builder: (context, state) { if (state is ACStatusLoaded) { @@ -98,7 +99,8 @@ class AcDeviceBatchControlView extends StatelessWidget with HelperResponsiveLayo ), Text( 'h', - style: context.textTheme.bodySmall!.copyWith(color: ColorsManager.blackColor), + style: + context.textTheme.bodySmall!.copyWith(color: ColorsManager.blackColor), ), Text( '30', @@ -107,7 +109,9 @@ class AcDeviceBatchControlView extends StatelessWidget with HelperResponsiveLayo fontWeight: FontWeight.bold, ), ), - Text('m', style: context.textTheme.bodySmall!.copyWith(color: ColorsManager.blackColor)), + Text('m', + style: context.textTheme.bodySmall! + .copyWith(color: ColorsManager.blackColor)), IconButton( onPressed: () {}, icon: const Icon( @@ -138,7 +142,7 @@ class AcDeviceBatchControlView extends StatelessWidget with HelperResponsiveLayo )); }, ), - FirmwareUpdateWidget(deviceId: devicesIds.first, version: 5), + // FirmwareUpdateWidget(deviceId: devicesIds.first, version: 5), FactoryResetWidget( callFactoryReset: () { context.read().add(AcFactoryResetEvent( diff --git a/lib/pages/device_managment/ceiling_sensor/view/ceiling_sensor_batch_control.dart b/lib/pages/device_managment/ceiling_sensor/view/ceiling_sensor_batch_control.dart index b7f9af5d..cf645b6f 100644 --- a/lib/pages/device_managment/ceiling_sensor/view/ceiling_sensor_batch_control.dart +++ b/lib/pages/device_managment/ceiling_sensor/view/ceiling_sensor_batch_control.dart @@ -6,7 +6,7 @@ import 'package:syncrow_web/pages/device_managment/ceiling_sensor/bloc/ceiling_e import 'package:syncrow_web/pages/device_managment/ceiling_sensor/bloc/ceiling_state.dart'; import 'package:syncrow_web/pages/device_managment/ceiling_sensor/model/ceiling_sensor_model.dart'; import 'package:syncrow_web/pages/device_managment/shared/batch_control/factory_reset.dart'; -import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart'; +// import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart'; import 'package:syncrow_web/pages/device_managment/shared/sensors_widgets/presence_space_type.dart'; import 'package:syncrow_web/pages/device_managment/shared/sensors_widgets/presence_update_data.dart'; import 'package:syncrow_web/pages/device_managment/shared/sensors_widgets/presense_nobody_time.dart'; @@ -110,7 +110,7 @@ class CeilingSensorBatchControlView extends StatelessWidget with HelperResponsiv ), ), ), - FirmwareUpdateWidget(deviceId: devicesIds.first, version: 4), + // FirmwareUpdateWidget(deviceId: devicesIds.first, version: 4), FactoryResetWidget( callFactoryReset: () { context.read().add( diff --git a/lib/pages/device_managment/curtain/view/curtain_batch_status_view.dart b/lib/pages/device_managment/curtain/view/curtain_batch_status_view.dart index b558c837..7c873e20 100644 --- a/lib/pages/device_managment/curtain/view/curtain_batch_status_view.dart +++ b/lib/pages/device_managment/curtain/view/curtain_batch_status_view.dart @@ -6,11 +6,10 @@ import 'package:syncrow_web/pages/device_managment/curtain/bloc/curtain_bloc.dar import 'package:syncrow_web/pages/device_managment/curtain/bloc/curtain_event.dart'; import 'package:syncrow_web/pages/device_managment/curtain/bloc/curtain_state.dart'; import 'package:syncrow_web/pages/device_managment/shared/batch_control/factory_reset.dart'; -import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart'; +// import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart'; import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart'; -class CurtainBatchStatusView extends StatelessWidget - with HelperResponsiveLayout { +class CurtainBatchStatusView extends StatelessWidget with HelperResponsiveLayout { const CurtainBatchStatusView({super.key, required this.devicesIds}); final List devicesIds; @@ -18,8 +17,8 @@ class CurtainBatchStatusView extends StatelessWidget @override Widget build(BuildContext context) { return BlocProvider( - create: (context) => CurtainBloc(deviceId: devicesIds.first) - ..add(CurtainFetchBatchStatus(devicesIds)), + create: (context) => + CurtainBloc(deviceId: devicesIds.first)..add(CurtainFetchBatchStatus(devicesIds)), child: BlocBuilder( builder: (context, state) { if (state is CurtainStatusLoading) { @@ -68,7 +67,7 @@ class CurtainBatchStatusView extends StatelessWidget )); }, ), - FirmwareUpdateWidget(deviceId: devicesIds.first, version: 5), + // FirmwareUpdateWidget(deviceId: devicesIds.first, version: 5), FactoryResetWidget( callFactoryReset: () { context.read().add( diff --git a/lib/pages/device_managment/door_lock/view/door_lock_batch_control_view.dart b/lib/pages/device_managment/door_lock/view/door_lock_batch_control_view.dart index abbd48dd..b28737fc 100644 --- a/lib/pages/device_managment/door_lock/view/door_lock_batch_control_view.dart +++ b/lib/pages/device_managment/door_lock/view/door_lock_batch_control_view.dart @@ -4,11 +4,10 @@ import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_re import 'package:syncrow_web/pages/device_managment/door_lock/bloc/door_lock_bloc.dart'; import 'package:syncrow_web/pages/device_managment/door_lock/bloc/door_lock_event.dart'; import 'package:syncrow_web/pages/device_managment/shared/batch_control/factory_reset.dart'; -import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart'; +// import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart'; import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart'; -class DoorLockBatchControlView extends StatelessWidget - with HelperResponsiveLayout { +class DoorLockBatchControlView extends StatelessWidget with HelperResponsiveLayout { const DoorLockBatchControlView({super.key, required this.devicesIds}); final List devicesIds; @@ -18,17 +17,17 @@ class DoorLockBatchControlView extends StatelessWidget return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - SizedBox( - width: 170, - height: 140, - child: FirmwareUpdateWidget( - deviceId: devicesIds.first, - version: 12, - ), - ), - const SizedBox( - width: 12, - ), + // SizedBox( + // width: 170, + // height: 140, + // child: FirmwareUpdateWidget( + // deviceId: devicesIds.first, + // version: 12, + // ), + // ), + // const SizedBox( + // width: 12, + // ), SizedBox( width: 170, height: 140, diff --git a/lib/pages/device_managment/garage_door/view/garage_door_batch_control_view.dart b/lib/pages/device_managment/garage_door/view/garage_door_batch_control_view.dart index 8c8b60cf..9b3159bb 100644 --- a/lib/pages/device_managment/garage_door/view/garage_door_batch_control_view.dart +++ b/lib/pages/device_managment/garage_door/view/garage_door_batch_control_view.dart @@ -6,17 +6,15 @@ import 'package:syncrow_web/pages/device_managment/garage_door/bloc/garage_door_ import 'package:syncrow_web/pages/device_managment/garage_door/bloc/garage_door_state.dart'; import 'package:syncrow_web/pages/device_managment/garage_door/models/garage_door_model.dart'; import 'package:syncrow_web/pages/device_managment/shared/batch_control/factory_reset.dart'; -import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart'; +// import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart'; import 'package:syncrow_web/pages/device_managment/shared/toggle_widget.dart'; import 'package:syncrow_web/utils/constants/assets.dart'; import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart'; -class GarageDoorBatchControlView extends StatelessWidget - with HelperResponsiveLayout { +class GarageDoorBatchControlView extends StatelessWidget with HelperResponsiveLayout { final List deviceIds; - const GarageDoorBatchControlView({Key? key, required this.deviceIds}) - : super(key: key); + const GarageDoorBatchControlView({Key? key, required this.deviceIds}) : super(key: key); @override Widget build(BuildContext context) { @@ -39,8 +37,7 @@ class GarageDoorBatchControlView extends StatelessWidget ); } - Widget _buildStatusControls( - BuildContext context, GarageDoorStatusModel status) { + Widget _buildStatusControls(BuildContext context, GarageDoorStatusModel status) { final isExtraLarge = isExtraLargeScreenSize(context); final isLarge = isLargeScreenSize(context); final isMedium = isMediumScreenSize(context); @@ -75,10 +72,10 @@ class GarageDoorBatchControlView extends StatelessWidget ); }, ), - FirmwareUpdateWidget( - deviceId: deviceIds.first, - version: 12, - ), + // FirmwareUpdateWidget( + // deviceId: deviceIds.first, + // version: 12, + // ), FactoryResetWidget( callFactoryReset: () { context.read().add( diff --git a/lib/pages/device_managment/gateway/view/gateway_batch_control.dart b/lib/pages/device_managment/gateway/view/gateway_batch_control.dart index cb85b7d9..f3a08a18 100644 --- a/lib/pages/device_managment/gateway/view/gateway_batch_control.dart +++ b/lib/pages/device_managment/gateway/view/gateway_batch_control.dart @@ -3,11 +3,10 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_reset_model.dart'; import 'package:syncrow_web/pages/device_managment/gateway/bloc/gate_way_bloc.dart'; import 'package:syncrow_web/pages/device_managment/shared/batch_control/factory_reset.dart'; -import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart'; +// import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart'; import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart'; -class GatewayBatchControlView extends StatelessWidget - with HelperResponsiveLayout { +class GatewayBatchControlView extends StatelessWidget with HelperResponsiveLayout { const GatewayBatchControlView({super.key, required this.gatewayIds}); final List gatewayIds; @@ -24,14 +23,13 @@ class GatewayBatchControlView extends StatelessWidget return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - SizedBox( - width: 170, - height: 140, - child: FirmwareUpdateWidget( - deviceId: gatewayIds.first, version: 2)), - const SizedBox( - width: 12, - ), + // SizedBox( + // width: 170, + // height: 140, + // child: FirmwareUpdateWidget(deviceId: gatewayIds.first, version: 2)), + // const SizedBox( + // width: 12, + // ), SizedBox( width: 170, height: 140, @@ -40,8 +38,7 @@ class GatewayBatchControlView extends StatelessWidget context.read().add( GateWayFactoryReset( deviceId: gatewayIds.first, - factoryReset: - FactoryResetModel(devicesUuid: gatewayIds), + factoryReset: FactoryResetModel(devicesUuid: gatewayIds), ), ); }, diff --git a/lib/pages/device_managment/main_door_sensor/view/main_door_sensor_batch_view.dart b/lib/pages/device_managment/main_door_sensor/view/main_door_sensor_batch_view.dart index 0cacc0be..7337c9fd 100644 --- a/lib/pages/device_managment/main_door_sensor/view/main_door_sensor_batch_view.dart +++ b/lib/pages/device_managment/main_door_sensor/view/main_door_sensor_batch_view.dart @@ -4,7 +4,7 @@ import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_re import 'package:syncrow_web/pages/device_managment/main_door_sensor/bloc/main_door_sensor_bloc.dart'; import 'package:syncrow_web/pages/device_managment/main_door_sensor/bloc/main_door_sensor_event.dart'; import 'package:syncrow_web/pages/device_managment/shared/batch_control/factory_reset.dart'; -import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart'; +// import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart'; class MainDoorSensorBatchView extends StatelessWidget { const MainDoorSensorBatchView({super.key, required this.devicesIds}); @@ -16,17 +16,17 @@ class MainDoorSensorBatchView extends StatelessWidget { return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - SizedBox( - width: 170, - height: 140, - child: FirmwareUpdateWidget( - deviceId: devicesIds.first, - version: 12, - ), - ), - const SizedBox( - width: 12, - ), + // SizedBox( + // width: 170, + // height: 140, + // child: FirmwareUpdateWidget( + // deviceId: devicesIds.first, + // version: 12, + // ), + // ), + // const SizedBox( + // width: 12, + // ), SizedBox( width: 170, height: 140, diff --git a/lib/pages/device_managment/one_g_glass_switch/view/one_gang_glass_batch_control_view.dart b/lib/pages/device_managment/one_g_glass_switch/view/one_gang_glass_batch_control_view.dart index 4239b08e..9b89e876 100644 --- a/lib/pages/device_managment/one_g_glass_switch/view/one_gang_glass_batch_control_view.dart +++ b/lib/pages/device_managment/one_g_glass_switch/view/one_gang_glass_batch_control_view.dart @@ -4,16 +4,14 @@ import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_re import 'package:syncrow_web/pages/device_managment/one_g_glass_switch/bloc/one_gang_glass_switch_bloc.dart'; import 'package:syncrow_web/pages/device_managment/one_g_glass_switch/models/once_gang_glass_status_model.dart'; import 'package:syncrow_web/pages/device_managment/shared/batch_control/factory_reset.dart'; -import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart'; +// import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart'; import 'package:syncrow_web/pages/device_managment/shared/toggle_widget.dart'; import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart'; -class OneGangGlassSwitchBatchControlView extends StatelessWidget - with HelperResponsiveLayout { +class OneGangGlassSwitchBatchControlView extends StatelessWidget with HelperResponsiveLayout { final List deviceIds; - const OneGangGlassSwitchBatchControlView( - {required this.deviceIds, super.key}); + const OneGangGlassSwitchBatchControlView({required this.deviceIds, super.key}); @override Widget build(BuildContext context) { @@ -36,8 +34,7 @@ class OneGangGlassSwitchBatchControlView extends StatelessWidget ); } - Widget _buildStatusControls( - BuildContext context, OneGangGlassStatusModel status) { + Widget _buildStatusControls(BuildContext context, OneGangGlassStatusModel status) { final isExtraLarge = isExtraLargeScreenSize(context); final isLarge = isLargeScreenSize(context); final isMedium = isMediumScreenSize(context); @@ -71,10 +68,10 @@ class OneGangGlassSwitchBatchControlView extends StatelessWidget ); }, ), - FirmwareUpdateWidget( - deviceId: deviceIds.first, - version: 12, - ), + // FirmwareUpdateWidget( + // deviceId: deviceIds.first, + // version: 12, + // ), FactoryResetWidget( callFactoryReset: () { context.read().add( diff --git a/lib/pages/device_managment/one_gang_switch/view/wall_light_batch_control.dart b/lib/pages/device_managment/one_gang_switch/view/wall_light_batch_control.dart index e1dabb61..7094b506 100644 --- a/lib/pages/device_managment/one_gang_switch/view/wall_light_batch_control.dart +++ b/lib/pages/device_managment/one_gang_switch/view/wall_light_batch_control.dart @@ -6,12 +6,11 @@ import 'package:syncrow_web/pages/device_managment/one_gang_switch/bloc/wall_lig import 'package:syncrow_web/pages/device_managment/one_gang_switch/bloc/wall_light_switch_state.dart'; import 'package:syncrow_web/pages/device_managment/one_gang_switch/models/wall_light_status_model.dart'; import 'package:syncrow_web/pages/device_managment/shared/batch_control/factory_reset.dart'; -import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart'; +// import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart'; import 'package:syncrow_web/pages/device_managment/shared/toggle_widget.dart'; import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart'; -class WallLightBatchControlView extends StatelessWidget - with HelperResponsiveLayout { +class WallLightBatchControlView extends StatelessWidget with HelperResponsiveLayout { const WallLightBatchControlView({super.key, required this.deviceIds}); final List deviceIds; @@ -27,8 +26,7 @@ class WallLightBatchControlView extends StatelessWidget return const Center(child: CircularProgressIndicator()); } else if (state is WallLightSwitchStatusLoaded) { return _buildStatusControls(context, state.status); - } else if (state is WallLightSwitchError || - state is WallLightSwitchControlError) { + } else if (state is WallLightSwitchError || state is WallLightSwitchControlError) { return const Center(child: Text('Error fetching status')); } else { return const Center(child: CircularProgressIndicator()); @@ -38,8 +36,7 @@ class WallLightBatchControlView extends StatelessWidget ); } - Widget _buildStatusControls( - BuildContext context, WallLightStatusModel status) { + Widget _buildStatusControls(BuildContext context, WallLightStatusModel status) { final isExtraLarge = isExtraLargeScreenSize(context); final isLarge = isLargeScreenSize(context); final isMedium = isMediumScreenSize(context); @@ -74,15 +71,14 @@ class WallLightBatchControlView extends StatelessWidget ); }, ), - FirmwareUpdateWidget( - deviceId: deviceIds.first, - version: 12, - ), + // FirmwareUpdateWidget( + // deviceId: deviceIds.first, + // version: 12, + // ), FactoryResetWidget( callFactoryReset: () { context.read().add(WallLightFactoryReset( - deviceId: status.uuid, - factoryReset: FactoryResetModel(devicesUuid: deviceIds))); + deviceId: status.uuid, factoryReset: FactoryResetModel(devicesUuid: deviceIds))); }, ), ], diff --git a/lib/pages/device_managment/power_clamp/view/power_clamp_batch_control_view.dart b/lib/pages/device_managment/power_clamp/view/power_clamp_batch_control_view.dart index c0244845..7f6a4b64 100644 --- a/lib/pages/device_managment/power_clamp/view/power_clamp_batch_control_view.dart +++ b/lib/pages/device_managment/power_clamp/view/power_clamp_batch_control_view.dart @@ -6,21 +6,19 @@ import 'package:syncrow_web/pages/device_managment/power_clamp/bloc/smart_power_ import 'package:syncrow_web/pages/device_managment/power_clamp/bloc/smart_power_state.dart'; import 'package:syncrow_web/pages/device_managment/power_clamp/models/power_clamp_batch_model.dart'; import 'package:syncrow_web/pages/device_managment/shared/batch_control/factory_reset.dart'; -import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart'; +// import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart'; import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart'; -class PowerClampBatchControlView extends StatelessWidget - with HelperResponsiveLayout { +class PowerClampBatchControlView extends StatelessWidget with HelperResponsiveLayout { final List deviceIds; - const PowerClampBatchControlView({Key? key, required this.deviceIds}) - : super(key: key); + const PowerClampBatchControlView({Key? key, required this.deviceIds}) : super(key: key); @override Widget build(BuildContext context) { return BlocProvider( - create: (context) => SmartPowerBloc(deviceId: deviceIds.first) - ..add(SmartPowerFetchBatchEvent(deviceIds)), + create: (context) => + SmartPowerBloc(deviceId: deviceIds.first)..add(SmartPowerFetchBatchEvent(deviceIds)), child: BlocBuilder( builder: (context, state) { if (state is SmartPowerLoading) { @@ -37,18 +35,17 @@ class PowerClampBatchControlView extends StatelessWidget ); } - Widget _buildStatusControls( - BuildContext context, PowerClampBatchModel status) { + Widget _buildStatusControls(BuildContext context, PowerClampBatchModel status) { return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - SizedBox( - width: 170, - // height: 140, - child: FirmwareUpdateWidget(deviceId: deviceIds.first, version: 2)), - const SizedBox( - width: 12, - ), + // SizedBox( + // width: 170, + // // height: 140, + // child: FirmwareUpdateWidget(deviceId: deviceIds.first, version: 2)), + // const SizedBox( + // width: 12, + // ), SizedBox( width: 170, height: 140, diff --git a/lib/pages/device_managment/shared/batch_control/firmware_update.dart b/lib/pages/device_managment/shared/batch_control/firmware_update.dart index e99ee948..8270fa36 100644 --- a/lib/pages/device_managment/shared/batch_control/firmware_update.dart +++ b/lib/pages/device_managment/shared/batch_control/firmware_update.dart @@ -1,128 +1,128 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_svg/flutter_svg.dart'; -import 'package:syncrow_web/pages/common/buttons/default_button.dart'; -import 'package:syncrow_web/pages/device_managment/shared/device_controls_container.dart'; -import 'package:syncrow_web/utils/color_manager.dart'; -import 'package:syncrow_web/utils/constants/assets.dart'; -import 'package:syncrow_web/utils/extension/build_context_x.dart'; +// import 'package:flutter/material.dart'; +// import 'package:flutter_svg/flutter_svg.dart'; +// import 'package:syncrow_web/pages/common/buttons/default_button.dart'; +// import 'package:syncrow_web/pages/device_managment/shared/device_controls_container.dart'; +// import 'package:syncrow_web/utils/color_manager.dart'; +// import 'package:syncrow_web/utils/constants/assets.dart'; +// import 'package:syncrow_web/utils/extension/build_context_x.dart'; -class FirmwareUpdateWidget extends StatefulWidget { - const FirmwareUpdateWidget({super.key, required this.deviceId, required this.version}); +// class FirmwareUpdateWidget extends StatefulWidget { +// const FirmwareUpdateWidget({super.key, required this.deviceId, required this.version}); - final String deviceId; - final int version; +// final String deviceId; +// final int version; - @override - State createState() => _FirmwareUpdateWidgetState(); -} +// @override +// State createState() => _FirmwareUpdateWidgetState(); +// } -class _FirmwareUpdateWidgetState extends State { - bool _showConfirmation = false; +// class _FirmwareUpdateWidgetState extends State { +// bool _showConfirmation = false; - void _toggleConfirmation() { - setState(() { - _showConfirmation = !_showConfirmation; - }); - } +// void _toggleConfirmation() { +// setState(() { +// _showConfirmation = !_showConfirmation; +// }); +// } - @override - Widget build(BuildContext context) { - return DeviceControlsContainer( - child: _showConfirmation - ? Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Column( - children: [ - Text( - 'Firmware Update', - style: context.textTheme.titleMedium!.copyWith( - fontWeight: FontWeight.bold, - color: ColorsManager.blackColor, - ), - ), - Text( - 'Are you sure?', - style: context.textTheme.bodySmall!.copyWith( - color: ColorsManager.grayColor, - ), - ), - ], - ), - Row( - children: [ - Flexible( - child: DefaultButton( - height: 20, - elevation: 0, - padding: 0, - onPressed: _toggleConfirmation, - backgroundColor: ColorsManager.greyColor, - child: Text( - 'Cancel', - style: context.textTheme.bodyMedium!.copyWith( - color: ColorsManager.blackColor, - fontWeight: FontWeight.w400, - fontSize: 12, - ), - ), - ), - ), - const SizedBox(width: 8), - Flexible( - child: DefaultButton( - height: 20, - elevation: 0, - padding: 0, - onPressed: () { - _toggleConfirmation(); - }, - backgroundColor: ColorsManager.primaryColor, - child: Text( - 'Update', - style: context.textTheme.bodyMedium!.copyWith( - color: ColorsManager.whiteColors, - fontWeight: FontWeight.w400, - fontSize: 12, - ), - ), - ), - ), - ], - ), - ], - ) - : GestureDetector( - onTap: _toggleConfirmation, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - ClipOval( - child: Container( - color: ColorsManager.whiteColors, - height: 60, - width: 60, - child: Padding( - padding: const EdgeInsets.all(12.0), - child: SvgPicture.asset( - Assets.firmware, - fit: BoxFit.cover, - ), - ), - ), - ), - Text( - 'Firmware Update', - style: context.textTheme.titleMedium!.copyWith( - fontWeight: FontWeight.w400, - color: ColorsManager.blackColor, - ), - ), - ], - ), - ), - ); - } -} +// @override +// Widget build(BuildContext context) { +// return DeviceControlsContainer( +// child: _showConfirmation +// ? Column( +// crossAxisAlignment: CrossAxisAlignment.start, +// mainAxisAlignment: MainAxisAlignment.spaceBetween, +// children: [ +// Column( +// children: [ +// Text( +// 'Firmware Update', +// style: context.textTheme.titleMedium!.copyWith( +// fontWeight: FontWeight.bold, +// color: ColorsManager.blackColor, +// ), +// ), +// Text( +// 'Are you sure?', +// style: context.textTheme.bodySmall!.copyWith( +// color: ColorsManager.grayColor, +// ), +// ), +// ], +// ), +// Row( +// children: [ +// Flexible( +// child: DefaultButton( +// height: 20, +// elevation: 0, +// padding: 0, +// onPressed: _toggleConfirmation, +// backgroundColor: ColorsManager.greyColor, +// child: Text( +// 'Cancel', +// style: context.textTheme.bodyMedium!.copyWith( +// color: ColorsManager.blackColor, +// fontWeight: FontWeight.w400, +// fontSize: 12, +// ), +// ), +// ), +// ), +// const SizedBox(width: 8), +// Flexible( +// child: DefaultButton( +// height: 20, +// elevation: 0, +// padding: 0, +// onPressed: () { +// _toggleConfirmation(); +// }, +// backgroundColor: ColorsManager.primaryColor, +// child: Text( +// 'Update', +// style: context.textTheme.bodyMedium!.copyWith( +// color: ColorsManager.whiteColors, +// fontWeight: FontWeight.w400, +// fontSize: 12, +// ), +// ), +// ), +// ), +// ], +// ), +// ], +// ) +// : GestureDetector( +// onTap: _toggleConfirmation, +// child: Column( +// crossAxisAlignment: CrossAxisAlignment.start, +// mainAxisAlignment: MainAxisAlignment.spaceBetween, +// children: [ +// ClipOval( +// child: Container( +// color: ColorsManager.whiteColors, +// height: 60, +// width: 60, +// child: Padding( +// padding: const EdgeInsets.all(12.0), +// child: SvgPicture.asset( +// Assets.firmware, +// fit: BoxFit.cover, +// ), +// ), +// ), +// ), +// Text( +// 'Firmware Update', +// style: context.textTheme.titleMedium!.copyWith( +// fontWeight: FontWeight.w400, +// color: ColorsManager.blackColor, +// ), +// ), +// ], +// ), +// ), +// ); +// } +// } diff --git a/lib/pages/device_managment/sos/view/sos_batch_control_view.dart b/lib/pages/device_managment/sos/view/sos_batch_control_view.dart index ec15b7d6..bc66d69f 100644 --- a/lib/pages/device_managment/sos/view/sos_batch_control_view.dart +++ b/lib/pages/device_managment/sos/view/sos_batch_control_view.dart @@ -18,20 +18,21 @@ class SOSBatchControlView extends StatelessWidget { return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - SizedBox( - width: 170, - // height: 140, - child: FirmwareUpdateWidget(deviceId: deviceIds.first, version: 2)), - const SizedBox( - width: 12, - ), + // SizedBox( + // width: 170, + // // height: 140, + // child: FirmwareUpdateWidget(deviceId: deviceIds.first, version: 2)), + // const SizedBox( + // width: 12, + // ), SizedBox( width: 170, height: 140, child: FactoryResetWidget( callFactoryReset: () { - context.read().add( - SosFactoryReset(deviceId: deviceIds.first, factoryReset: FactoryResetModel(devicesUuid: deviceIds))); + context.read().add(SosFactoryReset( + deviceId: deviceIds.first, + factoryReset: FactoryResetModel(devicesUuid: deviceIds))); }, ), ), diff --git a/lib/pages/device_managment/three_g_glass_switch/view/three_gang_glass_switch_batch_control_view.dart b/lib/pages/device_managment/three_g_glass_switch/view/three_gang_glass_switch_batch_control_view.dart index 4d1bb91c..071d6ca0 100644 --- a/lib/pages/device_managment/three_g_glass_switch/view/three_gang_glass_switch_batch_control_view.dart +++ b/lib/pages/device_managment/three_g_glass_switch/view/three_gang_glass_switch_batch_control_view.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_reset_model.dart'; import 'package:syncrow_web/pages/device_managment/shared/batch_control/factory_reset.dart'; -import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart'; +// import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart'; import 'package:syncrow_web/pages/device_managment/shared/toggle_widget.dart'; import 'package:syncrow_web/pages/device_managment/three_g_glass_switch/bloc/three_gang_glass_switch_bloc.dart'; import 'package:syncrow_web/pages/device_managment/three_g_glass_switch/models/three_gang_glass_switch.dart'; @@ -98,10 +98,10 @@ class ThreeGangGlassSwitchBatchControlView extends StatelessWidget with HelperRe ); }, ), - FirmwareUpdateWidget( - deviceId: deviceIds.first, - version: 12, // adjust the version according to your requirement - ), + // FirmwareUpdateWidget( + // deviceId: deviceIds.first, + // version: 12, // adjust the version according to your requirement + // ), FactoryResetWidget( callFactoryReset: () { context.read().add( diff --git a/lib/pages/device_managment/three_gang_switch/view/living_room_batch_controls.dart b/lib/pages/device_managment/three_gang_switch/view/living_room_batch_controls.dart index 0d82c515..97c25287 100644 --- a/lib/pages/device_managment/three_gang_switch/view/living_room_batch_controls.dart +++ b/lib/pages/device_managment/three_gang_switch/view/living_room_batch_controls.dart @@ -2,14 +2,13 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_reset_model.dart'; import 'package:syncrow_web/pages/device_managment/shared/batch_control/factory_reset.dart'; -import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart'; +// import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart'; import 'package:syncrow_web/pages/device_managment/three_gang_switch/bloc/living_room_bloc.dart'; import 'package:syncrow_web/pages/device_managment/three_gang_switch/models/living_room_model.dart'; import 'package:syncrow_web/pages/device_managment/shared/toggle_widget.dart'; import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart'; -class LivingRoomBatchControlsView extends StatelessWidget - with HelperResponsiveLayout { +class LivingRoomBatchControlsView extends StatelessWidget with HelperResponsiveLayout { const LivingRoomBatchControlsView({super.key, required this.deviceIds}); final List deviceIds; @@ -17,16 +16,15 @@ class LivingRoomBatchControlsView extends StatelessWidget @override Widget build(BuildContext context) { return BlocProvider( - create: (context) => LivingRoomBloc(deviceId: deviceIds.first) - ..add(LivingRoomFetchBatchEvent(deviceIds)), + create: (context) => + LivingRoomBloc(deviceId: deviceIds.first)..add(LivingRoomFetchBatchEvent(deviceIds)), child: BlocBuilder( builder: (context, state) { if (state is LivingRoomDeviceStatusLoading) { return const Center(child: CircularProgressIndicator()); } else if (state is LivingRoomDeviceStatusLoaded) { return _buildStatusControls(context, state.status); - } else if (state is LivingRoomDeviceManagementError || - state is LivingRoomControlError) { + } else if (state is LivingRoomDeviceManagementError || state is LivingRoomControlError) { return const Center(child: Text('Error fetching status')); } else { return const Center(child: CircularProgressIndicator()); @@ -36,8 +34,7 @@ class LivingRoomBatchControlsView extends StatelessWidget ); } - Widget _buildStatusControls( - BuildContext context, LivingRoomStatusModel status) { + Widget _buildStatusControls(BuildContext context, LivingRoomStatusModel status) { final isExtraLarge = isExtraLargeScreenSize(context); final isLarge = isLargeScreenSize(context); final isMedium = isMediumScreenSize(context); @@ -102,10 +99,10 @@ class LivingRoomBatchControlsView extends StatelessWidget ); }, ), - FirmwareUpdateWidget( - deviceId: deviceIds.first, - version: 12, - ), + // FirmwareUpdateWidget( + // deviceId: deviceIds.first, + // version: 12, + // ), FactoryResetWidget(callFactoryReset: () { context.read().add( LivingRoomFactoryResetEvent( diff --git a/lib/pages/device_managment/two_g_glass_switch/view/two_gang_glass_switch_batch_control_view.dart b/lib/pages/device_managment/two_g_glass_switch/view/two_gang_glass_switch_batch_control_view.dart index d0288ca3..c84c1d07 100644 --- a/lib/pages/device_managment/two_g_glass_switch/view/two_gang_glass_switch_batch_control_view.dart +++ b/lib/pages/device_managment/two_g_glass_switch/view/two_gang_glass_switch_batch_control_view.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_reset_model.dart'; import 'package:syncrow_web/pages/device_managment/shared/batch_control/factory_reset.dart'; -import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart'; +// import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart'; import 'package:syncrow_web/pages/device_managment/shared/toggle_widget.dart'; import 'package:syncrow_web/pages/device_managment/two_g_glass_switch/bloc/two_gang_glass_switch_bloc.dart'; import 'package:syncrow_web/pages/device_managment/two_g_glass_switch/models/two_gang_glass_status_model.dart'; @@ -16,8 +16,8 @@ class TwoGangGlassSwitchBatchControlView extends StatelessWidget with HelperResp @override Widget build(BuildContext context) { return BlocProvider( - create: (context) => - TwoGangGlassSwitchBloc(deviceId: deviceIds.first)..add(TwoGangGlassSwitchFetchBatchStatusEvent(deviceIds)), + create: (context) => TwoGangGlassSwitchBloc(deviceId: deviceIds.first) + ..add(TwoGangGlassSwitchFetchBatchStatusEvent(deviceIds)), child: BlocBuilder( builder: (context, state) { if (state is TwoGangGlassSwitchLoading) { @@ -83,10 +83,10 @@ class TwoGangGlassSwitchBatchControlView extends StatelessWidget with HelperResp ); }, ), - FirmwareUpdateWidget( - deviceId: deviceIds.first, - version: 12, // adjust the version according to your requirement - ), + // FirmwareUpdateWidget( + // deviceId: deviceIds.first, + // version: 12, // adjust the version according to your requirement + // ), FactoryResetWidget( callFactoryReset: () { context.read().add( diff --git a/lib/pages/device_managment/two_gang_switch/view/wall_light_batch_control.dart b/lib/pages/device_managment/two_gang_switch/view/wall_light_batch_control.dart index 52900155..b3a39287 100644 --- a/lib/pages/device_managment/two_gang_switch/view/wall_light_batch_control.dart +++ b/lib/pages/device_managment/two_gang_switch/view/wall_light_batch_control.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_reset_model.dart'; import 'package:syncrow_web/pages/device_managment/shared/batch_control/factory_reset.dart'; -import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart'; +// import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart'; import 'package:syncrow_web/pages/device_managment/shared/toggle_widget.dart'; import 'package:syncrow_web/pages/device_managment/two_gang_switch/bloc/two_gang_switch_bloc.dart'; import 'package:syncrow_web/pages/device_managment/two_gang_switch/bloc/two_gang_switch_event.dart'; @@ -10,8 +10,7 @@ import 'package:syncrow_web/pages/device_managment/two_gang_switch/bloc/two_gang import 'package:syncrow_web/pages/device_managment/two_gang_switch/models/two_gang_status_model.dart'; import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart'; -class TwoGangBatchControlView extends StatelessWidget - with HelperResponsiveLayout { +class TwoGangBatchControlView extends StatelessWidget with HelperResponsiveLayout { const TwoGangBatchControlView({super.key, required this.deviceIds}); final List deviceIds; @@ -27,8 +26,7 @@ class TwoGangBatchControlView extends StatelessWidget return const Center(child: CircularProgressIndicator()); } else if (state is TwoGangSwitchStatusLoaded) { return _buildStatusControls(context, state.status); - } else if (state is TwoGangSwitchError || - state is TwoGangSwitchControlError) { + } else if (state is TwoGangSwitchError || state is TwoGangSwitchControlError) { return const Center(child: Text('Error fetching status')); } else { return const Center(child: CircularProgressIndicator()); @@ -84,10 +82,10 @@ class TwoGangBatchControlView extends StatelessWidget )); }, ), - FirmwareUpdateWidget( - deviceId: deviceIds.first, - version: 12, - ), + // FirmwareUpdateWidget( + // deviceId: deviceIds.first, + // version: 12, + // ), FactoryResetWidget(callFactoryReset: () { context.read().add( TwoGangFactoryReset( diff --git a/lib/pages/device_managment/wall_sensor/view/wall_sensor_batch_control.dart b/lib/pages/device_managment/wall_sensor/view/wall_sensor_batch_control.dart index 66ff67aa..27169f0e 100644 --- a/lib/pages/device_managment/wall_sensor/view/wall_sensor_batch_control.dart +++ b/lib/pages/device_managment/wall_sensor/view/wall_sensor_batch_control.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_reset_model.dart'; import 'package:syncrow_web/pages/device_managment/shared/batch_control/factory_reset.dart'; -import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart'; +// import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart'; import 'package:syncrow_web/pages/device_managment/shared/sensors_widgets/presence_update_data.dart'; import 'package:syncrow_web/pages/device_managment/wall_sensor/bloc/wall_bloc.dart'; import 'package:syncrow_web/pages/device_managment/wall_sensor/bloc/wall_event.dart'; @@ -113,7 +113,7 @@ class WallSensorBatchControlView extends StatelessWidget with HelperResponsiveLa ), ), ), - FirmwareUpdateWidget(deviceId: devicesIds.first, version: 2), + // FirmwareUpdateWidget(deviceId: devicesIds.first, version: 2), FactoryResetWidget( callFactoryReset: () { context.read().add( diff --git a/lib/pages/device_managment/water_heater/view/water_heater_batch_control.dart b/lib/pages/device_managment/water_heater/view/water_heater_batch_control.dart index cc62adfd..aaab5271 100644 --- a/lib/pages/device_managment/water_heater/view/water_heater_batch_control.dart +++ b/lib/pages/device_managment/water_heater/view/water_heater_batch_control.dart @@ -2,15 +2,14 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:syncrow_web/pages/device_managment/shared/batch_control/factory_reset.dart'; -import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart'; +// import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart'; import 'package:syncrow_web/pages/device_managment/shared/toggle_widget.dart'; import 'package:syncrow_web/pages/device_managment/water_heater/bloc/water_heater_bloc.dart'; import 'package:syncrow_web/pages/device_managment/water_heater/models/water_heater_status_model.dart'; import 'package:syncrow_web/utils/constants/assets.dart'; import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart'; -class WaterHEaterBatchControlView extends StatelessWidget - with HelperResponsiveLayout { +class WaterHEaterBatchControlView extends StatelessWidget with HelperResponsiveLayout { const WaterHEaterBatchControlView({super.key, required this.deviceIds}); final List deviceIds; @@ -18,8 +17,8 @@ class WaterHEaterBatchControlView extends StatelessWidget @override Widget build(BuildContext context) { return BlocProvider( - create: (context) => WaterHeaterBloc() - ..add(FetchWaterHeaterBatchStatusEvent(devicesUuid: deviceIds)), + create: (context) => + WaterHeaterBloc()..add(FetchWaterHeaterBatchStatusEvent(devicesUuid: deviceIds)), child: BlocBuilder( builder: (context, state) { if (state is WaterHeaterLoadingState) { @@ -36,8 +35,7 @@ class WaterHEaterBatchControlView extends StatelessWidget ); } - Widget _buildStatusControls( - BuildContext context, WaterHeaterStatusModel status) { + Widget _buildStatusControls(BuildContext context, WaterHeaterStatusModel status) { final isExtraLarge = isExtraLargeScreenSize(context); final isLarge = isLargeScreenSize(context); final isMedium = isMediumScreenSize(context); @@ -73,10 +71,10 @@ class WaterHEaterBatchControlView extends StatelessWidget ); }, ), - FirmwareUpdateWidget( - deviceId: deviceIds.first, - version: 12, - ), + // FirmwareUpdateWidget( + // deviceId: deviceIds.first, + // version: 12, + // ), FactoryResetWidget( callFactoryReset: () {}, ), diff --git a/lib/pages/device_managment/water_leak/view/water_leak_batch_control_view.dart b/lib/pages/device_managment/water_leak/view/water_leak_batch_control_view.dart index 9d2c030f..1eb795e5 100644 --- a/lib/pages/device_managment/water_leak/view/water_leak_batch_control_view.dart +++ b/lib/pages/device_managment/water_leak/view/water_leak_batch_control_view.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_reset_model.dart'; import 'package:syncrow_web/pages/device_managment/shared/batch_control/factory_reset.dart'; -import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart'; +// import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart'; import 'package:syncrow_web/pages/device_managment/water_leak/bloc/water_leak_bloc.dart'; import 'package:syncrow_web/pages/device_managment/water_leak/bloc/water_leak_event.dart'; @@ -10,18 +10,16 @@ import 'package:syncrow_web/pages/device_managment/water_leak/bloc/water_leak_st import 'package:syncrow_web/pages/device_managment/water_leak/model/water_leak_status_model.dart'; import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart'; -class WaterLeakBatchControlView extends StatelessWidget - with HelperResponsiveLayout { +class WaterLeakBatchControlView extends StatelessWidget with HelperResponsiveLayout { final List deviceIds; - const WaterLeakBatchControlView({Key? key, required this.deviceIds}) - : super(key: key); + const WaterLeakBatchControlView({Key? key, required this.deviceIds}) : super(key: key); @override Widget build(BuildContext context) { return BlocProvider( - create: (context) => WaterLeakBloc(deviceIds.first) - ..add(FetchWaterLeakBatchStatusEvent(deviceIds)), + create: (context) => + WaterLeakBloc(deviceIds.first)..add(FetchWaterLeakBatchStatusEvent(deviceIds)), child: BlocBuilder( builder: (context, state) { if (state is WaterLeakLoadingState) { @@ -38,18 +36,17 @@ class WaterLeakBatchControlView extends StatelessWidget ); } - Widget _buildStatusControls( - BuildContext context, WaterLeakStatusModel status) { + Widget _buildStatusControls(BuildContext context, WaterLeakStatusModel status) { return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - SizedBox( - width: 170, - height: 140, - child: FirmwareUpdateWidget(deviceId: deviceIds.first, version: 2)), - const SizedBox( - width: 12, - ), + // SizedBox( + // width: 170, + // height: 140, + // child: FirmwareUpdateWidget(deviceId: deviceIds.first, version: 2)), + // const SizedBox( + // width: 12, + // ), SizedBox( width: 170, height: 140, diff --git a/lib/pages/home/bloc/home_bloc.dart b/lib/pages/home/bloc/home_bloc.dart index c837e40a..1772ef88 100644 --- a/lib/pages/home/bloc/home_bloc.dart +++ b/lib/pages/home/bloc/home_bloc.dart @@ -90,40 +90,40 @@ class HomeBloc extends Bloc { }, color: ColorsManager.primaryColor, ), - HomeItemModel( - title: 'Move in', - icon: Assets.moveinIcon, - active: false, - onPress: (context) {}, - color: ColorsManager.primaryColor, - ), - HomeItemModel( - title: 'Construction', - icon: Assets.constructionIcon, - active: false, - onPress: (context) {}, - color: ColorsManager.primaryColor, - ), - HomeItemModel( - title: 'Energy', - icon: Assets.energyIcon, - active: false, - onPress: (context) {}, - color: ColorsManager.slidingBlueColor.withOpacity(0.2), - ), - HomeItemModel( - title: 'Integrations', - icon: Assets.integrationsIcon, - active: false, - onPress: (context) {}, - color: ColorsManager.slidingBlueColor.withOpacity(0.2), - ), - HomeItemModel( - title: 'Asset', - icon: Assets.assetIcon, - active: false, - onPress: (context) {}, - color: ColorsManager.slidingBlueColor.withOpacity(0.2), - ), + // HomeItemModel( + // title: 'Move in', + // icon: Assets.moveinIcon, + // active: false, + // onPress: (context) {}, + // color: ColorsManager.primaryColor, + // ), + // HomeItemModel( + // title: 'Construction', + // icon: Assets.constructionIcon, + // active: false, + // onPress: (context) {}, + // color: ColorsManager.primaryColor, + // ), + // HomeItemModel( + // title: 'Energy', + // icon: Assets.energyIcon, + // active: false, + // onPress: (context) {}, + // color: ColorsManager.slidingBlueColor.withOpacity(0.2), + // ), + // HomeItemModel( + // title: 'Integrations', + // icon: Assets.integrationsIcon, + // active: false, + // onPress: (context) {}, + // color: ColorsManager.slidingBlueColor.withOpacity(0.2), + // ), + // HomeItemModel( + // title: 'Asset', + // icon: Assets.assetIcon, + // active: false, + // onPress: (context) {}, + // color: ColorsManager.slidingBlueColor.withOpacity(0.2), + // ), ]; } diff --git a/lib/pages/home/view/home_page_web.dart b/lib/pages/home/view/home_page_web.dart index cb806dfc..a198fa76 100644 --- a/lib/pages/home/view/home_page_web.dart +++ b/lib/pages/home/view/home_page_web.dart @@ -51,7 +51,7 @@ class HomeWebPage extends StatelessWidget { height: size.height * 0.6, width: size.width * 0.68, child: GridView.builder( - itemCount: 8, + itemCount: 3, //8 gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 4, crossAxisSpacing: 20.0, diff --git a/lib/utils/user_drop_down_menu.dart b/lib/utils/user_drop_down_menu.dart index 3a0c4194..cee9bbe9 100644 --- a/lib/utils/user_drop_down_menu.dart +++ b/lib/utils/user_drop_down_menu.dart @@ -75,26 +75,26 @@ class _UserDropdownMenuState extends State { ), ), items: [ - PopupMenuItem( - onTap: () {}, - child: ListTile( - leading: SvgPicture.asset(Assets.accountSetting), - title: Text( - "Account Settings", - style: context.textTheme.bodyMedium, - ), - ), - ), - PopupMenuItem( - onTap: () {}, - child: ListTile( - leading: SvgPicture.asset(Assets.settings), - title: Text( - "Settings", - style: context.textTheme.bodyMedium, - ), - ), - ), + // PopupMenuItem( + // onTap: () {}, + // child: ListTile( + // leading: SvgPicture.asset(Assets.accountSetting), + // title: Text( + // "Account Settings", + // style: context.textTheme.bodyMedium, + // ), + // ), + // ), + // PopupMenuItem( + // onTap: () {}, + // child: ListTile( + // leading: SvgPicture.asset(Assets.settings), + // title: Text( + // "Settings", + // style: context.textTheme.bodyMedium, + // ), + // ), + // ), PopupMenuItem( onTap: () { showDialog( @@ -211,8 +211,10 @@ class _UserDropdownMenuState extends State { elevation: 1, child: Text( 'Logout', - style: - Theme.of(context).textTheme.bodyMedium!.copyWith(fontSize: 12, color: Colors.white), + style: Theme.of(context) + .textTheme + .bodyMedium! + .copyWith(fontSize: 12, color: Colors.white), ), ), ), From c160220fcabfda0a1f05c741f2e318434723f2b3 Mon Sep 17 00:00:00 2001 From: Abdullah Alassaf Date: Mon, 23 Dec 2024 00:52:05 +0300 Subject: [PATCH 18/18] Hide region field --- lib/pages/auth/bloc/auth_bloc.dart | 14 ++-- lib/pages/auth/bloc/auth_event.dart | 14 ++-- .../auth/model/login_with_email_model.dart | 8 +- .../auth/view/forget_password_web_page.dart | 30 +++---- lib/pages/auth/view/login_mobile_page.dart | 84 ++++++++++--------- lib/pages/auth/view/login_web_page.dart | 16 ++-- lib/services/auth_api.dart | 6 +- 7 files changed, 86 insertions(+), 86 deletions(-) diff --git a/lib/pages/auth/bloc/auth_bloc.dart b/lib/pages/auth/bloc/auth_bloc.dart index 95ecb0ad..b931d90d 100644 --- a/lib/pages/auth/bloc/auth_bloc.dart +++ b/lib/pages/auth/bloc/auth_bloc.dart @@ -52,7 +52,8 @@ class AuthBloc extends Bloc { try { forgetEmailValidate = ''; _remainingTime = (await AuthenticationAPI.sendOtp( - email: forgetEmailController.text, regionUuid: regionUuid))!; + email: forgetEmailController.text, + ))!; } on DioException catch (e) { if (e.response!.statusCode == 400) { final errorData = e.response!.data; @@ -139,7 +140,7 @@ class AuthBloc extends Bloc { String validate = ''; String forgetValidate = ''; String forgetEmailValidate = ''; - String regionUuid = ''; + // String regionUuid = ''; static Token token = Token.emptyConstructor(); static UserModel? user; bool showValidationMessage = false; @@ -156,7 +157,9 @@ class AuthBloc extends Bloc { token = await AuthenticationAPI.loginWithEmail( model: LoginWithEmailModel( - email: event.username, password: event.password, regionUuid: event.regionUuid), + email: event.username, + password: event.password, + ), ); } catch (failure) { validate = 'Invalid Credentials!'; @@ -364,7 +367,7 @@ class AuthBloc extends Bloc { Future selectRegion(SelectRegionEvent event, Emitter emit) async { try { emit(AuthLoading()); - regionUuid = event.val; + // regionUuid = event.val; add(CheckEnableEvent()); emit(AuthInitialState()); } catch (e) { @@ -397,8 +400,7 @@ class AuthBloc extends Bloc { emit(AuthLoading()); checkValidate = isChecked == true && loginPasswordController.text.isNotEmpty && - loginEmailController.text.isNotEmpty && - regionUuid != ''; + loginEmailController.text.isNotEmpty; emit(LoginInitial()); return checkValidate; } diff --git a/lib/pages/auth/bloc/auth_event.dart b/lib/pages/auth/bloc/auth_event.dart index fa7e86b3..2b6a4eef 100644 --- a/lib/pages/auth/bloc/auth_event.dart +++ b/lib/pages/auth/bloc/auth_event.dart @@ -10,16 +10,16 @@ abstract class AuthEvent extends Equatable { class LoginButtonPressed extends AuthEvent { final String username; final String password; - final String regionUuid; + // final String regionUuid; const LoginButtonPressed({ required this.username, required this.password, - required this.regionUuid, + // required this.regionUuid, }); @override - List get props => [username, password, regionUuid]; + List get props => [username, password]; } class CheckBoxEvent extends AuthEvent { @@ -49,13 +49,9 @@ class UpdateTimerEvent extends AuthEvent { const UpdateTimerEvent({required this.remainingTime, required this.isButtonEnabled}); } -class ChangePasswordEvent extends AuthEvent { +class ChangePasswordEvent extends AuthEvent {} -} - -class SendOtpEvent extends AuthEvent { - -} +class SendOtpEvent extends AuthEvent {} class PasswordVisibleEvent extends AuthEvent { final bool? newValue; diff --git a/lib/pages/auth/model/login_with_email_model.dart b/lib/pages/auth/model/login_with_email_model.dart index 88be9808..ec3d4d98 100644 --- a/lib/pages/auth/model/login_with_email_model.dart +++ b/lib/pages/auth/model/login_with_email_model.dart @@ -1,19 +1,19 @@ class LoginWithEmailModel { final String email; final String password; - final String regionUuid; + // final String regionUuid; LoginWithEmailModel({ required this.email, required this.password, - required this.regionUuid, + // required this.regionUuid, }); factory LoginWithEmailModel.fromJson(Map json) { return LoginWithEmailModel( email: json['email'], password: json['password'], - regionUuid: json['regionUuid'], + // regionUuid: json['regionUuid'], ); } @@ -21,7 +21,7 @@ class LoginWithEmailModel { return { 'email': email, 'password': password, - 'regionUuid': regionUuid, + // 'regionUuid': regionUuid, }; } } diff --git a/lib/pages/auth/view/forget_password_web_page.dart b/lib/pages/auth/view/forget_password_web_page.dart index c04e7ee0..f389f44f 100644 --- a/lib/pages/auth/view/forget_password_web_page.dart +++ b/lib/pages/auth/view/forget_password_web_page.dart @@ -124,18 +124,18 @@ class ForgetPasswordWebPage extends StatelessWidget { .copyWith(fontSize: 14, fontWeight: FontWeight.w400), ), const SizedBox(height: 10), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - const SizedBox(height: 10), - Form( - key: forgetBloc.forgetRegionKey, - child: SizedBox( - child: - _buildDropdownField(context, forgetBloc, size))) - ], - ), + // Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // mainAxisAlignment: MainAxisAlignment.start, + // children: [ + // const SizedBox(height: 10), + // Form( + // key: forgetBloc.forgetRegionKey, + // child: SizedBox( + // child: + // _buildDropdownField(context, forgetBloc, size))) + // ], + // ), const SizedBox(height: 20), Form( key: forgetBloc.forgetEmailKey, @@ -459,9 +459,9 @@ class ForgetPasswordWebPage extends StatelessWidget { ), ); }).toList(), - value: loginBloc.regionList!.any((region) => region.id == loginBloc.regionUuid) - ? loginBloc.regionUuid - : null, + // value: loginBloc.regionList!.any((region) => region.id == loginBloc.regionUuid) + // ? loginBloc.regionUuid + // : null, onChanged: (String? value) { if (value != null) { loginBloc.add(SelectRegionEvent(val: value)); diff --git a/lib/pages/auth/view/login_mobile_page.dart b/lib/pages/auth/view/login_mobile_page.dart index 1a5c8358..4f001bc6 100644 --- a/lib/pages/auth/view/login_mobile_page.dart +++ b/lib/pages/auth/view/login_mobile_page.dart @@ -6,7 +6,7 @@ import 'package:go_router/go_router.dart'; import 'package:syncrow_web/pages/auth/bloc/auth_bloc.dart'; import 'package:syncrow_web/pages/auth/bloc/auth_event.dart'; import 'package:syncrow_web/pages/auth/bloc/auth_state.dart'; -import 'package:syncrow_web/pages/auth/model/region_model.dart'; +// import 'package:syncrow_web/pages/auth/model/region_model.dart'; import 'package:syncrow_web/pages/auth/view/forget_password_page.dart'; import 'package:syncrow_web/pages/common/buttons/default_button.dart'; import 'package:syncrow_web/utils/color_manager.dart'; @@ -112,44 +112,44 @@ class LoginMobilePage extends StatelessWidget { color: Colors.white, fontSize: 24, fontWeight: FontWeight.bold), ), const SizedBox(height: 30), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Text( - "Country/Region", - style: Theme.of(context).textTheme.bodySmall, - ), - SizedBox( - child: DropdownButtonFormField( - validator: loginBloc.validateRegion, - icon: const Icon( - Icons.keyboard_arrow_down_outlined, - ), - decoration: textBoxDecoration()!.copyWith( - hintText: null, - ), - hint: const Align( - alignment: Alignment.centerLeft, - child: Text( - 'Select your region/country', - textAlign: TextAlign.center, - ), - ), - isDense: true, - style: const TextStyle(color: Colors.black), - items: loginBloc.regionList!.map((RegionModel region) { - return DropdownMenuItem( - value: region.name, - child: Text(region.name), - ); - }).toList(), - onChanged: (String? value) {}, - ), - ) - ], - ), - const SizedBox(height: 20.0), + // Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // mainAxisAlignment: MainAxisAlignment.start, + // children: [ + // Text( + // "Country/Region", + // style: Theme.of(context).textTheme.bodySmall, + // ), + // SizedBox( + // child: DropdownButtonFormField( + // validator: loginBloc.validateRegion, + // icon: const Icon( + // Icons.keyboard_arrow_down_outlined, + // ), + // decoration: textBoxDecoration()!.copyWith( + // hintText: null, + // ), + // hint: const Align( + // alignment: Alignment.centerLeft, + // child: Text( + // 'Select your region/country', + // textAlign: TextAlign.center, + // ), + // ), + // isDense: true, + // style: const TextStyle(color: Colors.black), + // items: loginBloc.regionList!.map((RegionModel region) { + // return DropdownMenuItem( + // value: region.name, + // child: Text(region.name), + // ); + // }).toList(), + // onChanged: (String? value) {}, + // ), + // ) + // ], + // ), + // const SizedBox(height: 20.0), Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, @@ -207,7 +207,10 @@ class LoginMobilePage extends StatelessWidget { }, child: Text( "Forgot Password?", - style: Theme.of(context).textTheme.bodySmall, + style: Theme.of(context) + .textTheme + .bodySmall! + .copyWith(color: ColorsManager.blackColor), ), ), ], @@ -276,7 +279,6 @@ class LoginMobilePage extends StatelessWidget { if (loginBloc.loginFormKey.currentState!.validate()) { loginBloc.add( LoginButtonPressed( - regionUuid: '', username: loginBloc.loginEmailController.text, password: loginBloc.loginPasswordController.text, ), diff --git a/lib/pages/auth/view/login_web_page.dart b/lib/pages/auth/view/login_web_page.dart index 303dac76..72cad7cc 100644 --- a/lib/pages/auth/view/login_web_page.dart +++ b/lib/pages/auth/view/login_web_page.dart @@ -155,8 +155,8 @@ class _LoginWebPageState extends State with HelperResponsiveLayout children: [ const SizedBox(height: 40), Text('Login', style: Theme.of(context).textTheme.headlineLarge), - SizedBox(height: size.height * 0.03), - _buildDropdownField(context, loginBloc, size), + // SizedBox(height: size.height * 0.03), + // _buildDropdownField(context, loginBloc, size), const SizedBox(height: 20.0), _buildEmailField(context, loginBloc), const SizedBox(height: 20.0), @@ -219,11 +219,11 @@ class _LoginWebPageState extends State with HelperResponsiveLayout ), ); }).toList(), - value: loginBloc.regionList!.any( - (region) => region.id == loginBloc.regionUuid, - ) - ? loginBloc.regionUuid - : null, + // value: loginBloc.regionList!.any( + // (region) => region.id == loginBloc.regionUuid, + // ) + // ? loginBloc.regionUuid + // : null, onChanged: (String? value) { if (value != null) { loginBloc.add(CheckEnableEvent()); @@ -462,7 +462,7 @@ class _LoginWebPageState extends State with HelperResponsiveLayout onPressed: () { if (loginBloc.loginFormKey.currentState!.validate()) { loginBloc.add(LoginButtonPressed( - regionUuid: loginBloc.regionUuid, + // regionUuid: loginBloc.regionUuid, username: loginBloc.loginEmailController.text, password: loginBloc.loginPasswordController.text, )); diff --git a/lib/services/auth_api.dart b/lib/services/auth_api.dart index 2b158cdb..190eb624 100644 --- a/lib/services/auth_api.dart +++ b/lib/services/auth_api.dart @@ -22,16 +22,16 @@ class AuthenticationAPI { }) async { final response = await HTTPService().post( path: ApiEndpoints.forgetPassword, - body: {"email": email, "password": password,"otpCode": otpCode}, + body: {"email": email, "password": password, "otpCode": otpCode}, showServerMessage: true, expectedResponseModel: (json) {}); return response; } - static Future sendOtp({required String email, required String regionUuid}) async { + static Future sendOtp({required String email}) async { final response = await HTTPService().post( path: ApiEndpoints.sendOtp, - body: {"email": email, "type": "PASSWORD", "regionUuid": regionUuid}, + body: {"email": email, "type": "PASSWORD"}, showServerMessage: true, expectedResponseModel: (json) { return json['data']['cooldown'];