mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-11-27 02:04:55 +00:00
Compare commits
25 Commits
device_mgm
...
aug_bug_fi
| Author | SHA1 | Date | |
|---|---|---|---|
| bf6df377f6 | |||
| 18605f52a0 | |||
| 5a291ce9f8 | |||
| 25b9457043 | |||
| 040e678b1e | |||
| 7a32ad7878 | |||
| ea256c4f51 | |||
| ece37fc3c1 | |||
| 0936ca8b95 | |||
| b7c6232bdd | |||
| cf80251f82 | |||
| 3a254bce4d | |||
| 439ce85117 | |||
| a100b5c40e | |||
| 6ba0a70289 | |||
| 8130acc392 | |||
| 2339417c8c | |||
| 3017a5d1f6 | |||
| 7bbae2d332 | |||
| 4cf9d4c2f2 | |||
| 418f5d5406 | |||
| 00bce2d0ab | |||
| ddcdd4891a | |||
| 3ff6937116 | |||
| 4a252b38a8 |
2
.env.development
Normal file
2
.env.development
Normal file
@ -0,0 +1,2 @@
|
||||
ENV_NAME=development
|
||||
BASE_URL=https://syncrow-dev.azurewebsites.net
|
||||
2
.env.production
Normal file
2
.env.production
Normal file
@ -0,0 +1,2 @@
|
||||
ENV_NAME=production
|
||||
BASE_URL=https://syncrow-staging.azurewebsites.net
|
||||
2
.env.staging
Normal file
2
.env.staging
Normal file
@ -0,0 +1,2 @@
|
||||
ENV_NAME=staging
|
||||
BASE_URL=https://syncrow-staging.azurewebsites.net
|
||||
60
.github/workflows/azure-static-web-apps-agreeable-wave-096d61a10.yml
vendored
Normal file
60
.github/workflows/azure-static-web-apps-agreeable-wave-096d61a10.yml
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
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"
|
||||
###### 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: "/build/web" # App source code path
|
||||
api_location: "" # Api source code path - optional
|
||||
output_location: "/build/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_ZEALOUS_MUSHROOM_0D31A3303 }}
|
||||
action: "close"
|
||||
61
.vscode/launch.json
vendored
Normal file
61
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
{
|
||||
"configurations": [
|
||||
|
||||
{
|
||||
|
||||
"name": "DEVELOPMENT",
|
||||
|
||||
"request": "launch",
|
||||
|
||||
"type": "dart",
|
||||
|
||||
"args": [
|
||||
|
||||
"--dart-define",
|
||||
|
||||
"FLAVOR=development"
|
||||
|
||||
],
|
||||
|
||||
"flutterMode": "debug"
|
||||
|
||||
},{
|
||||
|
||||
"name": "STAGING",
|
||||
|
||||
"request": "launch",
|
||||
|
||||
"type": "dart",
|
||||
|
||||
"args": [
|
||||
|
||||
"--dart-define",
|
||||
|
||||
"FLAVOR=staging"
|
||||
|
||||
],
|
||||
|
||||
"flutterMode": "debug"
|
||||
|
||||
},{
|
||||
|
||||
"name": "PRODUCTION",
|
||||
|
||||
"request": "launch",
|
||||
|
||||
"type": "dart",
|
||||
|
||||
"args": [
|
||||
|
||||
"--dart-define",
|
||||
|
||||
"FLAVOR=production"
|
||||
|
||||
],
|
||||
|
||||
"flutterMode": "debug"
|
||||
|
||||
},
|
||||
|
||||
]
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:syncrow_web/pages/auth/bloc/auth_bloc.dart';
|
||||
import 'package:syncrow_web/pages/home/bloc/home_bloc.dart';
|
||||
import 'package:syncrow_web/pages/visitor_password/bloc/visitor_password_bloc.dart';
|
||||
@ -11,8 +12,12 @@ import 'package:syncrow_web/utils/constants/routes_const.dart';
|
||||
import 'package:syncrow_web/utils/theme/theme.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
initialSetup();
|
||||
try {
|
||||
const environment = String.fromEnvironment('FLAVOR', defaultValue: 'development');
|
||||
await dotenv.load(fileName: '.env.$environment');
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
initialSetup();
|
||||
} catch (_) {}
|
||||
runApp(MyApp());
|
||||
}
|
||||
|
||||
|
||||
@ -107,26 +107,28 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
||||
Future<void> _filterData(FilterDataEvent event, Emitter<AccessState> emit) async {
|
||||
emit(AccessLoaded());
|
||||
try {
|
||||
// Convert search text to lower case for case-insensitive search
|
||||
final searchText = event.passwordName?.toLowerCase() ?? '';
|
||||
|
||||
filteredData = data.where((item) {
|
||||
bool matchesCriteria = true;
|
||||
|
||||
// Convert timestamp to DateTime and extract date component
|
||||
DateTime effectiveDate =
|
||||
DateTime.fromMillisecondsSinceEpoch(int.parse(item.effectiveTime.toString()) * 1000)
|
||||
.toUtc()
|
||||
.toLocal();
|
||||
DateTime.fromMillisecondsSinceEpoch(int.parse(item.effectiveTime.toString()) * 1000)
|
||||
.toUtc()
|
||||
.toLocal();
|
||||
DateTime invalidDate =
|
||||
DateTime.fromMillisecondsSinceEpoch(int.parse(item.invalidTime.toString()) * 1000)
|
||||
.toUtc()
|
||||
.toLocal();
|
||||
DateTime.fromMillisecondsSinceEpoch(int.parse(item.invalidTime.toString()) * 1000)
|
||||
.toUtc()
|
||||
.toLocal();
|
||||
DateTime effectiveDateOnly =
|
||||
DateTime(effectiveDate.year, effectiveDate.month, effectiveDate.day);
|
||||
DateTime(effectiveDate.year, effectiveDate.month, effectiveDate.day);
|
||||
DateTime invalidDateOnly = DateTime(invalidDate.year, invalidDate.month, invalidDate.day);
|
||||
|
||||
// Filter by password name
|
||||
if (event.passwordName != null && event.passwordName!.isNotEmpty) {
|
||||
final bool matchesName =
|
||||
item.passwordName != null && item.passwordName.contains(event.passwordName);
|
||||
// Filter by password name, making the search case-insensitive
|
||||
if (searchText.isNotEmpty) {
|
||||
final bool matchesName = item.passwordName.toString().toLowerCase().contains(searchText);
|
||||
if (!matchesName) {
|
||||
matchesCriteria = false;
|
||||
}
|
||||
@ -135,7 +137,7 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
||||
// Filter by start date only
|
||||
if (event.startTime != null && event.endTime == null) {
|
||||
DateTime startDateOnly =
|
||||
DateTime.fromMillisecondsSinceEpoch(event.startTime! * 1000).toUtc().toLocal();
|
||||
DateTime.fromMillisecondsSinceEpoch(event.startTime! * 1000).toUtc().toLocal();
|
||||
startDateOnly = DateTime(startDateOnly.year, startDateOnly.month, startDateOnly.day);
|
||||
if (effectiveDateOnly.isBefore(startDateOnly)) {
|
||||
matchesCriteria = false;
|
||||
@ -145,7 +147,7 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
||||
// Filter by end date only
|
||||
if (event.endTime != null && event.startTime == null) {
|
||||
DateTime endDateOnly =
|
||||
DateTime.fromMillisecondsSinceEpoch(event.endTime! * 1000).toUtc().toLocal();
|
||||
DateTime.fromMillisecondsSinceEpoch(event.endTime! * 1000).toUtc().toLocal();
|
||||
endDateOnly = DateTime(endDateOnly.year, endDateOnly.month, endDateOnly.day);
|
||||
if (invalidDateOnly.isAfter(endDateOnly)) {
|
||||
matchesCriteria = false;
|
||||
@ -155,9 +157,9 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
||||
// Filter by both start date and end date
|
||||
if (event.startTime != null && event.endTime != null) {
|
||||
DateTime startDateOnly =
|
||||
DateTime.fromMillisecondsSinceEpoch(event.startTime! * 1000).toUtc().toLocal();
|
||||
DateTime.fromMillisecondsSinceEpoch(event.startTime! * 1000).toUtc().toLocal();
|
||||
DateTime endDateOnly =
|
||||
DateTime.fromMillisecondsSinceEpoch(event.endTime! * 1000).toUtc().toLocal();
|
||||
DateTime.fromMillisecondsSinceEpoch(event.endTime! * 1000).toUtc().toLocal();
|
||||
startDateOnly = DateTime(startDateOnly.year, startDateOnly.month, startDateOnly.day);
|
||||
endDateOnly = DateTime(endDateOnly.year, endDateOnly.month, endDateOnly.day);
|
||||
if (effectiveDateOnly.isBefore(startDateOnly) || invalidDateOnly.isAfter(endDateOnly)) {
|
||||
@ -183,6 +185,8 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
resetSearch(ResetSearch event, Emitter<AccessState> emit) async {
|
||||
emit(AccessLoaded());
|
||||
startTime = 'Start Time';
|
||||
|
||||
@ -30,7 +30,7 @@ class PasswordModel {
|
||||
effectiveTime: json['effectiveTime'],
|
||||
passwordCreated: json['passwordCreated'],
|
||||
createdTime: json['createdTime'],
|
||||
passwordName: json['passwordName'] ?? 'No name', // New field
|
||||
passwordName: json['passwordName']??'No Name',
|
||||
passwordStatus: AccessStatusExtension.fromString(json['passwordStatus']),
|
||||
passwordType: AccessTypeExtension.fromString(json['passwordType']),
|
||||
deviceUuid: json['deviceUuid'],
|
||||
|
||||
@ -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(
|
||||
enableMenuSideba: false,
|
||||
@ -38,17 +37,23 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout {
|
||||
style: Theme.of(context).textTheme.headlineLarge,
|
||||
),
|
||||
),
|
||||
centerBody: Text(
|
||||
'Physical Access',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.headlineMedium!
|
||||
.copyWith(color: Colors.white),
|
||||
centerBody: Wrap(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: MediaQuery.of(context).size.width * 0.09),
|
||||
child: Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: Text(
|
||||
'Physical Access',
|
||||
style: Theme.of(context).textTheme.headlineMedium!.copyWith(color: Colors.white),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
rightBody: const NavigateHomeGridView(),
|
||||
scaffoldBody: BlocProvider(
|
||||
create: (BuildContext context) =>
|
||||
AccessBloc()..add(FetchTableData()),
|
||||
create: (BuildContext context) => AccessBloc()..add(FetchTableData()),
|
||||
child: BlocConsumer<AccessBloc, AccessState>(
|
||||
listener: (context, state) {},
|
||||
builder: (context, state) {
|
||||
@ -82,6 +87,8 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout {
|
||||
const SizedBox(height: 20),
|
||||
Expanded(
|
||||
child: DynamicTable(
|
||||
uuidIndex: 1,
|
||||
withSelectAll: true,
|
||||
isEmpty: filteredData.isEmpty,
|
||||
withCheckBox: false,
|
||||
size: MediaQuery.of(context).size,
|
||||
@ -97,7 +104,7 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout {
|
||||
],
|
||||
data: filteredData.map((item) {
|
||||
return [
|
||||
item.passwordName.toString(),
|
||||
item.passwordName,
|
||||
item.passwordType.value,
|
||||
('${accessBloc.timestampToDate(item.effectiveTime)} - ${accessBloc.timestampToDate(item.invalidTime)}'),
|
||||
item.deviceUuid.toString(),
|
||||
@ -113,8 +120,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,8 +146,7 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout {
|
||||
borderRadius: 8,
|
||||
child: Text(
|
||||
'+ Create Visitor Password ',
|
||||
style: context.textTheme.titleSmall!
|
||||
.copyWith(color: Colors.white, fontSize: 12),
|
||||
style: context.textTheme.titleSmall!.copyWith(color: Colors.white, fontSize: 12),
|
||||
)),
|
||||
),
|
||||
Container(
|
||||
@ -153,8 +158,7 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout {
|
||||
backgroundColor: ColorsManager.whiteColors,
|
||||
child: Text(
|
||||
'Admin Password',
|
||||
style: context.textTheme.titleSmall!
|
||||
.copyWith(color: Colors.black, fontSize: 12),
|
||||
style: context.textTheme.titleSmall!.copyWith(color: Colors.black, fontSize: 12),
|
||||
)),
|
||||
),
|
||||
],
|
||||
@ -171,15 +175,14 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout {
|
||||
width: 250,
|
||||
child: CustomWebTextField(
|
||||
controller: accessBloc.passwordName,
|
||||
height: 38,
|
||||
isRequired: true,
|
||||
height: 43,
|
||||
isRequired: false,
|
||||
textFieldName: 'Name',
|
||||
description: '',
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 15),
|
||||
SizedBox(
|
||||
height: 70,
|
||||
child: DateTimeWebWidget(
|
||||
icon: Assets.calendarIcon,
|
||||
isRequired: false,
|
||||
@ -199,8 +202,7 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout {
|
||||
SearchResetButtons(
|
||||
onSearch: () {
|
||||
accessBloc.add(FilterDataEvent(
|
||||
selectedTabIndex:
|
||||
BlocProvider.of<AccessBloc>(context).selectedIndex,
|
||||
selectedTabIndex: BlocProvider.of<AccessBloc>(context).selectedIndex,
|
||||
passwordName: accessBloc.passwordName.text.toLowerCase(),
|
||||
startTime: accessBloc.effectiveTimeTimeStamp,
|
||||
endTime: accessBloc.expirationTimeTimeStamp));
|
||||
@ -245,8 +247,7 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout {
|
||||
SearchResetButtons(
|
||||
onSearch: () {
|
||||
accessBloc.add(FilterDataEvent(
|
||||
selectedTabIndex:
|
||||
BlocProvider.of<AccessBloc>(context).selectedIndex,
|
||||
selectedTabIndex: BlocProvider.of<AccessBloc>(context).selectedIndex,
|
||||
passwordName: accessBloc.passwordName.text.toLowerCase(),
|
||||
startTime: accessBloc.effectiveTimeTimeStamp,
|
||||
endTime: accessBloc.expirationTimeTimeStamp));
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import 'dart:async';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
@ -81,21 +82,25 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
_timer?.cancel();
|
||||
emit(const TimerState(isButtonEnabled: true, remainingTime: 0));
|
||||
emit(SuccessForgetState());
|
||||
} else if (response == "You entered wrong otp") {
|
||||
forgetValidate = 'Wrong one time password.';
|
||||
emit(AuthInitialState());
|
||||
} else if (response == "OTP expired") {
|
||||
forgetValidate = 'One time password has been expired.';
|
||||
emit(AuthInitialState());
|
||||
}
|
||||
} catch (failure) {
|
||||
// forgetValidate='Invalid Credentials!';
|
||||
emit(AuthInitialState());
|
||||
// emit(FailureForgetState(error: failure.toString()));
|
||||
}
|
||||
on DioException catch (e) {
|
||||
final errorData = e.response!.data;
|
||||
String errorMessage = errorData['message'];
|
||||
if(errorMessage=='this email is not registered'){
|
||||
validate='Invalid Credentials!';
|
||||
emit(AuthInitialState());
|
||||
}else if (errorMessage == "You entered wrong otp") {
|
||||
forgetValidate = 'Wrong one time password.';
|
||||
emit(AuthInitialState());
|
||||
} else if (errorMessage == "OTP expired") {
|
||||
forgetValidate = 'One time password has been expired.';
|
||||
emit(AuthInitialState());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//925207
|
||||
String? validateCode(String? value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Code is required';
|
||||
@ -158,6 +163,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
user = UserModel.fromToken(token);
|
||||
loginEmailController.clear();
|
||||
loginPasswordController.clear();
|
||||
debugPrint("token " + token.accessToken);
|
||||
emit(LoginSuccess());
|
||||
} else {
|
||||
emit(const LoginFailure(error: 'Something went wrong'));
|
||||
@ -177,15 +183,15 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
emit(LoginInitial());
|
||||
}
|
||||
|
||||
checkOtpCode(
|
||||
ChangePasswordEvent event,
|
||||
Emitter<AuthState> emit,
|
||||
) async {
|
||||
emit(LoadingForgetState());
|
||||
await AuthenticationAPI.verifyOtp(
|
||||
email: forgetEmailController.text, otpCode: forgetOtp.text);
|
||||
emit(SuccessForgetState());
|
||||
}
|
||||
// checkOtpCode(
|
||||
// ChangePasswordEvent event,
|
||||
// Emitter<AuthState> emit,
|
||||
// ) async {
|
||||
// emit(LoadingForgetState());
|
||||
// await AuthenticationAPI.verifyOtp(
|
||||
// email: forgetEmailController.text, otpCode: forgetOtp.text);
|
||||
// emit(SuccessForgetState());
|
||||
// }
|
||||
|
||||
void _passwordVisible(PasswordVisibleEvent event, Emitter<AuthState> emit) {
|
||||
emit(AuthLoading());
|
||||
|
||||
@ -49,9 +49,13 @@ 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;
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import 'package:dropdown_button2/dropdown_button2.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
@ -148,44 +149,7 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
SizedBox(
|
||||
child: DropdownButtonFormField<String>(
|
||||
validator: forgetBloc.validateRegion,
|
||||
icon: const Icon(
|
||||
Icons.keyboard_arrow_down_outlined,
|
||||
),
|
||||
decoration:
|
||||
textBoxDecoration()!.copyWith(
|
||||
hintText: null,
|
||||
),
|
||||
hint: SizedBox(
|
||||
width: size.width * 0.12,
|
||||
child: const Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
'Select your region/country',
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
),
|
||||
isDense: true,
|
||||
style: const TextStyle(
|
||||
color: Colors.black),
|
||||
items: forgetBloc.regionList!
|
||||
.map((RegionModel region) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: region.id,
|
||||
child: SizedBox(
|
||||
width: size.width * 0.06,
|
||||
child: Text(region.name)),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (String? value) {
|
||||
forgetBloc.add(SelectRegionEvent(
|
||||
val: value!,
|
||||
));
|
||||
},
|
||||
),
|
||||
child: _buildDropdownField(context, forgetBloc, size)
|
||||
)
|
||||
],
|
||||
),
|
||||
@ -208,11 +172,12 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
||||
SizedBox(
|
||||
child: TextFormField(
|
||||
validator: forgetBloc.validateEmail,
|
||||
controller:
|
||||
forgetBloc.forgetEmailController,
|
||||
decoration: textBoxDecoration()!
|
||||
.copyWith(
|
||||
hintText: 'Enter your email'),
|
||||
hintText: 'Enter your email',
|
||||
hintStyle: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
color: ColorsManager.grayColor,
|
||||
fontWeight: FontWeight.w400)),
|
||||
style: const TextStyle(
|
||||
color: Colors.black),
|
||||
),
|
||||
@ -244,13 +209,15 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
||||
decoration:
|
||||
textBoxDecoration()!.copyWith(
|
||||
hintText: 'Enter Code',
|
||||
hintStyle: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
color: ColorsManager.grayColor,
|
||||
fontWeight: FontWeight.w400),
|
||||
suffixIcon: SizedBox(
|
||||
width: 100,
|
||||
child: Center(
|
||||
child: InkWell(
|
||||
onTap: state is TimerState &&
|
||||
!state
|
||||
.isButtonEnabled &&
|
||||
!state.isButtonEnabled &&
|
||||
state.remainingTime !=
|
||||
1
|
||||
? null
|
||||
@ -261,10 +228,8 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
||||
child: Text(
|
||||
'Get Code ${state is TimerState && !state.isButtonEnabled && state.remainingTime != 1 ? "(${forgetBloc.formattedTime(state.remainingTime)}) " : ""}',
|
||||
style: TextStyle(
|
||||
color: state
|
||||
is TimerState &&
|
||||
!state
|
||||
.isButtonEnabled
|
||||
color: state is TimerState &&
|
||||
!state.isButtonEnabled
|
||||
? Colors.grey
|
||||
: ColorsManager
|
||||
.btnColor,
|
||||
@ -278,8 +243,7 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
||||
color: Colors.black),
|
||||
),
|
||||
),
|
||||
if (forgetBloc.forgetValidate !=
|
||||
'') // Check if there is a validation message
|
||||
if (forgetBloc.forgetValidate != '') // Check if there is a validation message
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(top: 8.0),
|
||||
@ -311,18 +275,16 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
||||
const SizedBox(height: 10),
|
||||
SizedBox(
|
||||
child: TextFormField(
|
||||
validator:
|
||||
forgetBloc.passwordValidator,
|
||||
keyboardType:
|
||||
TextInputType.visiblePassword,
|
||||
controller: forgetBloc
|
||||
.forgetPasswordController,
|
||||
decoration:
|
||||
textBoxDecoration()!.copyWith(
|
||||
validator: forgetBloc.passwordValidator,
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
controller: forgetBloc.forgetPasswordController,
|
||||
decoration: textBoxDecoration()!.copyWith(
|
||||
hintText: 'At least 8 characters',
|
||||
hintStyle: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
color: ColorsManager.grayColor,
|
||||
fontWeight: FontWeight.w400),
|
||||
),
|
||||
style: const TextStyle(
|
||||
color: Colors.black),
|
||||
style: const TextStyle(color: Colors.black),
|
||||
),
|
||||
),
|
||||
],
|
||||
@ -346,8 +308,7 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
||||
if (forgetBloc
|
||||
.forgetFormKey.currentState!
|
||||
.validate()) {
|
||||
forgetBloc
|
||||
.add(ChangePasswordEvent());
|
||||
forgetBloc.add(ChangePasswordEvent());
|
||||
}
|
||||
},
|
||||
),
|
||||
@ -355,12 +316,14 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
SizedBox(
|
||||
child: Text(
|
||||
forgetBloc.validate,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
color: ColorsManager.red),
|
||||
Center(
|
||||
child: SizedBox(
|
||||
child: Text(
|
||||
forgetBloc.validate,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
color: ColorsManager.red),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
@ -410,4 +373,109 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
||||
),
|
||||
));
|
||||
}
|
||||
Widget _buildDropdownField(
|
||||
BuildContext context, AuthBloc loginBloc, Size size) {
|
||||
final TextEditingController textEditingController = TextEditingController();
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Country/Region",
|
||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Container(
|
||||
height: 50,
|
||||
decoration: const BoxDecoration(
|
||||
color: ColorsManager.boxColor,
|
||||
borderRadius: BorderRadius.all(Radius.circular(8)),
|
||||
),
|
||||
width: size.width * 0.9,
|
||||
child: DropdownButtonHideUnderline(
|
||||
child: DropdownButton2<String>(
|
||||
style: TextStyle(color: Colors.black),
|
||||
isExpanded: true,
|
||||
hint: Text(
|
||||
'Select your region/country',
|
||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
color: ColorsManager.grayColor,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
items: loginBloc.regionList!.map((RegionModel region) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: region.id, // Use region.id as the value
|
||||
child: Text(
|
||||
region.name,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
value: loginBloc.regionList!.any(
|
||||
(region) => region.id == loginBloc.regionUuid,)
|
||||
? loginBloc.regionUuid
|
||||
: null,
|
||||
onChanged: (String? value) {
|
||||
if (value != null) {
|
||||
|
||||
loginBloc.add(SelectRegionEvent(
|
||||
val: value,
|
||||
));
|
||||
}
|
||||
},
|
||||
buttonStyleData: const ButtonStyleData(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||
height: 40,
|
||||
width: double.infinity,
|
||||
),
|
||||
dropdownStyleData: DropdownStyleData(
|
||||
maxHeight: size.height * 0.70,
|
||||
),
|
||||
menuItemStyleData: const MenuItemStyleData(
|
||||
height: 40,
|
||||
),
|
||||
dropdownSearchData: DropdownSearchData(
|
||||
searchController: textEditingController,
|
||||
searchInnerWidgetHeight: 50,
|
||||
searchInnerWidget: Container(
|
||||
height: 50,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
child: TextFormField(
|
||||
style: const TextStyle(color: Colors.black),
|
||||
controller: textEditingController,
|
||||
decoration: textBoxDecoration()!.copyWith(
|
||||
errorStyle: const TextStyle(height: 0),
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
vertical: 12,
|
||||
horizontal: 10,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
searchMatchFn: (item, searchValue) {
|
||||
// Use the item's child text (region name) for searching.
|
||||
final regionName = (item.child as Text).data?.toLowerCase() ?? '';
|
||||
final search = searchValue.toLowerCase().trim();
|
||||
// Debugging print statement to ensure values are captured correctly.
|
||||
// Return true if the region name contains the search term.
|
||||
return regionName.contains(search);
|
||||
},
|
||||
),
|
||||
onMenuStateChange: (isOpen) {
|
||||
if (!isOpen) {
|
||||
textEditingController.clear();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import 'package:dropdown_button2/dropdown_button2.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
@ -23,7 +24,8 @@ class LoginWebPage extends StatefulWidget {
|
||||
State<LoginWebPage> createState() => _LoginWebPageState();
|
||||
}
|
||||
|
||||
class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout {
|
||||
class _LoginWebPageState extends State<LoginWebPage>
|
||||
with HelperResponsiveLayout {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@ -58,7 +60,8 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
|
||||
_scrollController = ScrollController();
|
||||
|
||||
void _scrollToCenter() {
|
||||
final double middlePosition = _scrollController.position.maxScrollExtent / 2;
|
||||
final double middlePosition =
|
||||
_scrollController.position.maxScrollExtent / 2;
|
||||
_scrollController.animateTo(
|
||||
middlePosition,
|
||||
duration: const Duration(seconds: 1),
|
||||
@ -120,7 +123,8 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
|
||||
const Spacer(),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: _buildLoginFormFields(context, loginBloc, size),
|
||||
child: _buildLoginFormFields(
|
||||
context, loginBloc, size),
|
||||
),
|
||||
const Spacer(),
|
||||
],
|
||||
@ -131,12 +135,14 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
|
||||
),
|
||||
),
|
||||
),
|
||||
if (state is AuthLoading) const Center(child: CircularProgressIndicator())
|
||||
if (state is AuthLoading)
|
||||
const Center(child: CircularProgressIndicator())
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLoginFormFields(BuildContext context, AuthBloc loginBloc, Size size) {
|
||||
Widget _buildLoginFormFields(
|
||||
BuildContext context, AuthBloc loginBloc, Size size) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withOpacity(0.1),
|
||||
@ -146,8 +152,8 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
|
||||
child: Form(
|
||||
key: loginBloc.loginFormKey,
|
||||
child: Padding(
|
||||
padding:
|
||||
EdgeInsets.symmetric(horizontal: size.width * 0.02, vertical: size.width * 0.003),
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: size.width * 0.02, vertical: size.width * 0.003),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@ -175,88 +181,112 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDropdownField(BuildContext context, AuthBloc loginBloc, Size size) {
|
||||
|
||||
Widget _buildDropdownField(
|
||||
BuildContext context, AuthBloc loginBloc, Size size) {
|
||||
final TextEditingController textEditingController = TextEditingController();
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Country/Region",
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodySmall!
|
||||
.copyWith(fontSize: 14, fontWeight: FontWeight.w400),
|
||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
SizedBox(
|
||||
width: size.width * 0.8,
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
return DropdownButtonFormField<String>(
|
||||
value: loginBloc.regionList!.any((region) => region.id == loginBloc.regionUuid)
|
||||
? loginBloc.regionUuid
|
||||
: null,
|
||||
validator: loginBloc.validateRegion,
|
||||
icon: const Icon(
|
||||
Icons.keyboard_arrow_down_outlined,
|
||||
size: 20,
|
||||
Container(
|
||||
height: 50,
|
||||
decoration: const BoxDecoration(
|
||||
color: ColorsManager.boxColor,
|
||||
borderRadius: BorderRadius.all(Radius.circular(8)),
|
||||
),
|
||||
width: size.width * 0.9,
|
||||
child: DropdownButtonHideUnderline(
|
||||
child: DropdownButton2<String>(
|
||||
style: TextStyle(color: Colors.black),
|
||||
isExpanded: true,
|
||||
hint: Text(
|
||||
'Select your region/country',
|
||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
color: ColorsManager.grayColor,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
decoration: textBoxDecoration()!.copyWith(
|
||||
errorStyle: const TextStyle(height: 0),
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
vertical: 12,
|
||||
horizontal: 10,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
items: loginBloc.regionList!.map((RegionModel region) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: region.id, // Use region.id as the value
|
||||
child: Text(
|
||||
region.name,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
),
|
||||
),
|
||||
hint: Text(
|
||||
'Select your region/country',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodySmall!
|
||||
.copyWith(color: ColorsManager.grayColor, fontWeight: FontWeight.w400),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
isDense: true,
|
||||
style: const TextStyle(color: Colors.black),
|
||||
items: loginBloc.regionList!.map((RegionModel region) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: region.id,
|
||||
child: Container(
|
||||
constraints: BoxConstraints(maxWidth: constraints.maxWidth - 40),
|
||||
child: Text(
|
||||
region.name,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
);
|
||||
}).toList(),
|
||||
value: loginBloc.regionList!.any(
|
||||
(region) => region.id == loginBloc.regionUuid,)
|
||||
? loginBloc.regionUuid
|
||||
: null,
|
||||
onChanged: (String? value) {
|
||||
if (value != null) {
|
||||
loginBloc.add(CheckEnableEvent());
|
||||
loginBloc.add(SelectRegionEvent(val: value));
|
||||
}
|
||||
},
|
||||
buttonStyleData: const ButtonStyleData(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||
height: 40,
|
||||
width: double.infinity,
|
||||
),
|
||||
dropdownStyleData: DropdownStyleData(
|
||||
maxHeight: size.height * 0.70,
|
||||
),
|
||||
menuItemStyleData: const MenuItemStyleData(
|
||||
height: 40,
|
||||
),
|
||||
dropdownSearchData: DropdownSearchData(
|
||||
searchController: textEditingController,
|
||||
searchInnerWidgetHeight: 50,
|
||||
searchInnerWidget: Container(
|
||||
height: 50,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
child: TextFormField(
|
||||
style: const TextStyle(color: Colors.black),
|
||||
controller: textEditingController,
|
||||
decoration: textBoxDecoration()!.copyWith(
|
||||
errorStyle: const TextStyle(height: 0),
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
vertical: 12,
|
||||
horizontal: 10,
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (String? value) {
|
||||
loginBloc.add(CheckEnableEvent());
|
||||
loginBloc.add(SelectRegionEvent(val: value!));
|
||||
),
|
||||
),
|
||||
searchMatchFn: (item, searchValue) {
|
||||
// Use the item's child text (region name) for searching.
|
||||
final regionName = (item.child as Text).data?.toLowerCase() ?? '';
|
||||
final search = searchValue.toLowerCase().trim();
|
||||
// Debugging print statement to ensure values are captured correctly.
|
||||
// Return true if the region name contains the search term.
|
||||
return regionName.contains(search);
|
||||
},
|
||||
dropdownColor: Colors.white,
|
||||
menuMaxHeight: size.height * 0.45,
|
||||
selectedItemBuilder: (context) {
|
||||
return loginBloc.regionList!.map<Widget>((region) {
|
||||
return Container(
|
||||
constraints: BoxConstraints(maxWidth: constraints.maxWidth - 40),
|
||||
child: Text(
|
||||
region.name,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
),
|
||||
);
|
||||
}).toList();
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
onMenuStateChange: (isOpen) {
|
||||
if (!isOpen) {
|
||||
textEditingController.clear();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Widget _buildEmailField(BuildContext context, AuthBloc loginBloc) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@ -280,10 +310,9 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
|
||||
decoration: textBoxDecoration()!.copyWith(
|
||||
errorStyle: const TextStyle(height: 0),
|
||||
hintText: 'Enter your email address',
|
||||
hintStyle: Theme.of(context)
|
||||
.textTheme
|
||||
.bodySmall!
|
||||
.copyWith(color: ColorsManager.grayColor, fontWeight: FontWeight.w400)),
|
||||
hintStyle: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
color: ColorsManager.grayColor,
|
||||
fontWeight: FontWeight.w400)),
|
||||
style: const TextStyle(color: Colors.black),
|
||||
),
|
||||
),
|
||||
@ -315,17 +344,18 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
|
||||
controller: loginBloc.loginPasswordController,
|
||||
decoration: textBoxDecoration()!.copyWith(
|
||||
hintText: 'At least 8 characters',
|
||||
hintStyle: Theme.of(context)
|
||||
.textTheme
|
||||
.bodySmall!
|
||||
.copyWith(color: ColorsManager.grayColor, fontWeight: FontWeight.w400),
|
||||
hintStyle: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
color: ColorsManager.grayColor, fontWeight: FontWeight.w400),
|
||||
suffixIcon: IconButton(
|
||||
onPressed: () {
|
||||
loginBloc.add(PasswordVisibleEvent(newValue: loginBloc.obscureText));
|
||||
loginBloc.add(
|
||||
PasswordVisibleEvent(newValue: loginBloc.obscureText));
|
||||
},
|
||||
icon: SizedBox(
|
||||
child: SvgPicture.asset(
|
||||
loginBloc.obscureText ? Assets.visiblePassword : Assets.invisiblePassword,
|
||||
loginBloc.obscureText
|
||||
? Assets.visiblePassword
|
||||
: Assets.invisiblePassword,
|
||||
height: 15,
|
||||
width: 15,
|
||||
),
|
||||
@ -353,10 +383,10 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
|
||||
},
|
||||
child: Text(
|
||||
"Forgot Password?",
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodySmall!
|
||||
.copyWith(color: Colors.black, fontSize: 14, fontWeight: FontWeight.w400),
|
||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
color: Colors.black,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400),
|
||||
),
|
||||
),
|
||||
],
|
||||
@ -419,7 +449,8 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSignInButton(BuildContext context, AuthBloc loginBloc, Size size) {
|
||||
Widget _buildSignInButton(
|
||||
BuildContext context, AuthBloc loginBloc, Size size) {
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
@ -460,7 +491,8 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
|
||||
SizedBox(
|
||||
child: Text(
|
||||
loginBloc.validate,
|
||||
style: const TextStyle(fontWeight: FontWeight.w700, color: ColorsManager.red),
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w700, color: ColorsManager.red),
|
||||
),
|
||||
)
|
||||
],
|
||||
|
||||
@ -5,27 +5,33 @@ import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
|
||||
class DynamicTable extends StatefulWidget {
|
||||
final List<String> headers;
|
||||
final String? tableName;
|
||||
final List<List<dynamic>> data;
|
||||
final BoxDecoration? headerDecoration;
|
||||
final BoxDecoration? cellDecoration;
|
||||
final Size size;
|
||||
final bool withCheckBox;
|
||||
final bool withSelectAll;
|
||||
final bool isEmpty;
|
||||
final void Function(bool?)? selectAll;
|
||||
final void Function(int, bool, dynamic)? onRowSelected;
|
||||
final List<String>? initialSelectedIds;
|
||||
final int uuidIndex;
|
||||
const DynamicTable({
|
||||
super.key,
|
||||
required this.headers,
|
||||
required this.data,
|
||||
required this.size,
|
||||
this.tableName,
|
||||
required this.isEmpty,
|
||||
required this.withCheckBox,
|
||||
required this.withSelectAll,
|
||||
this.headerDecoration,
|
||||
this.cellDecoration,
|
||||
this.selectAll,
|
||||
this.onRowSelected,
|
||||
this.initialSelectedIds,
|
||||
required this.uuidIndex,
|
||||
});
|
||||
|
||||
@override
|
||||
@ -34,13 +40,29 @@ class DynamicTable extends StatefulWidget {
|
||||
|
||||
class _DynamicTableState extends State<DynamicTable> {
|
||||
late List<bool> _selected;
|
||||
bool _selectAll = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_initializeSelection();
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(DynamicTable oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (oldWidget.data != widget.data) {
|
||||
_initializeSelection();
|
||||
}
|
||||
}
|
||||
|
||||
void _initializeSelection() {
|
||||
_selected = List<bool>.generate(widget.data.length, (index) {
|
||||
// Check if the initialSelectedIds contains the deviceUuid
|
||||
// uuidIndex is the index of the column containing the deviceUuid
|
||||
final deviceUuid = widget.data[index][widget.uuidIndex];
|
||||
return widget.initialSelectedIds != null &&
|
||||
widget.initialSelectedIds!.contains(widget.data[index][1]);
|
||||
widget.initialSelectedIds!.contains(deviceUuid);
|
||||
});
|
||||
}
|
||||
|
||||
@ -54,6 +76,17 @@ class _DynamicTableState extends State<DynamicTable> {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void _toggleSelectAll(bool? value) {
|
||||
setState(() {
|
||||
_selectAll = value ?? false;
|
||||
_selected = List<bool>.filled(widget.data.length, _selectAll);
|
||||
if (widget.selectAll != null) {
|
||||
widget.selectAll!(_selectAll);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
@ -71,8 +104,7 @@ class _DynamicTableState extends State<DynamicTable> {
|
||||
children: [
|
||||
if (widget.withCheckBox) _buildSelectAllCheckbox(),
|
||||
...widget.headers
|
||||
.map((header) => _buildTableHeaderCell(header))
|
||||
.toList(),
|
||||
.map((header) => _buildTableHeaderCell(header)),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -92,7 +124,8 @@ class _DynamicTableState extends State<DynamicTable> {
|
||||
height: 15,
|
||||
),
|
||||
Text(
|
||||
'No Devices',
|
||||
// no password
|
||||
widget.tableName=='AccessManagement'? 'No Password ' : 'No Devices',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodySmall!
|
||||
@ -119,11 +152,9 @@ class _DynamicTableState extends State<DynamicTable> {
|
||||
if (widget.withCheckBox)
|
||||
_buildRowCheckbox(
|
||||
index, widget.size.height * 0.10),
|
||||
...row
|
||||
.map((cell) => _buildTableCell(
|
||||
cell.toString(),
|
||||
widget.size.height * 0.10))
|
||||
.toList(),
|
||||
...row.map((cell) => _buildTableCell(
|
||||
cell.toString(),
|
||||
widget.size.height * 0.10)),
|
||||
],
|
||||
);
|
||||
},
|
||||
@ -148,7 +179,7 @@ class _DynamicTableState extends State<DynamicTable> {
|
||||
),
|
||||
child: Checkbox(
|
||||
value: _selected.every((element) => element == true),
|
||||
onChanged: null,
|
||||
onChanged:widget.withSelectAll?_toggleSelectAll:null,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -32,21 +32,19 @@ class CustomWebTextField extends StatelessWidget {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
if (isRequired)
|
||||
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
'* ',
|
||||
if (isRequired)
|
||||
Text('* ',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyMedium!
|
||||
.textTheme.bodyMedium!
|
||||
.copyWith(color: Colors.red),
|
||||
),
|
||||
Text(
|
||||
textFieldName,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodySmall!
|
||||
.textTheme.bodySmall!
|
||||
.copyWith(color: Colors.black, fontSize: 13),
|
||||
),
|
||||
],
|
||||
@ -70,15 +68,17 @@ class CustomWebTextField extends StatelessWidget {
|
||||
),
|
||||
Container(
|
||||
height: height ?? 35,
|
||||
decoration: containerDecoration
|
||||
.copyWith(color: const Color(0xFFF5F6F7), boxShadow: [
|
||||
decoration: containerDecoration.copyWith(
|
||||
color: const Color(0xFFF5F6F7),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.3),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 3,
|
||||
offset: const Offset(1, 1), // changes position of shadow
|
||||
),
|
||||
]),
|
||||
]
|
||||
),
|
||||
child: TextFormField(
|
||||
validator: validator,
|
||||
controller: controller,
|
||||
|
||||
@ -28,14 +28,16 @@ class DeviceManagementBloc
|
||||
emit(DeviceManagementLoading());
|
||||
try {
|
||||
final devices = await DevicesManagementApi().fetchDevices();
|
||||
_selectedDevices.clear();
|
||||
_devices = devices;
|
||||
_calculateDeviceCounts();
|
||||
emit(DeviceManagementLoaded(
|
||||
devices: devices,
|
||||
selectedIndex: _selectedIndex,
|
||||
selectedIndex: 0,
|
||||
onlineCount: _onlineCount,
|
||||
offlineCount: _offlineCount,
|
||||
lowBatteryCount: _lowBatteryCount,
|
||||
selectedDevice: null,
|
||||
));
|
||||
} catch (e) {
|
||||
emit(DeviceManagementInitial());
|
||||
@ -63,6 +65,8 @@ class DeviceManagementBloc
|
||||
onlineCount: _onlineCount,
|
||||
offlineCount: _offlineCount,
|
||||
lowBatteryCount: _lowBatteryCount,
|
||||
selectedDevice:
|
||||
_selectedDevices.isNotEmpty ? _selectedDevices.first : null,
|
||||
));
|
||||
}
|
||||
}
|
||||
@ -75,8 +79,10 @@ class DeviceManagementBloc
|
||||
|
||||
void _onSelectDevice(
|
||||
SelectDevice event, Emitter<DeviceManagementState> emit) {
|
||||
if (_selectedDevices.contains(event.selectedDevice)) {
|
||||
_selectedDevices.remove(event.selectedDevice);
|
||||
final selectedUuid = event.selectedDevice.uuid;
|
||||
|
||||
if (_selectedDevices.any((device) => device.uuid == selectedUuid)) {
|
||||
_selectedDevices.removeWhere((device) => device.uuid == selectedUuid);
|
||||
} else {
|
||||
_selectedDevices.add(event.selectedDevice);
|
||||
}
|
||||
@ -129,6 +135,9 @@ class DeviceManagementBloc
|
||||
void _onSearchDevices(
|
||||
SearchDevices event, Emitter<DeviceManagementState> emit) {
|
||||
if (_devices.isNotEmpty) {
|
||||
_selectedDevices.clear();
|
||||
_selectedIndex = 0;
|
||||
|
||||
final filteredDevices = _devices.where((device) {
|
||||
final matchesCommunity = event.community == null ||
|
||||
event.community!.isEmpty ||
|
||||
@ -150,7 +159,6 @@ class DeviceManagementBloc
|
||||
false);
|
||||
return matchesCommunity && matchesUnit && matchesProductName;
|
||||
}).toList();
|
||||
_selectedDevices = [];
|
||||
emit(DeviceManagementFiltered(
|
||||
filteredDevices: filteredDevices,
|
||||
selectedIndex: 0,
|
||||
|
||||
@ -42,6 +42,10 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
|
||||
offlineCount = state.offlineCount;
|
||||
lowBatteryCount = state.lowBatteryCount;
|
||||
isControlButtonEnabled = state.selectedDevice != null;
|
||||
} else if (state is DeviceManagementInitial) {
|
||||
devicesToShow = [];
|
||||
selectedIndex = 0;
|
||||
isControlButtonEnabled = false;
|
||||
}
|
||||
|
||||
final tabs = [
|
||||
@ -51,71 +55,68 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
|
||||
'Low Battery ($lowBatteryCount)',
|
||||
];
|
||||
|
||||
return CustomScrollView(
|
||||
slivers: [
|
||||
SliverToBoxAdapter(
|
||||
child: Container(
|
||||
padding: isLargeScreenSize(context)
|
||||
? const EdgeInsets.all(30)
|
||||
: const EdgeInsets.all(15),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
FilterWidget(
|
||||
size: MediaQuery.of(context).size,
|
||||
tabs: tabs,
|
||||
selectedIndex: selectedIndex,
|
||||
onTabChanged: (index) {
|
||||
context
|
||||
.read<DeviceManagementBloc>()
|
||||
.add(SelectedFilterChanged(index));
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
const DeviceSearchFilters(),
|
||||
const SizedBox(height: 12),
|
||||
Container(
|
||||
height: 45,
|
||||
width: 100,
|
||||
decoration: containerDecoration,
|
||||
child: Center(
|
||||
child: DefaultButton(
|
||||
onPressed: isControlButtonEnabled
|
||||
? () {
|
||||
final selectedDevice = context
|
||||
.read<DeviceManagementBloc>()
|
||||
.selectedDevices
|
||||
.first;
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => DeviceControlDialog(
|
||||
device: selectedDevice),
|
||||
);
|
||||
}
|
||||
: null,
|
||||
borderRadius: 9,
|
||||
child: Text(
|
||||
'Control',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: isControlButtonEnabled
|
||||
? Colors.white
|
||||
: Colors.grey,
|
||||
),
|
||||
return Column(
|
||||
children: [
|
||||
Container(
|
||||
padding: isLargeScreenSize(context)
|
||||
? const EdgeInsets.all(30)
|
||||
: const EdgeInsets.all(15),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
FilterWidget(
|
||||
size: MediaQuery.of(context).size,
|
||||
tabs: tabs,
|
||||
selectedIndex: selectedIndex,
|
||||
onTabChanged: (index) {
|
||||
context.read<DeviceManagementBloc>()
|
||||
.add(SelectedFilterChanged(index));
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
const DeviceSearchFilters(),
|
||||
const SizedBox(height: 12),
|
||||
Container(
|
||||
height: 45,
|
||||
width: 100,
|
||||
decoration: containerDecoration,
|
||||
child: Center(
|
||||
child: DefaultButton(
|
||||
onPressed: isControlButtonEnabled
|
||||
? () {
|
||||
final selectedDevice = context
|
||||
.read<DeviceManagementBloc>()
|
||||
.selectedDevices.first;
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => DeviceControlDialog(
|
||||
device: selectedDevice),
|
||||
);
|
||||
}
|
||||
: null,
|
||||
borderRadius: 9,
|
||||
child: Text(
|
||||
'Control',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: isControlButtonEnabled
|
||||
? Colors.white
|
||||
: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SliverFillRemaining(
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: isLargeScreenSize(context)
|
||||
? const EdgeInsets.all(30)
|
||||
: const EdgeInsets.all(15),
|
||||
child: DynamicTable(
|
||||
withSelectAll: false,
|
||||
cellDecoration: containerDecoration,
|
||||
onRowSelected: (index, isSelected, row) {
|
||||
final selectedDevice = devicesToShow[index];
|
||||
@ -125,6 +126,7 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
|
||||
},
|
||||
withCheckBox: true,
|
||||
size: context.screenSize,
|
||||
uuidIndex: 2,
|
||||
headers: const [
|
||||
'Device Name',
|
||||
'Product Name',
|
||||
@ -153,10 +155,15 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
|
||||
(device.updateTime ?? 0) * 1000)),
|
||||
];
|
||||
}).toList(),
|
||||
initialSelectedIds: context
|
||||
.read<DeviceManagementBloc>()
|
||||
.selectedDevices
|
||||
.map((device) => device.uuid!)
|
||||
.toList(),
|
||||
isEmpty: devicesToShow.isEmpty,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
|
||||
@ -62,16 +62,19 @@ class CeilingSensorBloc extends Bloc<CeilingSensorEvent, CeilingSensorState> {
|
||||
deviceStatus.noBodyTime = event.value;
|
||||
} else if (event.code == 'moving_max_dis') {
|
||||
deviceStatus.maxDistance = event.value;
|
||||
} else if (event.code == 'scene') {
|
||||
deviceStatus.spaceType = getSpaceType(event.value);
|
||||
}
|
||||
emit(CeilingUpdateState(ceilingSensorModel: deviceStatus));
|
||||
await _runDeBouncer(
|
||||
deviceId: deviceId, code: event.code, value: event.value);
|
||||
deviceId: deviceId, code: event.code, value: event.value, emit: emit);
|
||||
}
|
||||
|
||||
_runDeBouncer({
|
||||
required String deviceId,
|
||||
required String code,
|
||||
required dynamic value,
|
||||
required Emitter<CeilingSensorState> emit,
|
||||
}) {
|
||||
if (_timer != null) {
|
||||
_timer!.cancel();
|
||||
@ -84,6 +87,11 @@ class CeilingSensorBloc extends Bloc<CeilingSensorEvent, CeilingSensorState> {
|
||||
if (!response) {
|
||||
add(CeilingInitialEvent());
|
||||
}
|
||||
if (response == true && code == 'scene') {
|
||||
emit(CeilingLoadingInitialState());
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
add(CeilingInitialEvent());
|
||||
}
|
||||
} catch (_) {
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
add(CeilingInitialEvent());
|
||||
|
||||
@ -10,7 +10,7 @@ class CeilingSensorModel {
|
||||
String bodyMovement;
|
||||
String noBodyTime;
|
||||
int maxDistance;
|
||||
String spaceType;
|
||||
SpaceTypes spaceType;
|
||||
|
||||
CeilingSensorModel({
|
||||
required this.presenceState,
|
||||
@ -33,7 +33,7 @@ class CeilingSensorModel {
|
||||
String _bodyMovement = 'none';
|
||||
String _noBodyTime = 'none';
|
||||
int _maxDis = 0;
|
||||
String _spaceType = 'none';
|
||||
SpaceTypes _spaceType = SpaceTypes.none;
|
||||
|
||||
try {
|
||||
for (var status in jsonList) {
|
||||
@ -42,7 +42,7 @@ class CeilingSensorModel {
|
||||
_presenceState = status.value ?? 'none';
|
||||
break;
|
||||
case 'scene':
|
||||
_spaceType = status.value ?? 'none';
|
||||
_spaceType = getSpaceType(status.value ?? 'none');
|
||||
break;
|
||||
case 'sensitivity':
|
||||
_sensitivity = status.value is int
|
||||
@ -92,3 +92,27 @@ class CeilingSensorModel {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
enum SpaceTypes {
|
||||
none,
|
||||
parlour,
|
||||
area,
|
||||
toilet,
|
||||
bedroom,
|
||||
}
|
||||
|
||||
SpaceTypes getSpaceType(String value) {
|
||||
switch (value) {
|
||||
case 'parlour':
|
||||
return SpaceTypes.parlour;
|
||||
case 'area':
|
||||
return SpaceTypes.area;
|
||||
case 'toilet':
|
||||
return SpaceTypes.toilet;
|
||||
case 'bedroom':
|
||||
return SpaceTypes.bedroom;
|
||||
case 'none':
|
||||
default:
|
||||
return SpaceTypes.none;
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,15 +99,14 @@ class CeilingSensorControls extends StatelessWidget
|
||||
description: 'Detection Range',
|
||||
),
|
||||
PresenceSpaceType(
|
||||
listOfIcons: const [
|
||||
Assets.office,
|
||||
Assets.parlour,
|
||||
Assets.dyi,
|
||||
Assets.bathroom,
|
||||
Assets.bedroom,
|
||||
],
|
||||
description: 'Space Type',
|
||||
value: model.spaceType,
|
||||
action: (String value) => context.read<CeilingSensorBloc>().add(
|
||||
CeilingChangeValueEvent(
|
||||
code: 'scene',
|
||||
value: value,
|
||||
),
|
||||
),
|
||||
),
|
||||
PresenceUpdateData(
|
||||
value: model.sensitivity.toDouble(),
|
||||
|
||||
@ -1,24 +1,33 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
import 'package:syncrow_web/utils/extension/build_context_x.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/pages/device_managment/ceiling_sensor/model/ceiling_sensor_model.dart';
|
||||
|
||||
class PresenceSpaceType extends StatelessWidget {
|
||||
const PresenceSpaceType({
|
||||
super.key,
|
||||
required this.listOfIcons,
|
||||
required this.description,
|
||||
required this.value,
|
||||
required this.action,
|
||||
});
|
||||
|
||||
final List<String> listOfIcons;
|
||||
final String description;
|
||||
final String value;
|
||||
final SpaceTypes value;
|
||||
final void Function(String value) action;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Map<SpaceTypes, String> spaceTypeIcons = {
|
||||
SpaceTypes.none: Assets.office,
|
||||
SpaceTypes.parlour: Assets.parlour,
|
||||
SpaceTypes.area: Assets.dyi,
|
||||
SpaceTypes.toilet: Assets.bathroom,
|
||||
SpaceTypes.bedroom: Assets.bedroom,
|
||||
};
|
||||
|
||||
return DeviceControlsContainer(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@ -38,23 +47,28 @@ class PresenceSpaceType extends StatelessWidget {
|
||||
Wrap(
|
||||
runSpacing: 8,
|
||||
spacing: 16,
|
||||
children: [
|
||||
...listOfIcons.map((icon) => Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(100),
|
||||
border: Border.all(
|
||||
color: icon.contains(value)
|
||||
? ColorsManager.blueColor
|
||||
: Colors.transparent,
|
||||
),
|
||||
children: spaceTypeIcons.entries.map((entry) {
|
||||
final icon = entry.value;
|
||||
final spaceType = entry.key;
|
||||
return GestureDetector(
|
||||
onTap: () => action(spaceType.name),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(100),
|
||||
border: Border.all(
|
||||
color: value == spaceType
|
||||
? ColorsManager.blueColor
|
||||
: Colors.transparent,
|
||||
),
|
||||
child: SvgPicture.asset(
|
||||
icon,
|
||||
width: 40,
|
||||
height: 40,
|
||||
),
|
||||
)),
|
||||
],
|
||||
),
|
||||
child: SvgPicture.asset(
|
||||
icon,
|
||||
width: 40,
|
||||
height: 40,
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@ -6,6 +6,8 @@ import 'package:syncrow_web/pages/device_managment/shared/table/table_header.dar
|
||||
|
||||
class ReportsTable extends StatelessWidget {
|
||||
final DeviceReport report;
|
||||
final String? thirdColumnTitle;
|
||||
final String? thirdColumnDescription;
|
||||
final Function(int index) onRowTap;
|
||||
final VoidCallback onClose;
|
||||
|
||||
@ -14,6 +16,8 @@ class ReportsTable extends StatelessWidget {
|
||||
required this.report,
|
||||
required this.onRowTap,
|
||||
required this.onClose,
|
||||
this.thirdColumnTitle,
|
||||
this.thirdColumnDescription,
|
||||
});
|
||||
|
||||
@override
|
||||
@ -32,33 +36,34 @@ class ReportsTable extends StatelessWidget {
|
||||
children: [
|
||||
TableRow(
|
||||
decoration: BoxDecoration(color: Colors.grey.shade200),
|
||||
children: const [
|
||||
TableHeader(title: 'Date'),
|
||||
TableHeader(title: 'Time'),
|
||||
TableHeader(title: 'Status'),
|
||||
children: [
|
||||
const TableHeader(title: 'Date'),
|
||||
const TableHeader(title: 'Time'),
|
||||
TableHeader(title: thirdColumnTitle ?? 'Status'),
|
||||
],
|
||||
),
|
||||
...report.data!.asMap().entries.map((entry) {
|
||||
int index = entry.key;
|
||||
DeviceEvent data = entry.value;
|
||||
if (report.data != null)
|
||||
...report.data!.asMap().entries.map((entry) {
|
||||
int index = entry.key;
|
||||
DeviceEvent data = entry.value;
|
||||
|
||||
// Parse eventTime into Date and Time
|
||||
DateTime eventDateTime =
|
||||
DateTime.fromMillisecondsSinceEpoch(data.eventTime!);
|
||||
String date = DateFormat('dd/MM/yyyy').format(eventDateTime);
|
||||
String time = DateFormat('HH:mm').format(eventDateTime);
|
||||
// Parse eventTime into Date and Time
|
||||
DateTime eventDateTime =
|
||||
DateTime.fromMillisecondsSinceEpoch(data.eventTime!);
|
||||
String date = DateFormat('dd/MM/yyyy').format(eventDateTime);
|
||||
String time = DateFormat('HH:mm').format(eventDateTime);
|
||||
|
||||
return TableRow(
|
||||
children: [
|
||||
TableCellWidget(value: date),
|
||||
TableCellWidget(value: time),
|
||||
TableCellWidget(
|
||||
value: data.value!,
|
||||
onTap: () => onRowTap(index),
|
||||
),
|
||||
],
|
||||
);
|
||||
}).toList(),
|
||||
return TableRow(
|
||||
children: [
|
||||
TableCellWidget(value: date),
|
||||
TableCellWidget(value: time),
|
||||
TableCellWidget(
|
||||
value: '${data.value!} ${thirdColumnDescription ?? ''}',
|
||||
onTap: () => onRowTap(index),
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@ -99,7 +99,7 @@ class WallSensorBloc extends Bloc<WallSensorEvent, WallSensorState> {
|
||||
try {
|
||||
await DevicesManagementApi.getDeviceReports(deviceId, event.code)
|
||||
.then((value) {
|
||||
emit(DeviceReportsState(deviceReport: value));
|
||||
emit(DeviceReportsState(deviceReport: value, code:event.code));
|
||||
});
|
||||
} catch (e) {
|
||||
emit(DeviceReportsFailedState(error: e.toString()));
|
||||
|
||||
@ -42,7 +42,8 @@ class DeviceReportsLoadingState extends WallSensorState {}
|
||||
|
||||
class DeviceReportsState extends WallSensorState {
|
||||
final DeviceReport deviceReport;
|
||||
const DeviceReportsState({required this.deviceReport});
|
||||
final String code;
|
||||
const DeviceReportsState({required this.deviceReport, required this.code});
|
||||
}
|
||||
|
||||
class DeviceReportsFailedState extends WallSensorState {
|
||||
|
||||
@ -25,16 +25,23 @@ class WallSensorControls extends StatelessWidget with HelperResponsiveLayout {
|
||||
final isLarge = isLargeScreenSize(context);
|
||||
final isMedium = isMediumScreenSize(context);
|
||||
return BlocProvider(
|
||||
create: (context) => WallSensorBloc(deviceId: device.uuid!)..add(WallSensorInitialEvent()),
|
||||
create: (context) =>
|
||||
WallSensorBloc(deviceId: device.uuid!)..add(WallSensorInitialEvent()),
|
||||
child: BlocBuilder<WallSensorBloc, WallSensorState>(
|
||||
builder: (context, state) {
|
||||
if (state is WallSensorLoadingInitialState || state is DeviceReportsLoadingState) {
|
||||
if (state is WallSensorLoadingInitialState ||
|
||||
state is DeviceReportsLoadingState) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
} else if (state is WallSensorUpdateState) {
|
||||
return _buildGridView(context, state.wallSensorModel, isExtraLarge, isLarge, isMedium);
|
||||
return _buildGridView(context, state.wallSensorModel, isExtraLarge,
|
||||
isLarge, isMedium);
|
||||
} else if (state is DeviceReportsState) {
|
||||
return ReportsTable(
|
||||
report: state.deviceReport,
|
||||
thirdColumnTitle:
|
||||
state.code == 'illuminance_value' ? "Value" : 'Status',
|
||||
thirdColumnDescription:
|
||||
state.code == 'illuminance_value' ? "Lux" : null,
|
||||
onRowTap: (index) {},
|
||||
onClose: () {
|
||||
context.read<WallSensorBloc>().add(BackToGridViewEvent());
|
||||
@ -49,7 +56,8 @@ class WallSensorControls extends StatelessWidget with HelperResponsiveLayout {
|
||||
);
|
||||
} else if (state is DeviceReportsFailedState) {
|
||||
final model = context.read<WallSensorBloc>().deviceStatus;
|
||||
return _buildGridView(context, model, isExtraLarge, isLarge, isMedium);
|
||||
return _buildGridView(
|
||||
context, model, isExtraLarge, isLarge, isMedium);
|
||||
}
|
||||
return const Center(child: Text('Error fetching status'));
|
||||
},
|
||||
@ -57,8 +65,8 @@ class WallSensorControls extends StatelessWidget with HelperResponsiveLayout {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildGridView(
|
||||
BuildContext context, WallSensorModel model, bool isExtraLarge, bool isLarge, bool isMedium) {
|
||||
Widget _buildGridView(BuildContext context, WallSensorModel model,
|
||||
bool isExtraLarge, bool isLarge, bool isMedium) {
|
||||
return GridView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 50),
|
||||
shrinkWrap: true,
|
||||
@ -127,10 +135,11 @@ class WallSensorControls extends StatelessWidget with HelperResponsiveLayout {
|
||||
maxValue: 10000,
|
||||
steps: 1,
|
||||
description: 'hr',
|
||||
action: (int value) => context.read<WallSensorBloc>().add(WallSensorChangeValueEvent(
|
||||
code: 'no_one_time',
|
||||
value: value,
|
||||
))),
|
||||
action: (int value) =>
|
||||
context.read<WallSensorBloc>().add(WallSensorChangeValueEvent(
|
||||
code: 'no_one_time',
|
||||
value: value,
|
||||
))),
|
||||
PresenceUpdateData(
|
||||
value: model.farDetection.toDouble(),
|
||||
title: 'Far Detection:',
|
||||
@ -147,9 +156,8 @@ class WallSensorControls extends StatelessWidget with HelperResponsiveLayout {
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
context
|
||||
.read<WallSensorBloc>()
|
||||
.add(GetDeviceReportsEvent(code: 'illuminance_value', deviceUuid: device.uuid!));
|
||||
context.read<WallSensorBloc>().add(GetDeviceReportsEvent(
|
||||
code: 'illuminance_value', deviceUuid: device.uuid!));
|
||||
},
|
||||
child: const PresenceStaticWidget(
|
||||
icon: Assets.illuminanceRecordIcon,
|
||||
@ -158,9 +166,8 @@ class WallSensorControls extends StatelessWidget with HelperResponsiveLayout {
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
context
|
||||
.read<WallSensorBloc>()
|
||||
.add(GetDeviceReportsEvent(code: 'presence_state', deviceUuid: device.uuid!));
|
||||
context.read<WallSensorBloc>().add(GetDeviceReportsEvent(
|
||||
code: 'presence_state', deviceUuid: device.uuid!));
|
||||
},
|
||||
child: const PresenceStaticWidget(
|
||||
icon: Assets.presenceRecordIcon,
|
||||
|
||||
@ -16,11 +16,11 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
|
||||
final BuchheimWalkerConfiguration builder = BuchheimWalkerConfiguration();
|
||||
List<Node> sourcesList = [];
|
||||
List<Node> destinationsList = [];
|
||||
static UserModel? user;
|
||||
UserModel? user;
|
||||
|
||||
HomeBloc() : super((HomeInitial())) {
|
||||
on<CreateNewNode>(_createNode);
|
||||
fetchUserInfo();
|
||||
on<FetchUserInfo>(_fetchUserInfo);
|
||||
}
|
||||
|
||||
void _createNode(CreateNewNode event, Emitter<HomeState> emit) async {
|
||||
@ -39,10 +39,12 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
|
||||
emit(HomeUpdateTree(graph: graph, builder: builder));
|
||||
}
|
||||
|
||||
static Future fetchUserInfo() async {
|
||||
Future _fetchUserInfo(FetchUserInfo event, Emitter<HomeState> emit) async {
|
||||
try {
|
||||
var uuid = await const FlutterSecureStorage().read(key: UserModel.userUuidKey);
|
||||
var uuid =
|
||||
await const FlutterSecureStorage().read(key: UserModel.userUuidKey);
|
||||
user = await HomeApi().fetchUserInfo(uuid);
|
||||
emit(HomeInitial());
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -17,3 +17,7 @@ class CreateNewNode extends HomeEvent {
|
||||
@override
|
||||
List<Object> get props => [sourceNode, destinationNode];
|
||||
}
|
||||
|
||||
class FetchUserInfo extends HomeEvent {
|
||||
const FetchUserInfo();
|
||||
}
|
||||
@ -1,11 +1,25 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/home/bloc/home_bloc.dart';
|
||||
import 'package:syncrow_web/pages/home/bloc/home_event.dart';
|
||||
import 'package:syncrow_web/pages/home/view/home_page_mobile.dart';
|
||||
import 'package:syncrow_web/pages/home/view/home_page_web.dart';
|
||||
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
||||
|
||||
class HomePage extends StatelessWidget with HelperResponsiveLayout {
|
||||
class HomePage extends StatefulWidget {
|
||||
const HomePage({super.key});
|
||||
|
||||
@override
|
||||
State<HomePage> createState() => _HomePageState();
|
||||
}
|
||||
|
||||
class _HomePageState extends State<HomePage> with HelperResponsiveLayout {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
context.read<HomeBloc>().add(const FetchUserInfo());
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final isSmallScreen = isSmallScreenSize(context);
|
||||
|
||||
@ -10,6 +10,7 @@ import 'package:syncrow_web/web_layout/web_scaffold.dart';
|
||||
|
||||
class HomeMobilePage extends StatelessWidget {
|
||||
HomeMobilePage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Size size = MediaQuery.of(context).size;
|
||||
@ -79,7 +80,7 @@ class HomeMobilePage extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
dynamic homeItems = [
|
||||
final dynamic homeItems = [
|
||||
{
|
||||
'title': 'Access',
|
||||
'icon': Assets.accessIcon,
|
||||
|
||||
@ -1,16 +0,0 @@
|
||||
|
||||
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SpaseManagementicon extends StatelessWidget {
|
||||
const SpaseManagementicon({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Container(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -219,8 +219,8 @@ class VisitorPasswordBloc extends Bloc<VisitorPasswordEvent, VisitorPasswordStat
|
||||
scheduleList: [
|
||||
if (repeat)
|
||||
Schedule(
|
||||
effectiveTime: getTimeFromDateTimeString(expirationTime),
|
||||
invalidTime: getTimeFromDateTimeString(effectiveTime).toString(),
|
||||
effectiveTime: getTimeFromDateTimeString(effectiveTime),
|
||||
invalidTime: getTimeFromDateTimeString(expirationTime).toString(),
|
||||
workingDay: selectedDays,
|
||||
),
|
||||
],
|
||||
@ -448,6 +448,7 @@ class VisitorPasswordBloc extends Bloc<VisitorPasswordEvent, VisitorPasswordStat
|
||||
<Widget>[
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
|
||||
Navigator.of(context).pop(true);
|
||||
},
|
||||
child: const Text('OK'),
|
||||
|
||||
@ -35,12 +35,12 @@ class AddDeviceDialog extends StatelessWidget {
|
||||
backgroundColor: Colors.white,
|
||||
title: Text(
|
||||
'Add Accessible Device',
|
||||
style: Theme.of(context).textTheme.headlineLarge!.copyWith(
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 24,
|
||||
color: Colors.black),
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.headlineLarge!
|
||||
.copyWith(fontWeight: FontWeight.w400, fontSize: 24, color: Colors.black),
|
||||
),
|
||||
content: Container(
|
||||
content: SizedBox(
|
||||
height: MediaQuery.of(context).size.height / 1.7,
|
||||
width: MediaQuery.of(context).size.width / 2,
|
||||
child: Padding(
|
||||
@ -68,17 +68,14 @@ class AddDeviceDialog extends StatelessWidget {
|
||||
),
|
||||
Text(
|
||||
'Only online accessible devices can be added',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodySmall!
|
||||
.copyWith(
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 12,
|
||||
color: ColorsManager.grayColor),
|
||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 12,
|
||||
color: ColorsManager.grayColor),
|
||||
),
|
||||
],
|
||||
)),
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
const SizedBox(
|
||||
@ -93,7 +90,7 @@ class AddDeviceDialog extends StatelessWidget {
|
||||
flex: 4,
|
||||
child: CustomWebTextField(
|
||||
controller: visitorBloc.deviceNameController,
|
||||
isRequired: true,
|
||||
isRequired: false,
|
||||
textFieldName: 'Device Name',
|
||||
description: '',
|
||||
),
|
||||
@ -103,7 +100,7 @@ class AddDeviceDialog extends StatelessWidget {
|
||||
flex: 4,
|
||||
child: CustomWebTextField(
|
||||
controller: visitorBloc.deviceIdController,
|
||||
isRequired: true,
|
||||
isRequired: false,
|
||||
textFieldName: 'Device ID',
|
||||
description: '',
|
||||
),
|
||||
@ -113,7 +110,7 @@ class AddDeviceDialog extends StatelessWidget {
|
||||
flex: 4,
|
||||
child: CustomWebTextField(
|
||||
controller: visitorBloc.unitNameController,
|
||||
isRequired: true,
|
||||
isRequired: false,
|
||||
textFieldName: 'Unit Name',
|
||||
description: '',
|
||||
),
|
||||
@ -155,8 +152,7 @@ class AddDeviceDialog extends StatelessWidget {
|
||||
visitorBloc.deviceNameController.clear();
|
||||
visitorBloc.deviceIdController.clear();
|
||||
visitorBloc.unitNameController.clear();
|
||||
visitorBloc.add(
|
||||
FetchDevice()); // Reset to original list
|
||||
visitorBloc.add(FetchDevice()); // Reset to original list
|
||||
},
|
||||
),
|
||||
),
|
||||
@ -168,14 +164,15 @@ class AddDeviceDialog extends StatelessWidget {
|
||||
flex: 3,
|
||||
child: state is TableLoaded
|
||||
? DynamicTable(
|
||||
uuidIndex: 1,
|
||||
withSelectAll: true,
|
||||
initialSelectedIds: selectedDeviceIds,
|
||||
cellDecoration: containerDecoration,
|
||||
isEmpty: visitorBloc.data.isEmpty,
|
||||
selectAll: (p0) {
|
||||
visitorBloc.selectedDeviceIds.clear();
|
||||
for (var item in state.data) {
|
||||
visitorBloc
|
||||
.add(SelectDeviceEvent(item.uuid));
|
||||
visitorBloc.add(SelectDeviceEvent(item.uuid));
|
||||
}
|
||||
},
|
||||
onRowSelected: (index, isSelected, row) {
|
||||
|
||||
@ -87,7 +87,8 @@ class VisitorPasswordDialog extends StatelessWidget {
|
||||
],
|
||||
))
|
||||
.then((v) {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pop(true);
|
||||
|
||||
});
|
||||
} else if (state is FailedState) {
|
||||
visitorBloc.stateDialog(
|
||||
@ -211,28 +212,28 @@ class VisitorPasswordDialog extends StatelessWidget {
|
||||
},
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: size.width * 0.12,
|
||||
child: RadioListTile<String>(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: Text(
|
||||
'Dynamic Password',
|
||||
style: text,
|
||||
),
|
||||
value: 'Dynamic Password',
|
||||
groupValue: (state is PasswordTypeSelected)
|
||||
? state.selectedType
|
||||
: visitorBloc.accessTypeSelected,
|
||||
onChanged: (String? value) {
|
||||
if (value != null) {
|
||||
context
|
||||
.read<VisitorPasswordBloc>()
|
||||
.add(SelectPasswordType(value));
|
||||
visitorBloc.usageFrequencySelected = '';
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
// SizedBox(
|
||||
// width: size.width * 0.12,
|
||||
// child: RadioListTile<String>(
|
||||
// contentPadding: EdgeInsets.zero,
|
||||
// title: Text(
|
||||
// 'Dynamic Password',
|
||||
// style: text,
|
||||
// ),
|
||||
// value: 'Dynamic Password',
|
||||
// groupValue: (state is PasswordTypeSelected)
|
||||
// ? state.selectedType
|
||||
// : visitorBloc.accessTypeSelected,
|
||||
// onChanged: (String? value) {
|
||||
// if (value != null) {
|
||||
// context
|
||||
// .read<VisitorPasswordBloc>()
|
||||
// .add(SelectPasswordType(value));
|
||||
// visitorBloc.usageFrequencySelected = '';
|
||||
// }
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
)),
|
||||
const Spacer(
|
||||
@ -256,14 +257,14 @@ class VisitorPasswordDialog extends StatelessWidget {
|
||||
color: ColorsManager.grayColor,
|
||||
fontSize: 9),
|
||||
),
|
||||
if (visitorBloc.accessTypeSelected == 'Dynamic Password')
|
||||
Text(
|
||||
'Quick and short-acting password, only valid within 5 minutes after creation, the system randomly generates a digital password.',
|
||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
fontWeight: FontWeight.w400,
|
||||
color: ColorsManager.grayColor,
|
||||
fontSize: 9),
|
||||
),
|
||||
// if (visitorBloc.accessTypeSelected == 'Dynamic Password')
|
||||
// Text(
|
||||
// 'Quick and short-acting password, only valid within 5 minutes after creation, the system randomly generates a digital password.',
|
||||
// style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
// fontWeight: FontWeight.w400,
|
||||
// color: ColorsManager.grayColor,
|
||||
// fontSize: 9),
|
||||
// ),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
)
|
||||
@ -323,8 +324,7 @@ class VisitorPasswordDialog extends StatelessWidget {
|
||||
: visitorBloc.usageFrequencySelected,
|
||||
onChanged: (String? value) {
|
||||
if (value != null) {
|
||||
context
|
||||
.read<VisitorPasswordBloc>()
|
||||
context.read<VisitorPasswordBloc>()
|
||||
.add(SelectUsageFrequency(value));
|
||||
}
|
||||
},
|
||||
@ -344,7 +344,7 @@ class VisitorPasswordDialog extends StatelessWidget {
|
||||
if (visitorBloc.usageFrequencySelected == 'One-Time' &&
|
||||
visitorBloc.accessTypeSelected == 'Offline Password')
|
||||
Text(
|
||||
'Within the validity period, there is no limit to the number of times each device can be unlocked.',
|
||||
'Within the validity period, each device can be unlocked only once, and the maximum validity period is 6 hours',
|
||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
color: ColorsManager.grayColor, fontSize: 9),
|
||||
),
|
||||
@ -380,11 +380,9 @@ class VisitorPasswordDialog extends StatelessWidget {
|
||||
endTime: () {
|
||||
if (visitorBloc.usageFrequencySelected == 'Periodic' &&
|
||||
visitorBloc.accessTypeSelected == 'Offline Password') {
|
||||
visitorBloc.add(
|
||||
SelectTimeEvent(context: context, isEffective: false));
|
||||
visitorBloc.add(SelectTimeEvent(context: context, isEffective: false));
|
||||
} else {
|
||||
visitorBloc.add(SelectTimeVisitorPassword(
|
||||
context: context, isStart: false, isRepeat: false));
|
||||
visitorBloc.add(SelectTimeVisitorPassword(context: context, isStart: false, isRepeat: false));
|
||||
}
|
||||
},
|
||||
startTime: () {
|
||||
@ -398,13 +396,11 @@ class VisitorPasswordDialog extends StatelessWidget {
|
||||
}
|
||||
},
|
||||
firstString: (visitorBloc.usageFrequencySelected ==
|
||||
'Periodic' &&
|
||||
visitorBloc.accessTypeSelected == 'Offline Password')
|
||||
'Periodic' && visitorBloc.accessTypeSelected == 'Offline Password')
|
||||
? visitorBloc.effectiveTime
|
||||
: visitorBloc.startTimeAccess.toString(),
|
||||
secondString: (visitorBloc.usageFrequencySelected ==
|
||||
'Periodic' &&
|
||||
visitorBloc.accessTypeSelected == 'Offline Password')
|
||||
'Periodic' && visitorBloc.accessTypeSelected == 'Offline Password')
|
||||
? visitorBloc.expirationTime
|
||||
: visitorBloc.endTimeAccess.toString(),
|
||||
icon: Assets.calendarIcon),
|
||||
@ -528,9 +524,20 @@ class VisitorPasswordDialog extends StatelessWidget {
|
||||
if (visitorBloc.usageFrequencySelected == 'One-Time' &&
|
||||
visitorBloc.accessTypeSelected == 'Offline Password') {
|
||||
setPasswordFunction(context, size, visitorBloc);
|
||||
} else if (visitorBloc.accessTypeSelected == 'Dynamic Password') {
|
||||
setPasswordFunction(context, size, visitorBloc);
|
||||
} else {
|
||||
} else if (visitorBloc.usageFrequencySelected == 'Periodic' &&
|
||||
visitorBloc.accessTypeSelected == 'Offline Password') {
|
||||
if (visitorBloc.expirationTime != 'End Time' &&
|
||||
visitorBloc.effectiveTime != 'Start Time' ) {
|
||||
setPasswordFunction(context, size, visitorBloc);
|
||||
}else{
|
||||
visitorBloc.stateDialog(
|
||||
context: context,
|
||||
message: 'Please select Access Period to continue',
|
||||
title: 'Access Period');
|
||||
}
|
||||
} else if(
|
||||
visitorBloc.endTimeAccess.toString()!='End Time'
|
||||
&&visitorBloc.startTimeAccess.toString()!='Start Time') {
|
||||
if (visitorBloc.effectiveTimeTimeStamp != null &&
|
||||
visitorBloc.expirationTimeTimeStamp != null) {
|
||||
if (isRepeat == true) {
|
||||
@ -554,6 +561,11 @@ class VisitorPasswordDialog extends StatelessWidget {
|
||||
message: 'Please select Access Period to continue',
|
||||
title: 'Access Period');
|
||||
}
|
||||
}else{
|
||||
visitorBloc.stateDialog(
|
||||
context: context,
|
||||
message: 'Please select Access Period to continue',
|
||||
title: 'Access Period');
|
||||
}
|
||||
} else {
|
||||
visitorBloc.stateDialog(
|
||||
@ -563,57 +575,6 @@ class VisitorPasswordDialog extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// onPressed: () {
|
||||
// if (visitorBloc.forgetFormKey.currentState!.validate()) {
|
||||
// if (visitorBloc.selectedDevices.isNotEmpty) {
|
||||
// switch (visitorBloc.usageFrequencySelected) {
|
||||
// case 'One-Time':
|
||||
// if (visitorBloc.accessTypeSelected == 'Offline Password') {
|
||||
// setPasswordFunction(context, size, visitorBloc);
|
||||
// } else {
|
||||
// visitorBloc.stateDialog(
|
||||
// context: context,
|
||||
// message: 'Invalid combination of Access Type and Usage Frequency.',
|
||||
// title: 'Error',
|
||||
// );
|
||||
// }
|
||||
// break;
|
||||
// default:
|
||||
// if (visitorBloc.effectiveTimeTimeStamp != null && visitorBloc.expirationTimeTimeStamp != null) {
|
||||
// if (isRepeat) {
|
||||
// if (visitorBloc.expirationTime != 'End Time' &&
|
||||
// visitorBloc.effectiveTime != 'Start Time' &&
|
||||
// visitorBloc.selectedDays.isNotEmpty) {
|
||||
// setPasswordFunction(context, size, visitorBloc);
|
||||
// } else {
|
||||
// visitorBloc.stateDialog(
|
||||
// context: context,
|
||||
// message: 'Please select days and fill start time and end time to continue',
|
||||
// title: 'Access Period',
|
||||
// );
|
||||
// }
|
||||
// } else {
|
||||
// setPasswordFunction(context, size, visitorBloc);
|
||||
// }
|
||||
// } else {
|
||||
// visitorBloc.stateDialog(
|
||||
// context: context,
|
||||
// message: 'Please select Access Period to continue',
|
||||
// title: 'Access Period',
|
||||
// );
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// } else {
|
||||
// visitorBloc.stateDialog(
|
||||
// context: context,
|
||||
// message: 'Please select devices to continue',
|
||||
// title: 'Select Devices',
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
borderRadius: 8,
|
||||
child: Text(
|
||||
'Ok',
|
||||
@ -723,39 +684,39 @@ class VisitorPasswordDialog extends StatelessWidget {
|
||||
borderRadius: 8,
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
if (visitorBloc.accessTypeSelected == 'Dynamic Password') {
|
||||
} else {
|
||||
if (visitorBloc.usageFrequencySelected == 'One-Time' &&
|
||||
visitorBloc.accessTypeSelected == 'Online Password') {
|
||||
visitorBloc.add(OnlineOneTimePasswordEvent(
|
||||
context: context,
|
||||
passwordName: visitorBloc.userNameController.text,
|
||||
email: visitorBloc.emailController.text,
|
||||
));
|
||||
} else if (visitorBloc.usageFrequencySelected == 'Periodic' &&
|
||||
visitorBloc.accessTypeSelected == 'Online Password') {
|
||||
visitorBloc.add(OnlineMultipleTimePasswordEvent(
|
||||
passwordName: visitorBloc.userNameController.text,
|
||||
email: visitorBloc.emailController.text,
|
||||
effectiveTime: visitorBloc.effectiveTimeTimeStamp.toString(),
|
||||
invalidTime: visitorBloc.expirationTimeTimeStamp.toString(),
|
||||
));
|
||||
} else if (visitorBloc.usageFrequencySelected == 'One-Time' &&
|
||||
visitorBloc.accessTypeSelected == 'Offline Password') {
|
||||
visitorBloc.add(OfflineOneTimePasswordEvent(
|
||||
context: context,
|
||||
passwordName: visitorBloc.userNameController.text,
|
||||
email: visitorBloc.emailController.text,
|
||||
));
|
||||
} else if (visitorBloc.usageFrequencySelected == 'Periodic' &&
|
||||
visitorBloc.accessTypeSelected == 'Offline Password') {
|
||||
visitorBloc.add(OfflineMultipleTimePasswordEvent(
|
||||
passwordName: visitorBloc.userNameController.text,
|
||||
email: visitorBloc.emailController.text,
|
||||
effectiveTime: visitorBloc.effectiveTimeTimeStamp.toString(),
|
||||
invalidTime: visitorBloc.expirationTimeTimeStamp.toString(),
|
||||
));
|
||||
}
|
||||
if (visitorBloc.usageFrequencySelected == 'One-Time' &&
|
||||
visitorBloc.accessTypeSelected == 'Online Password') {
|
||||
visitorBloc.add(OnlineOneTimePasswordEvent(
|
||||
context: context,
|
||||
passwordName: visitorBloc.userNameController.text,
|
||||
email: visitorBloc.emailController.text,
|
||||
));
|
||||
}
|
||||
else if (visitorBloc.usageFrequencySelected == 'Periodic' &&
|
||||
visitorBloc.accessTypeSelected == 'Online Password') {
|
||||
visitorBloc.add(OnlineMultipleTimePasswordEvent(
|
||||
passwordName: visitorBloc.userNameController.text,
|
||||
email: visitorBloc.emailController.text,
|
||||
effectiveTime: visitorBloc.effectiveTimeTimeStamp.toString(),
|
||||
invalidTime: visitorBloc.expirationTimeTimeStamp.toString(),
|
||||
));
|
||||
}
|
||||
else if (visitorBloc.usageFrequencySelected == 'One-Time' &&
|
||||
visitorBloc.accessTypeSelected == 'Offline Password') {
|
||||
visitorBloc.add(OfflineOneTimePasswordEvent(
|
||||
context: context,
|
||||
passwordName: visitorBloc.userNameController.text,
|
||||
email: visitorBloc.emailController.text,
|
||||
));
|
||||
}
|
||||
else if (visitorBloc.usageFrequencySelected == 'Periodic' &&
|
||||
visitorBloc.accessTypeSelected == 'Offline Password') {
|
||||
visitorBloc.add(OfflineMultipleTimePasswordEvent(
|
||||
passwordName: visitorBloc.userNameController.text,
|
||||
email: visitorBloc.emailController.text,
|
||||
effectiveTime: visitorBloc.effectiveTimeTimeStamp.toString(),
|
||||
invalidTime: visitorBloc.expirationTimeTimeStamp.toString(),
|
||||
));
|
||||
}
|
||||
},
|
||||
child: Text(
|
||||
|
||||
@ -22,7 +22,6 @@ class AccessMangApi {
|
||||
);
|
||||
return response;
|
||||
} catch (e) {
|
||||
debugPrint('Error fetching visitor passwords: $e');
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@ -42,7 +41,6 @@ class AccessMangApi {
|
||||
);
|
||||
return response;
|
||||
} catch (e) {
|
||||
debugPrint('Error fetching $e');
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,7 +25,8 @@ class AuthenticationAPI {
|
||||
path: ApiEndpoints.forgetPassword,
|
||||
body: {"email": email, "password": password},
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {});
|
||||
expectedResponseModel: (json) {
|
||||
});
|
||||
return response;
|
||||
}
|
||||
|
||||
@ -52,21 +53,17 @@ class AuthenticationAPI {
|
||||
return cooldown;
|
||||
}
|
||||
} else {
|
||||
debugPrint('Error: ${e.response!.statusCode} - ${e.response!.statusMessage}');
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
debugPrint('Error: ${e.message}');
|
||||
return 1;
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint('Unexpected Error: $e');
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
static Future verifyOtp({required String email, required String otpCode}) async {
|
||||
try {
|
||||
final response = await HTTPService().post(
|
||||
path: ApiEndpoints.verifyOtp,
|
||||
body: {"email": email, "type": "PASSWORD", "otpCode": otpCode},
|
||||
@ -79,17 +76,7 @@ class AuthenticationAPI {
|
||||
}
|
||||
});
|
||||
return response;
|
||||
} on DioException catch (e) {
|
||||
if (e.response != null) {
|
||||
if (e.response!.statusCode == 400) {
|
||||
final errorData = e.response!.data;
|
||||
String errorMessage = errorData['message'];
|
||||
return errorMessage;
|
||||
}
|
||||
} else {
|
||||
debugPrint('Error: ${e.message}');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static Future<List<RegionModel>> fetchRegion() async {
|
||||
|
||||
@ -1,41 +1,35 @@
|
||||
abstract class ApiEndpoints {
|
||||
static const String baseUrl = 'https://syncrow-dev.azurewebsites.net';
|
||||
// static const String baseUrl = 'http://100.107.182.63:4001'; //Localhost
|
||||
//https://syncrow-staging.azurewebsites.net
|
||||
////////////////////////////////////// Authentication ///////////////////////////////
|
||||
static const String signUp = '$baseUrl/authentication/user/signup';
|
||||
static const String login = '$baseUrl/authentication/user/login';
|
||||
static const String forgetPassword =
|
||||
'$baseUrl/authentication/user/forget-password';
|
||||
static const String sendOtp = '$baseUrl/authentication/user/send-otp';
|
||||
static const String verifyOtp = '$baseUrl/authentication/user/verify-otp';
|
||||
static const String getRegion = '$baseUrl/region';
|
||||
static const String visitorPassword = '$baseUrl/visitor-password';
|
||||
static const String getDevices = '$baseUrl/visitor-password/devices';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
|
||||
static const String sendOnlineOneTime =
|
||||
'$baseUrl/visitor-password/temporary-password/online/one-time';
|
||||
abstract class ApiEndpoints {
|
||||
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';
|
||||
static const String sendOtp = '/authentication/user/send-otp';
|
||||
static const String verifyOtp = '/authentication/user/verify-otp';
|
||||
static const String getRegion = '/region';
|
||||
static const String visitorPassword = '/visitor-password';
|
||||
static const String getDevices = '/visitor-password/devices';
|
||||
|
||||
static const String sendOnlineOneTime = '/visitor-password/temporary-password/online/one-time';
|
||||
static const String sendOnlineMultipleTime =
|
||||
'$baseUrl/visitor-password/temporary-password/online/multiple-time';
|
||||
'/visitor-password/temporary-password/online/multiple-time';
|
||||
|
||||
//offline Password
|
||||
static const String sendOffLineOneTime =
|
||||
'$baseUrl/visitor-password/temporary-password/offline/one-time';
|
||||
static const String sendOffLineOneTime = '/visitor-password/temporary-password/offline/one-time';
|
||||
static const String sendOffLineMultipleTime =
|
||||
'$baseUrl/visitor-password/temporary-password/offline/multiple-time';
|
||||
'/visitor-password/temporary-password/offline/multiple-time';
|
||||
|
||||
static const String getUser = '$baseUrl/user/{userUuid}';
|
||||
static const String getUser = '/user/{userUuid}';
|
||||
|
||||
////// Devices Management ////////////////
|
||||
|
||||
static const String getAllDevices = '$baseUrl/device';
|
||||
static const String getDeviceStatus =
|
||||
'$baseUrl/device/{uuid}/functions/status';
|
||||
static const String getAllDevices = '/device';
|
||||
static const String getDeviceStatus = '/device/{uuid}/functions/status';
|
||||
|
||||
static const String deviceControl = '$baseUrl/device/{uuid}/control';
|
||||
static const String deviceControl = '/device/{uuid}/control';
|
||||
static const String gatewayApi = '/device/gateway/{gatewayUuid}/devices';
|
||||
static const String openDoorLock = '/door-lock/open/{doorLockUuid}';
|
||||
|
||||
static const String getDeviceLogs =
|
||||
'$baseUrl/device/report-logs/{uuid}?code={code}';
|
||||
static const String getDeviceLogs = '/device/report-logs/{uuid}?code={code}';
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@ class Assets {
|
||||
static const String google = "assets/images/google.svg";
|
||||
static const String facebook = "assets/images/facebook.svg";
|
||||
static const String invisiblePassword = "assets/images/Password_invisible.svg";
|
||||
static const String visiblePassword = "assets/images/Password_visible.svg";
|
||||
static const String visiblePassword = "assets/images/password_visible.svg";
|
||||
static const String accessIcon = "assets/images/access_icon.svg";
|
||||
static const String spaseManagementIcon = "assets/images/spase_management_icon.svg";
|
||||
static const String devicesIcon = "assets/images/devices_icon.svg";
|
||||
|
||||
@ -15,13 +15,14 @@ class WebAppBar extends StatelessWidget with HelperResponsiveLayout {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
bool isSmallScreen = isSmallScreenSize(context);
|
||||
|
||||
bool isHalfMediumScreen = isHafMediumScreenSize(context);
|
||||
return BlocBuilder<HomeBloc, HomeState>(builder: (context, state) {
|
||||
final user = context.read<HomeBloc>().user;
|
||||
return Container(
|
||||
height: isSmallScreen ? 130 : 100,
|
||||
height: (isSmallScreen || isHalfMediumScreen) ? 130 : 100,
|
||||
decoration: const BoxDecoration(color: ColorsManager.secondaryColor),
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: isSmallScreen
|
||||
child: isSmallScreen || isHalfMediumScreen
|
||||
? Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@ -31,14 +32,11 @@ class WebAppBar extends StatelessWidget with HelperResponsiveLayout {
|
||||
child: title!,
|
||||
),
|
||||
if (centerBody != null)
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 8.0),
|
||||
child: centerBody,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8.0),
|
||||
child: centerBody,
|
||||
),
|
||||
if (rightBody != null || HomeBloc.user != null)
|
||||
if (rightBody != null || user != null)
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
@ -61,9 +59,9 @@ class WebAppBar extends StatelessWidget with HelperResponsiveLayout {
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
if (HomeBloc.user != null)
|
||||
if (user != null)
|
||||
Text(
|
||||
'${HomeBloc.user!.firstName} ${HomeBloc.user!.lastName}',
|
||||
'${user.firstName} ${user.lastName}',
|
||||
style: Theme.of(context).textTheme.bodyLarge,
|
||||
),
|
||||
],
|
||||
@ -76,16 +74,18 @@ class WebAppBar extends StatelessWidget with HelperResponsiveLayout {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: title!,
|
||||
),
|
||||
if (centerBody != null)
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: centerBody,
|
||||
),
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
title!,
|
||||
if (centerBody != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 80),
|
||||
child: centerBody!,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
@ -113,9 +113,9 @@ class WebAppBar extends StatelessWidget with HelperResponsiveLayout {
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
if (HomeBloc.user != null)
|
||||
if (user != null)
|
||||
Text(
|
||||
'${HomeBloc.user!.firstName} ${HomeBloc.user!.lastName}',
|
||||
'${user.firstName} ${user.lastName}',
|
||||
style: Theme.of(context).textTheme.bodyLarge,
|
||||
),
|
||||
],
|
||||
|
||||
24
pubspec.lock
24
pubspec.lock
@ -89,6 +89,22 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
dropdown_button2:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: dropdown_button2
|
||||
sha256: b0fe8d49a030315e9eef6c7ac84ca964250155a6224d491c1365061bc974a9e1
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.9"
|
||||
dropdown_search:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: dropdown_search
|
||||
sha256: "55106e8290acaa97ed15bea1fdad82c3cf0c248dd410e651f5a8ac6870f783ab"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.0.6"
|
||||
equatable:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -134,6 +150,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "8.1.5"
|
||||
flutter_dotenv:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_dotenv
|
||||
sha256: "9357883bdd153ab78cbf9ffa07656e336b8bbb2b5a3ca596b0b27e119f7c7d77"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.1.0"
|
||||
flutter_lints:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
|
||||
@ -43,9 +43,13 @@ dependencies:
|
||||
get_it: ^7.6.7
|
||||
flutter_secure_storage: ^9.2.2
|
||||
shared_preferences: ^2.3.0
|
||||
dropdown_button2: ^2.3.9
|
||||
data_table_2: ^2.5.15
|
||||
go_router:
|
||||
intl: ^0.19.0
|
||||
dropdown_search: ^5.0.6
|
||||
flutter_dotenv: ^5.1.0
|
||||
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
@ -75,6 +79,9 @@ flutter:
|
||||
- assets/icons/
|
||||
- assets/images/
|
||||
- assets/
|
||||
- .env.development
|
||||
- .env.staging
|
||||
- .env.production
|
||||
|
||||
|
||||
# An image asset can refer to one or more resolution-specific "variants", see
|
||||
|
||||
Reference in New Issue
Block a user