mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-16 10:06:19 +00:00
Compare commits
18 Commits
SP-1717-FE
...
dev
Author | SHA1 | Date | |
---|---|---|---|
75b9f4a4e6 | |||
fe4063ef8f | |||
029b5d32e0 | |||
428c81efff | |||
288c252f46 | |||
7399dee687 | |||
08e2ed4b4c | |||
59e04708cd | |||
338d4f5737 | |||
5532935a3a | |||
249cbfc242 | |||
8167926620 | |||
559091faa0 | |||
eba351c9be | |||
65d541d594 | |||
2681c837f5 | |||
b6664ec1ba | |||
dcf1df9b4a |
@ -0,0 +1,170 @@
|
|||||||
|
import 'package:dio/dio.dart';
|
||||||
|
import 'package:syncrow_web/pages/access_management/booking_system/domain/models/calendar_event_booking.dart';
|
||||||
|
import 'package:syncrow_web/pages/access_management/booking_system/domain/services/calendar_system_service.dart';
|
||||||
|
import 'package:syncrow_web/services/api/api_exception.dart';
|
||||||
|
import 'package:syncrow_web/services/api/http_service.dart';
|
||||||
|
import 'package:syncrow_web/utils/constants/api_const.dart';
|
||||||
|
|
||||||
|
class RemoteCalendarService implements CalendarSystemService {
|
||||||
|
const RemoteCalendarService(this._httpService);
|
||||||
|
|
||||||
|
final HTTPService _httpService;
|
||||||
|
static const _defaultErrorMessage = 'Failed to load Calendar';
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<CalendarEventsResponse> getCalendarEvents({
|
||||||
|
required String spaceId,
|
||||||
|
}) async {
|
||||||
|
try {
|
||||||
|
final response = await _httpService.get(
|
||||||
|
path: ApiEndpoints.getCalendarEvents,
|
||||||
|
queryParameters: {
|
||||||
|
'spaceId': spaceId,
|
||||||
|
},
|
||||||
|
expectedResponseModel: (json) {
|
||||||
|
return CalendarEventsResponse.fromJson(
|
||||||
|
json as Map<String, dynamic>,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
return CalendarEventsResponse.fromJson(response as Map<String, dynamic>);
|
||||||
|
} on DioException catch (e) {
|
||||||
|
final responseData = e.response?.data;
|
||||||
|
if (responseData is Map<String, dynamic>) {
|
||||||
|
final errorMessage = responseData['error']?['message'] as String? ??
|
||||||
|
responseData['message'] as String? ??
|
||||||
|
_defaultErrorMessage;
|
||||||
|
throw APIException(errorMessage);
|
||||||
|
}
|
||||||
|
throw APIException(_defaultErrorMessage);
|
||||||
|
} catch (e) {
|
||||||
|
throw APIException('$_defaultErrorMessage: ${e.toString()}');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class FakeRemoteCalendarService implements CalendarSystemService {
|
||||||
|
const FakeRemoteCalendarService(this._httpService, {this.useDummy = false});
|
||||||
|
|
||||||
|
final HTTPService _httpService;
|
||||||
|
final bool useDummy;
|
||||||
|
static const _defaultErrorMessage = 'Failed to load Calendar';
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<CalendarEventsResponse> getCalendarEvents({
|
||||||
|
required String spaceId,
|
||||||
|
}) async {
|
||||||
|
if (useDummy) {
|
||||||
|
final dummyJson = {
|
||||||
|
'statusCode': 200,
|
||||||
|
'message': 'Successfully fetched all bookings',
|
||||||
|
'data': [
|
||||||
|
{
|
||||||
|
'uuid': 'd4553fa6-a0c9-4f42-81c9-99a13a57bf80',
|
||||||
|
'date': '2025-07-11T10:22:00.626Z',
|
||||||
|
'startTime': '09:00:00',
|
||||||
|
'endTime': '12:00:00',
|
||||||
|
'cost': 10,
|
||||||
|
'user': {
|
||||||
|
'uuid': '784394ff-3197-4c39-9f07-48dc44920b1e',
|
||||||
|
'firstName': 'salsabeel',
|
||||||
|
'lastName': 'abuzaid',
|
||||||
|
'email': 'test@test.com',
|
||||||
|
'companyName': null
|
||||||
|
},
|
||||||
|
'space': {
|
||||||
|
'uuid': '000f4d81-43e4-4ad7-865c-0f8b04b7081e',
|
||||||
|
'spaceName': '2(1)'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'uuid': 'e9b27af0-b963-4d98-9657-454c4ba78561',
|
||||||
|
'date': '2025-07-11T10:22:00.626Z',
|
||||||
|
'startTime': '12:00:00',
|
||||||
|
'endTime': '13:00:00',
|
||||||
|
'cost': 10,
|
||||||
|
'user': {
|
||||||
|
'uuid': '784394ff-3197-4c39-9f07-48dc44920b1e',
|
||||||
|
'firstName': 'salsabeel',
|
||||||
|
'lastName': 'abuzaid',
|
||||||
|
'email': 'test@test.com',
|
||||||
|
'companyName': null
|
||||||
|
},
|
||||||
|
'space': {
|
||||||
|
'uuid': '000f4d81-43e4-4ad7-865c-0f8b04b7081e',
|
||||||
|
'spaceName': '2(1)'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'uuid': 'e9b27af0-b963-4d98-9657-454c4ba78561',
|
||||||
|
'date': '2025-07-13T10:22:00.626Z',
|
||||||
|
'startTime': '15:30:00',
|
||||||
|
'endTime': '19:00:00',
|
||||||
|
'cost': 20,
|
||||||
|
'user': {
|
||||||
|
'uuid': '784394ff-3197-4c39-9f07-48dc44920b1e',
|
||||||
|
'firstName': 'salsabeel',
|
||||||
|
'lastName': 'abuzaid',
|
||||||
|
'email': 'test@test.com',
|
||||||
|
'companyName': null
|
||||||
|
},
|
||||||
|
'space': {
|
||||||
|
'uuid': '000f4d81-43e4-4ad7-865c-0f8b04b7081e',
|
||||||
|
'spaceName': '2(1)'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'success': true
|
||||||
|
};
|
||||||
|
final response = CalendarEventsResponse.fromJson(dummyJson);
|
||||||
|
|
||||||
|
// Filter events by spaceId
|
||||||
|
final filteredData = response.data.where((event) {
|
||||||
|
return event.space.uuid == spaceId;
|
||||||
|
}).toList();
|
||||||
|
print('Filtering events for spaceId: $spaceId');
|
||||||
|
print('Found ${filteredData.length} matching events');
|
||||||
|
return filteredData.isNotEmpty
|
||||||
|
? CalendarEventsResponse(
|
||||||
|
statusCode: response.statusCode,
|
||||||
|
message: response.message,
|
||||||
|
data: filteredData,
|
||||||
|
success: response.success,
|
||||||
|
)
|
||||||
|
: CalendarEventsResponse(
|
||||||
|
statusCode: 404,
|
||||||
|
message: 'No events found for spaceId: $spaceId',
|
||||||
|
data: [],
|
||||||
|
success: false,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await _httpService.get(
|
||||||
|
path: ApiEndpoints.getCalendarEvents,
|
||||||
|
queryParameters: {
|
||||||
|
'spaceId': spaceId,
|
||||||
|
},
|
||||||
|
expectedResponseModel: (json) {
|
||||||
|
return CalendarEventsResponse.fromJson(
|
||||||
|
json as Map<String, dynamic>,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
return CalendarEventsResponse.fromJson(response as Map<String, dynamic>);
|
||||||
|
} on DioException catch (e) {
|
||||||
|
final responseData = e.response?.data;
|
||||||
|
if (responseData is Map<String, dynamic>) {
|
||||||
|
final errorMessage = responseData['error']?['message'] as String? ??
|
||||||
|
responseData['message'] as String? ??
|
||||||
|
_defaultErrorMessage;
|
||||||
|
throw APIException(errorMessage);
|
||||||
|
}
|
||||||
|
throw APIException(_defaultErrorMessage);
|
||||||
|
} catch (e) {
|
||||||
|
throw APIException('$_defaultErrorMessage: ${e.toString()}');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,134 @@
|
|||||||
|
class CalendarEventBooking {
|
||||||
|
final String uuid;
|
||||||
|
final DateTime date;
|
||||||
|
final String startTime;
|
||||||
|
final String endTime;
|
||||||
|
final int cost;
|
||||||
|
final BookingUser user;
|
||||||
|
final BookingSpace space;
|
||||||
|
|
||||||
|
CalendarEventBooking({
|
||||||
|
required this.uuid,
|
||||||
|
required this.date,
|
||||||
|
required this.startTime,
|
||||||
|
required this.endTime,
|
||||||
|
required this.cost,
|
||||||
|
required this.user,
|
||||||
|
required this.space,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory CalendarEventBooking.fromJson(Map<String, dynamic> json) {
|
||||||
|
return CalendarEventBooking(
|
||||||
|
uuid: json['uuid'] as String? ?? '',
|
||||||
|
date: json['date'] != null
|
||||||
|
? DateTime.parse(json['date'] as String)
|
||||||
|
: DateTime.now(),
|
||||||
|
startTime: json['startTime'] as String? ?? '',
|
||||||
|
endTime: json['endTime'] as String? ?? '',
|
||||||
|
cost: _parseInt(json['cost']),
|
||||||
|
user: json['user'] != null
|
||||||
|
? BookingUser.fromJson(json['user'] as Map<String, dynamic>)
|
||||||
|
: BookingUser.empty(),
|
||||||
|
space: json['space'] != null
|
||||||
|
? BookingSpace.fromJson(json['space'] as Map<String, dynamic>)
|
||||||
|
: BookingSpace.empty(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int _parseInt(dynamic value) {
|
||||||
|
if (value is int) return value;
|
||||||
|
if (value is String) return int.tryParse(value) ?? 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class BookingUser {
|
||||||
|
final String uuid;
|
||||||
|
final String firstName;
|
||||||
|
final String lastName;
|
||||||
|
final String email;
|
||||||
|
final String? companyName;
|
||||||
|
|
||||||
|
BookingUser({
|
||||||
|
required this.uuid,
|
||||||
|
required this.firstName,
|
||||||
|
required this.lastName,
|
||||||
|
required this.email,
|
||||||
|
this.companyName,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory BookingUser.fromJson(Map<String, dynamic> json) {
|
||||||
|
return BookingUser(
|
||||||
|
uuid: json['uuid'] as String? ?? '',
|
||||||
|
firstName: json['firstName'] as String? ?? '',
|
||||||
|
lastName: json['lastName'] as String? ?? '',
|
||||||
|
email: json['email'] as String? ?? '',
|
||||||
|
companyName: json['companyName'] as String?,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
factory BookingUser.empty() {
|
||||||
|
return BookingUser(
|
||||||
|
uuid: '',
|
||||||
|
firstName: '',
|
||||||
|
lastName: '',
|
||||||
|
email: '',
|
||||||
|
companyName: null,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class BookingSpace {
|
||||||
|
final String uuid;
|
||||||
|
final String spaceName;
|
||||||
|
|
||||||
|
BookingSpace({
|
||||||
|
required this.uuid,
|
||||||
|
required this.spaceName,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory BookingSpace.fromJson(Map<String, dynamic> json) {
|
||||||
|
return BookingSpace(
|
||||||
|
uuid: json['uuid'] as String? ?? '',
|
||||||
|
spaceName: json['spaceName'] as String? ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
factory BookingSpace.empty() {
|
||||||
|
return BookingSpace(
|
||||||
|
uuid: '',
|
||||||
|
spaceName: '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class CalendarEventsResponse {
|
||||||
|
final int statusCode;
|
||||||
|
final String message;
|
||||||
|
final List<CalendarEventBooking> data;
|
||||||
|
final bool success;
|
||||||
|
|
||||||
|
CalendarEventsResponse({
|
||||||
|
required this.statusCode,
|
||||||
|
required this.message,
|
||||||
|
required this.data,
|
||||||
|
required this.success,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory CalendarEventsResponse.fromJson(Map<String, dynamic> json) {
|
||||||
|
return CalendarEventsResponse(
|
||||||
|
statusCode: _parseInt(json['statusCode']),
|
||||||
|
message: json['message'] as String? ?? '',
|
||||||
|
data: (json['data'] as List? ?? [])
|
||||||
|
.map((e) => CalendarEventBooking.fromJson(e as Map<String, dynamic>))
|
||||||
|
.toList(),
|
||||||
|
success: json['success'] as bool? ?? false,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int _parseInt(dynamic value) {
|
||||||
|
if (value is int) return value;
|
||||||
|
if (value is String) return int.tryParse(value) ?? 0;
|
||||||
|
return 0;
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
import 'package:syncrow_web/pages/access_management/booking_system/domain/models/calendar_event_booking.dart';
|
||||||
|
|
||||||
|
abstract class CalendarSystemService {
|
||||||
|
Future<CalendarEventsResponse> getCalendarEvents({
|
||||||
|
required String spaceId,
|
||||||
|
});
|
||||||
|
}
|
@ -2,13 +2,17 @@ import 'dart:async';
|
|||||||
import 'package:bloc/bloc.dart';
|
import 'package:bloc/bloc.dart';
|
||||||
import 'package:calendar_view/calendar_view.dart';
|
import 'package:calendar_view/calendar_view.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:syncrow_web/pages/access_management/booking_system/domain/models/calendar_event_booking.dart';
|
||||||
|
import 'package:syncrow_web/pages/access_management/booking_system/domain/services/calendar_system_service.dart';
|
||||||
|
|
||||||
part 'events_event.dart';
|
part 'events_event.dart';
|
||||||
part 'events_state.dart';
|
part 'events_state.dart';
|
||||||
|
|
||||||
class CalendarEventsBloc extends Bloc<CalendarEventsEvent, CalendarEventState> {
|
class CalendarEventsBloc extends Bloc<CalendarEventsEvent, CalendarEventState> {
|
||||||
final EventController eventController = EventController();
|
final EventController eventController = EventController();
|
||||||
|
final CalendarSystemService calendarService;
|
||||||
|
|
||||||
CalendarEventsBloc() : super(EventsInitial()) {
|
CalendarEventsBloc({required this.calendarService}) : super(EventsInitial()) {
|
||||||
on<LoadEvents>(_onLoadEvents);
|
on<LoadEvents>(_onLoadEvents);
|
||||||
on<AddEvent>(_onAddEvent);
|
on<AddEvent>(_onAddEvent);
|
||||||
on<StartTimer>(_onStartTimer);
|
on<StartTimer>(_onStartTimer);
|
||||||
@ -22,53 +26,24 @@ class CalendarEventsBloc extends Bloc<CalendarEventsEvent, CalendarEventState> {
|
|||||||
) async {
|
) async {
|
||||||
emit(EventsLoading());
|
emit(EventsLoading());
|
||||||
try {
|
try {
|
||||||
final events = _generateDummyEventsForWeek(event.weekStart);
|
final response = await calendarService.getCalendarEvents(
|
||||||
|
spaceId: event.spaceId,
|
||||||
|
);
|
||||||
|
final events =
|
||||||
|
response.data.map<CalendarEventData>(_toCalendarEventData).toList();
|
||||||
eventController.addAll(events);
|
eventController.addAll(events);
|
||||||
emit(EventsLoaded(
|
emit(EventsLoaded(events: events));
|
||||||
events: events,
|
|
||||||
initialDate: event.weekStart,
|
|
||||||
weekDays: _getWeekDays(event.weekStart),
|
|
||||||
));
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(EventsError('Failed to load events'));
|
emit(EventsError('Failed to load events'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<CalendarEventData> _generateDummyEventsForWeek(DateTime weekStart) {
|
|
||||||
final events = <CalendarEventData>[];
|
|
||||||
|
|
||||||
for (int i = 0; i < 7; i++) {
|
|
||||||
final date = weekStart.add(Duration(days: i));
|
|
||||||
|
|
||||||
events.add(CalendarEventData(
|
|
||||||
date: date,
|
|
||||||
startTime: date.copyWith(hour: 9, minute: 0),
|
|
||||||
endTime: date.copyWith(hour: 10, minute: 30),
|
|
||||||
title: 'Team Meeting',
|
|
||||||
description: 'Daily standup',
|
|
||||||
color: Colors.blue,
|
|
||||||
));
|
|
||||||
events.add(CalendarEventData(
|
|
||||||
date: date,
|
|
||||||
startTime: date.copyWith(hour: 14, minute: 0),
|
|
||||||
endTime: date.copyWith(hour: 15, minute: 0),
|
|
||||||
title: 'Client Call',
|
|
||||||
description: 'Project discussion',
|
|
||||||
color: Colors.green,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
return events;
|
|
||||||
}
|
|
||||||
|
|
||||||
void _onAddEvent(AddEvent event, Emitter<CalendarEventState> emit) {
|
void _onAddEvent(AddEvent event, Emitter<CalendarEventState> emit) {
|
||||||
eventController.add(event.event);
|
eventController.add(event.event);
|
||||||
if (state is EventsLoaded) {
|
if (state is EventsLoaded) {
|
||||||
final loaded = state as EventsLoaded;
|
final loaded = state as EventsLoaded;
|
||||||
emit(EventsLoaded(
|
emit(EventsLoaded(
|
||||||
events: [...eventController.events],
|
events: [...eventController.events],
|
||||||
initialDate: loaded.initialDate,
|
|
||||||
weekDays: loaded.weekDays,
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -86,47 +61,44 @@ class CalendarEventsBloc extends Bloc<CalendarEventsEvent, CalendarEventState> {
|
|||||||
final newWeekDays = _getWeekDays(event.weekDate);
|
final newWeekDays = _getWeekDays(event.weekDate);
|
||||||
emit(EventsLoaded(
|
emit(EventsLoaded(
|
||||||
events: loaded.events,
|
events: loaded.events,
|
||||||
initialDate: event.weekDate,
|
|
||||||
weekDays: newWeekDays,
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<CalendarEventData> _generateDummyEvents() {
|
CalendarEventData _toCalendarEventData(CalendarEventBooking booking) {
|
||||||
final now = DateTime.now();
|
final date = booking.date;
|
||||||
return [
|
|
||||||
CalendarEventData(
|
final localDate = date.toLocal();
|
||||||
date: now,
|
|
||||||
startTime: now.copyWith(hour: 8, minute: 00, second: 0),
|
final startParts = booking.startTime.split(':').map(int.parse).toList();
|
||||||
endTime: now.copyWith(hour: 9, minute: 00, second: 0),
|
final endParts = booking.endTime.split(':').map(int.parse).toList();
|
||||||
title: 'Team Meeting',
|
|
||||||
description: 'Weekly team sync',
|
final startTime = DateTime(
|
||||||
color: Colors.blue,
|
localDate.year,
|
||||||
),
|
localDate.month,
|
||||||
CalendarEventData(
|
localDate.day,
|
||||||
date: now,
|
startParts[0],
|
||||||
startTime: now.copyWith(hour: 9, minute: 00, second: 0),
|
startParts[1],
|
||||||
endTime: now.copyWith(hour: 10, minute: 30, second: 0),
|
);
|
||||||
title: 'Team Meeting',
|
|
||||||
description: 'Weekly team sync',
|
final endTime = DateTime(
|
||||||
color: Colors.blue,
|
localDate.year,
|
||||||
),
|
localDate.month,
|
||||||
CalendarEventData(
|
localDate.day,
|
||||||
date: now.add(const Duration(days: 1)),
|
endParts[0],
|
||||||
startTime: now.copyWith(hour: 14, day: now.day + 1),
|
endParts[1],
|
||||||
endTime: now.copyWith(hour: 15, day: now.day + 1),
|
);
|
||||||
title: 'Client Call',
|
|
||||||
description: 'Project discussion',
|
return CalendarEventData(
|
||||||
color: Colors.green,
|
date: startTime,
|
||||||
),
|
startTime: startTime,
|
||||||
CalendarEventData(
|
endTime: endTime,
|
||||||
date: now.add(const Duration(days: 2)),
|
title:
|
||||||
startTime: now.copyWith(hour: 11, day: now.day + 2),
|
'${booking.space.spaceName} - ${booking.user.firstName} ${booking.user.lastName}',
|
||||||
endTime: now.copyWith(hour: 12, day: now.day + 2),
|
description: 'Cost: ${booking.cost}',
|
||||||
title: 'Lunch with Team',
|
color: Colors.blue,
|
||||||
color: Colors.orange,
|
event: booking,
|
||||||
),
|
);
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<DateTime> _getWeekDays(DateTime date) {
|
List<DateTime> _getWeekDays(DateTime date) {
|
||||||
|
@ -6,13 +6,20 @@ abstract class CalendarEventsEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class LoadEvents extends CalendarEventsEvent {
|
class LoadEvents extends CalendarEventsEvent {
|
||||||
|
final String spaceId;
|
||||||
final DateTime weekStart;
|
final DateTime weekStart;
|
||||||
const LoadEvents({required this.weekStart});
|
final DateTime weekEnd;
|
||||||
|
|
||||||
|
const LoadEvents({
|
||||||
|
required this.spaceId,
|
||||||
|
required this.weekStart,
|
||||||
|
required this.weekEnd,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
class AddEvent extends CalendarEventsEvent {
|
class AddEvent extends CalendarEventsEvent {
|
||||||
final CalendarEventData event;
|
final CalendarEventData event;
|
||||||
AddEvent(this.event);
|
const AddEvent(this.event);
|
||||||
}
|
}
|
||||||
|
|
||||||
class StartTimer extends CalendarEventsEvent {}
|
class StartTimer extends CalendarEventsEvent {}
|
||||||
@ -23,3 +30,8 @@ class GoToWeek extends CalendarEventsEvent {
|
|||||||
final DateTime weekDate;
|
final DateTime weekDate;
|
||||||
GoToWeek(this.weekDate);
|
GoToWeek(this.weekDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class CheckWeekHasEvents extends CalendarEventsEvent {
|
||||||
|
final DateTime weekStart;
|
||||||
|
const CheckWeekHasEvents(this.weekStart);
|
||||||
|
}
|
||||||
|
@ -9,13 +9,9 @@ class EventsLoading extends CalendarEventState {}
|
|||||||
|
|
||||||
class EventsLoaded extends CalendarEventState {
|
class EventsLoaded extends CalendarEventState {
|
||||||
final List<CalendarEventData> events;
|
final List<CalendarEventData> events;
|
||||||
final DateTime initialDate;
|
|
||||||
final List<DateTime> weekDays;
|
|
||||||
|
|
||||||
EventsLoaded({
|
EventsLoaded({
|
||||||
required this.events,
|
required this.events,
|
||||||
required this.initialDate,
|
|
||||||
required this.weekDays,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:intl/intl.dart';
|
|
||||||
import 'package:calendar_view/calendar_view.dart';
|
import 'package:calendar_view/calendar_view.dart';
|
||||||
|
import 'package:syncrow_web/pages/access_management/booking_system/data/services/remote_calendar_service.dart';
|
||||||
|
import 'package:syncrow_web/pages/access_management/booking_system/presentation/bloc/calendar/events_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/access_management/booking_system/presentation/bloc/date_selection/date_selection_bloc.dart';
|
import 'package:syncrow_web/pages/access_management/booking_system/presentation/bloc/date_selection/date_selection_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/access_management/booking_system/presentation/bloc/date_selection/date_selection_event.dart';
|
import 'package:syncrow_web/pages/access_management/booking_system/presentation/bloc/date_selection/date_selection_event.dart';
|
||||||
import 'package:syncrow_web/pages/access_management/booking_system/presentation/bloc/date_selection/date_selection_state.dart';
|
import 'package:syncrow_web/pages/access_management/booking_system/presentation/bloc/date_selection/date_selection_state.dart';
|
||||||
@ -9,7 +10,9 @@ import 'package:syncrow_web/pages/access_management/booking_system/presentation/
|
|||||||
import 'package:syncrow_web/pages/access_management/booking_system/presentation/view/widgets/booking_sidebar.dart';
|
import 'package:syncrow_web/pages/access_management/booking_system/presentation/view/widgets/booking_sidebar.dart';
|
||||||
import 'package:syncrow_web/pages/access_management/booking_system/presentation/view/widgets/custom_calendar_page.dart';
|
import 'package:syncrow_web/pages/access_management/booking_system/presentation/view/widgets/custom_calendar_page.dart';
|
||||||
import 'package:syncrow_web/pages/access_management/booking_system/presentation/view/widgets/icon_text_button.dart';
|
import 'package:syncrow_web/pages/access_management/booking_system/presentation/view/widgets/icon_text_button.dart';
|
||||||
|
import 'package:syncrow_web/pages/access_management/booking_system/presentation/view/widgets/week_navigation.dart';
|
||||||
import 'package:syncrow_web/pages/access_management/booking_system/presentation/view/widgets/weekly_calendar_page.dart';
|
import 'package:syncrow_web/pages/access_management/booking_system/presentation/view/widgets/weekly_calendar_page.dart';
|
||||||
|
import 'package:syncrow_web/services/api/http_service.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
|
|
||||||
@ -35,33 +38,20 @@ class _BookingPageState extends State<BookingPage> {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<CalendarEventData> _generateDummyEventsForWeek(DateTime weekStart) {
|
void _dispatchLoadEvents(BuildContext context) {
|
||||||
final List<CalendarEventData> events = [];
|
final selectedRoom =
|
||||||
for (int i = 0; i < 7; i++) {
|
context.read<SelectedBookableSpaceBloc>().state.selectedBookableSpace;
|
||||||
final date = weekStart.add(Duration(days: i));
|
final dateState = context.read<DateSelectionBloc>().state;
|
||||||
events.add(CalendarEventData(
|
|
||||||
date: date,
|
|
||||||
startTime: date.copyWith(hour: 9, minute: 0),
|
|
||||||
endTime: date.copyWith(hour: 10, minute: 30),
|
|
||||||
title: 'Team Meeting',
|
|
||||||
description: 'Daily standup',
|
|
||||||
color: Colors.blue,
|
|
||||||
));
|
|
||||||
events.add(CalendarEventData(
|
|
||||||
date: date,
|
|
||||||
startTime: date.copyWith(hour: 14, minute: 0),
|
|
||||||
endTime: date.copyWith(hour: 15, minute: 0),
|
|
||||||
title: 'Client Call',
|
|
||||||
description: 'Project discussion',
|
|
||||||
color: Colors.green,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
return events;
|
|
||||||
}
|
|
||||||
|
|
||||||
void _loadEventsForWeek(DateTime weekStart) {
|
if (selectedRoom != null) {
|
||||||
_eventController.removeWhere((_) => true);
|
context.read<CalendarEventsBloc>().add(
|
||||||
_eventController.addAll(_generateDummyEventsForWeek(weekStart));
|
LoadEvents(
|
||||||
|
spaceId: selectedRoom.uuid,
|
||||||
|
weekStart: dateState.weekStart,
|
||||||
|
weekEnd: dateState.weekStart.add(const Duration(days: 6)),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -70,197 +60,181 @@ class _BookingPageState extends State<BookingPage> {
|
|||||||
providers: [
|
providers: [
|
||||||
BlocProvider(create: (_) => SelectedBookableSpaceBloc()),
|
BlocProvider(create: (_) => SelectedBookableSpaceBloc()),
|
||||||
BlocProvider(create: (_) => DateSelectionBloc()),
|
BlocProvider(create: (_) => DateSelectionBloc()),
|
||||||
|
BlocProvider(
|
||||||
|
create: (_) => CalendarEventsBloc(
|
||||||
|
calendarService:
|
||||||
|
FakeRemoteCalendarService(HTTPService(), useDummy: true),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
child: BlocListener<DateSelectionBloc, DateSelectionState>(
|
child: Builder(
|
||||||
listenWhen: (previous, current) =>
|
builder: (context) =>
|
||||||
previous.weekStart != current.weekStart,
|
BlocListener<CalendarEventsBloc, CalendarEventState>(
|
||||||
listener: (context, state) {
|
listenWhen: (prev, curr) => curr is EventsLoaded,
|
||||||
_loadEventsForWeek(state.weekStart);
|
listener: (context, state) {
|
||||||
},
|
if (state is EventsLoaded) {
|
||||||
child: Row(
|
_eventController.removeWhere((_) => true);
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
_eventController.addAll(state.events);
|
||||||
children: [
|
}
|
||||||
Expanded(
|
},
|
||||||
child: Container(
|
child: BlocListener<SelectedBookableSpaceBloc,
|
||||||
decoration: BoxDecoration(
|
SelectedBookableSpaceState>(
|
||||||
color: ColorsManager.whiteColors,
|
listener: (context, state) => _dispatchLoadEvents(context),
|
||||||
boxShadow: [
|
child: BlocListener<DateSelectionBloc, DateSelectionState>(
|
||||||
BoxShadow(
|
listener: (context, state) => _dispatchLoadEvents(context),
|
||||||
color: ColorsManager.blackColor.withOpacity(0.1),
|
child: Row(
|
||||||
offset: const Offset(3, 0),
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
blurRadius: 6,
|
children: [
|
||||||
spreadRadius: 0,
|
Expanded(
|
||||||
),
|
child: Container(
|
||||||
],
|
decoration: BoxDecoration(
|
||||||
),
|
color: ColorsManager.whiteColors,
|
||||||
child: Column(
|
boxShadow: [
|
||||||
children: [
|
BoxShadow(
|
||||||
Expanded(
|
color: ColorsManager.blackColor.withOpacity(0.1),
|
||||||
flex: 2,
|
offset: const Offset(3, 0),
|
||||||
child: BlocBuilder<SelectedBookableSpaceBloc,
|
blurRadius: 6,
|
||||||
SelectedBookableSpaceState>(
|
spreadRadius: 0,
|
||||||
builder: (context, state) {
|
),
|
||||||
return BookingSidebar(
|
],
|
||||||
onRoomSelected: (selectedRoom) {
|
),
|
||||||
context
|
child: Column(
|
||||||
.read<SelectedBookableSpaceBloc>()
|
children: [
|
||||||
.add(SelectBookableSpace(selectedRoom));
|
Expanded(
|
||||||
},
|
flex: 2,
|
||||||
);
|
child: BlocBuilder<SelectedBookableSpaceBloc,
|
||||||
},
|
SelectedBookableSpaceState>(
|
||||||
|
builder: (context, state) {
|
||||||
|
return BookingSidebar(
|
||||||
|
onRoomSelected: (selectedRoom) {
|
||||||
|
context
|
||||||
|
.read<SelectedBookableSpaceBloc>()
|
||||||
|
.add(SelectBookableSpace(selectedRoom));
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: BlocBuilder<DateSelectionBloc,
|
||||||
|
DateSelectionState>(
|
||||||
|
builder: (context, dateState) {
|
||||||
|
return CustomCalendarPage(
|
||||||
|
selectedDate: dateState.selectedDate,
|
||||||
|
onDateChanged: (day, month, year) {
|
||||||
|
final newDate = DateTime(year, month, day);
|
||||||
|
context
|
||||||
|
.read<DateSelectionBloc>()
|
||||||
|
.add(SelectDate(newDate));
|
||||||
|
context.read<DateSelectionBloc>().add(
|
||||||
|
SelectDateFromSidebarCalendar(newDate));
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
),
|
||||||
child: BlocBuilder<DateSelectionBloc, DateSelectionState>(
|
Expanded(
|
||||||
builder: (context, dateState) {
|
flex: 4,
|
||||||
return CustomCalendarPage(
|
child: Padding(
|
||||||
selectedDate: dateState.selectedDate,
|
padding: const EdgeInsets.all(20.0),
|
||||||
onDateChanged: (day, month, year) {
|
child: Column(
|
||||||
final newDate = DateTime(year, month, day);
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
context
|
children: [
|
||||||
.read<DateSelectionBloc>()
|
Row(
|
||||||
.add(SelectDate(newDate));
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
context
|
children: [
|
||||||
.read<DateSelectionBloc>()
|
Row(
|
||||||
.add(SelectDateFromSidebarCalendar(newDate));
|
children: [
|
||||||
},
|
SvgTextButton(
|
||||||
);
|
svgAsset: Assets.homeIcon,
|
||||||
},
|
label: 'Manage Bookable Spaces',
|
||||||
),
|
onPressed: () {},
|
||||||
),
|
),
|
||||||
],
|
const SizedBox(width: 20),
|
||||||
),
|
SvgTextButton(
|
||||||
),
|
svgAsset: Assets.groupIcon,
|
||||||
),
|
label: 'Manage Users',
|
||||||
Expanded(
|
onPressed: () {},
|
||||||
flex: 4,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(20.0),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
SvgTextButton(
|
|
||||||
svgAsset: Assets.homeIcon,
|
|
||||||
label: 'Manage Bookable Spaces',
|
|
||||||
onPressed: () {},
|
|
||||||
),
|
|
||||||
const SizedBox(width: 20),
|
|
||||||
SvgTextButton(
|
|
||||||
svgAsset: Assets.groupIcon,
|
|
||||||
label: 'Manage Users',
|
|
||||||
onPressed: () {},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
BlocBuilder<DateSelectionBloc, DateSelectionState>(
|
|
||||||
builder: (context, state) {
|
|
||||||
final weekStart = state.weekStart;
|
|
||||||
final weekEnd =
|
|
||||||
weekStart.add(const Duration(days: 6));
|
|
||||||
return Container(
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 10, vertical: 5),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: ColorsManager.circleRolesBackground,
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
boxShadow: const [
|
|
||||||
BoxShadow(
|
|
||||||
color: ColorsManager.lightGrayColor,
|
|
||||||
blurRadius: 4,
|
|
||||||
offset: Offset(0, 1),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
child: Row(
|
BlocBuilder<DateSelectionBloc,
|
||||||
children: [
|
DateSelectionState>(
|
||||||
IconButton(
|
builder: (context, state) {
|
||||||
iconSize: 15,
|
final weekStart = state.weekStart;
|
||||||
icon: const Icon(Icons.arrow_back_ios,
|
final weekEnd =
|
||||||
color: ColorsManager.lightGrayColor),
|
weekStart.add(const Duration(days: 6));
|
||||||
onPressed: () {
|
return WeekNavigation(
|
||||||
|
weekStart: weekStart,
|
||||||
|
weekEnd: weekEnd,
|
||||||
|
onPreviousWeek: () {
|
||||||
context
|
context
|
||||||
.read<DateSelectionBloc>()
|
.read<DateSelectionBloc>()
|
||||||
.add(PreviousWeek());
|
.add(PreviousWeek());
|
||||||
},
|
},
|
||||||
),
|
onNextWeek: () {
|
||||||
const SizedBox(width: 10),
|
|
||||||
Text(
|
|
||||||
_getMonthYearText(weekStart, weekEnd),
|
|
||||||
style: const TextStyle(
|
|
||||||
color: ColorsManager.lightGrayColor,
|
|
||||||
fontSize: 14,
|
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 10),
|
|
||||||
IconButton(
|
|
||||||
iconSize: 15,
|
|
||||||
icon: const Icon(Icons.arrow_forward_ios,
|
|
||||||
color: ColorsManager.lightGrayColor),
|
|
||||||
onPressed: () {
|
|
||||||
context
|
context
|
||||||
.read<DateSelectionBloc>()
|
.read<DateSelectionBloc>()
|
||||||
.add(NextWeek());
|
.add(NextWeek());
|
||||||
},
|
},
|
||||||
),
|
);
|
||||||
],
|
},
|
||||||
),
|
),
|
||||||
);
|
],
|
||||||
},
|
),
|
||||||
),
|
Expanded(
|
||||||
],
|
child: BlocBuilder<SelectedBookableSpaceBloc,
|
||||||
),
|
SelectedBookableSpaceState>(
|
||||||
Expanded(
|
builder: (context, roomState) {
|
||||||
child: BlocBuilder<SelectedBookableSpaceBloc,
|
final selectedRoom =
|
||||||
SelectedBookableSpaceState>(
|
roomState.selectedBookableSpace;
|
||||||
builder: (context, roomState) {
|
return BlocBuilder<DateSelectionBloc,
|
||||||
final selectedRoom = roomState.selectedBookableSpace;
|
DateSelectionState>(
|
||||||
return BlocBuilder<DateSelectionBloc,
|
builder: (context, dateState) {
|
||||||
DateSelectionState>(
|
return BlocListener<CalendarEventsBloc,
|
||||||
builder: (context, dateState) {
|
CalendarEventState>(
|
||||||
return WeeklyCalendarPage(
|
listenWhen: (prev, curr) =>
|
||||||
startTime:
|
curr is EventsLoaded,
|
||||||
selectedRoom?.bookableConfig.startTime,
|
listener: (context, state) {
|
||||||
endTime: selectedRoom?.bookableConfig.endTime,
|
if (state is EventsLoaded) {
|
||||||
weekStart: dateState.weekStart,
|
_eventController
|
||||||
selectedDate: dateState.selectedDate,
|
.removeWhere((_) => true);
|
||||||
eventController: _eventController,
|
_eventController.addAll(state.events);
|
||||||
selectedDateFromSideBarCalender: context
|
}
|
||||||
.watch<DateSelectionBloc>()
|
},
|
||||||
.state
|
child: WeeklyCalendarPage(
|
||||||
.selectedDateFromSideBarCalender,
|
startTime: selectedRoom
|
||||||
);
|
?.bookableConfig.startTime,
|
||||||
},
|
endTime: selectedRoom
|
||||||
);
|
?.bookableConfig.endTime,
|
||||||
},
|
weekStart: dateState.weekStart,
|
||||||
|
selectedDate: dateState.selectedDate,
|
||||||
|
eventController: _eventController,
|
||||||
|
selectedDateFromSideBarCalender: context
|
||||||
|
.watch<DateSelectionBloc>()
|
||||||
|
.state
|
||||||
|
.selectedDateFromSideBarCalender,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
String _getMonthYearText(DateTime start, DateTime end) {
|
|
||||||
final startMonth = DateFormat('MMM').format(start);
|
|
||||||
final endMonth = DateFormat('MMM').format(end);
|
|
||||||
final year = start.year == end.year
|
|
||||||
? start.year.toString()
|
|
||||||
: '${start.year}-${end.year}';
|
|
||||||
|
|
||||||
if (start.month == end.month) {
|
|
||||||
return '$startMonth $year';
|
|
||||||
} else {
|
|
||||||
return '$startMonth - $endMonth $year';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,60 @@
|
|||||||
|
import 'package:calendar_view/calendar_view.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
|
||||||
|
class EventTileWidget extends StatelessWidget {
|
||||||
|
final List<CalendarEventData<Object?>> events;
|
||||||
|
|
||||||
|
const EventTileWidget({
|
||||||
|
super.key,
|
||||||
|
required this.events,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
margin: const EdgeInsets.symmetric(vertical: 2, horizontal: 2),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: events.map((event) {
|
||||||
|
final bool isEventEnded =
|
||||||
|
event.endTime != null && event.endTime!.isBefore(DateTime.now());
|
||||||
|
return Expanded(
|
||||||
|
child: Container(
|
||||||
|
width: double.infinity,
|
||||||
|
padding: const EdgeInsets.all(6),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: isEventEnded
|
||||||
|
? ColorsManager.lightGrayBorderColor
|
||||||
|
: ColorsManager.blue1.withOpacity(0.25),
|
||||||
|
borderRadius: BorderRadius.circular(6),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
DateFormat('h:mm a').format(event.startTime!),
|
||||||
|
style: const TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 12,
|
||||||
|
color: Colors.black87,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 2),
|
||||||
|
Text(
|
||||||
|
event.title,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
color: ColorsManager.blackColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,91 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'dart:math' as math;
|
||||||
|
|
||||||
|
class HatchedColumnBackground extends StatelessWidget {
|
||||||
|
final Color backgroundColor;
|
||||||
|
final Color lineColor;
|
||||||
|
final double opacity;
|
||||||
|
final double stripeSpacing;
|
||||||
|
final BorderRadius? borderRadius;
|
||||||
|
|
||||||
|
const HatchedColumnBackground({
|
||||||
|
super.key,
|
||||||
|
required this.backgroundColor,
|
||||||
|
required this.lineColor,
|
||||||
|
this.opacity = 0.15,
|
||||||
|
this.stripeSpacing = 12,
|
||||||
|
this.borderRadius,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return CustomPaint(
|
||||||
|
painter: _HatchedBackgroundPainter(
|
||||||
|
backgroundColor: backgroundColor,
|
||||||
|
opacity: opacity,
|
||||||
|
lineColor: lineColor,
|
||||||
|
stripeSpacing: stripeSpacing,
|
||||||
|
borderRadius: borderRadius,
|
||||||
|
),
|
||||||
|
size: Size.infinite,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _HatchedBackgroundPainter extends CustomPainter {
|
||||||
|
final Color backgroundColor;
|
||||||
|
final double opacity;
|
||||||
|
final Color lineColor;
|
||||||
|
final double stripeSpacing;
|
||||||
|
final BorderRadius? borderRadius;
|
||||||
|
|
||||||
|
_HatchedBackgroundPainter({
|
||||||
|
required this.backgroundColor,
|
||||||
|
required this.opacity,
|
||||||
|
required this.lineColor,
|
||||||
|
required this.stripeSpacing,
|
||||||
|
this.borderRadius,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
void paint(Canvas canvas, Size size) {
|
||||||
|
final rect = Rect.fromLTWH(0, 0, size.width, size.height);
|
||||||
|
final RRect rrect = borderRadius?.toRRect(rect) ??
|
||||||
|
RRect.fromRectAndRadius(rect, Radius.zero);
|
||||||
|
final backgroundPaint = Paint()
|
||||||
|
..color = backgroundColor.withOpacity(0.02)
|
||||||
|
..style = PaintingStyle.fill;
|
||||||
|
canvas.drawRRect(rrect, backgroundPaint);
|
||||||
|
canvas.save();
|
||||||
|
canvas.clipRRect(rrect);
|
||||||
|
final linePaint = Paint()
|
||||||
|
..color = lineColor
|
||||||
|
..strokeWidth = 0.5
|
||||||
|
..style = PaintingStyle.stroke;
|
||||||
|
final maxExtent =
|
||||||
|
math.sqrt(size.width * size.width + size.height * size.height);
|
||||||
|
|
||||||
|
canvas.translate(0, size.height);
|
||||||
|
canvas.rotate(-math.pi / 4);
|
||||||
|
double y = -maxExtent;
|
||||||
|
while (y < maxExtent) {
|
||||||
|
canvas.drawLine(
|
||||||
|
Offset(-maxExtent, y),
|
||||||
|
Offset(maxExtent, y),
|
||||||
|
linePaint,
|
||||||
|
);
|
||||||
|
y += stripeSpacing;
|
||||||
|
}
|
||||||
|
|
||||||
|
canvas.restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool shouldRepaint(covariant _HatchedBackgroundPainter oldDelegate) {
|
||||||
|
return backgroundColor != oldDelegate.backgroundColor ||
|
||||||
|
opacity != oldDelegate.opacity ||
|
||||||
|
lineColor != oldDelegate.lineColor ||
|
||||||
|
stripeSpacing != oldDelegate.stripeSpacing ||
|
||||||
|
borderRadius != oldDelegate.borderRadius;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
|
||||||
|
class TimeLineWidget extends StatelessWidget {
|
||||||
|
final DateTime date;
|
||||||
|
|
||||||
|
const TimeLineWidget({Key? key, required this.date}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
int hour =
|
||||||
|
date.hour == 0 ? 12 : (date.hour > 12 ? date.hour - 12 : date.hour);
|
||||||
|
String period = date.hour >= 12 ? 'PM' : 'AM';
|
||||||
|
return Container(
|
||||||
|
height: 60,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: RichText(
|
||||||
|
text: TextSpan(
|
||||||
|
children: [
|
||||||
|
TextSpan(
|
||||||
|
text: '$hour',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
fontSize: 24,
|
||||||
|
color: ColorsManager.blackColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
WidgetSpan(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 2, top: 6),
|
||||||
|
child: Text(
|
||||||
|
period,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
fontSize: 12,
|
||||||
|
color: ColorsManager.blackColor,
|
||||||
|
letterSpacing: 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
alignment: PlaceholderAlignment.baseline,
|
||||||
|
baseline: TextBaseline.alphabetic,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
|
||||||
|
class WeekDayHeader extends StatelessWidget {
|
||||||
|
final DateTime date;
|
||||||
|
final bool isSelectedDay;
|
||||||
|
|
||||||
|
const WeekDayHeader({
|
||||||
|
Key? key,
|
||||||
|
required this.date,
|
||||||
|
required this.isSelectedDay,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
DateFormat('EEE').format(date).toUpperCase(),
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
fontSize: 14,
|
||||||
|
color: isSelectedDay ? Colors.blue : Colors.black,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
DateFormat('d').format(date),
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
fontSize: 20,
|
||||||
|
color:
|
||||||
|
isSelectedDay ? ColorsManager.blue1 : ColorsManager.blackColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,76 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
|
||||||
|
class WeekNavigation extends StatelessWidget {
|
||||||
|
final DateTime weekStart;
|
||||||
|
final DateTime weekEnd;
|
||||||
|
final VoidCallback onPreviousWeek;
|
||||||
|
final VoidCallback onNextWeek;
|
||||||
|
|
||||||
|
const WeekNavigation({
|
||||||
|
Key? key,
|
||||||
|
required this.weekStart,
|
||||||
|
required this.weekEnd,
|
||||||
|
required this.onPreviousWeek,
|
||||||
|
required this.onNextWeek,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: ColorsManager.circleRolesBackground,
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
boxShadow: const [
|
||||||
|
BoxShadow(
|
||||||
|
color: ColorsManager.lightGrayColor,
|
||||||
|
blurRadius: 4,
|
||||||
|
offset: Offset(0, 1),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
IconButton(
|
||||||
|
iconSize: 15,
|
||||||
|
icon: const Icon(Icons.arrow_back_ios,
|
||||||
|
color: ColorsManager.lightGrayColor),
|
||||||
|
onPressed: onPreviousWeek,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Text(
|
||||||
|
_getMonthYearText(weekStart, weekEnd),
|
||||||
|
style: const TextStyle(
|
||||||
|
color: ColorsManager.lightGrayColor,
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
IconButton(
|
||||||
|
iconSize: 15,
|
||||||
|
icon: const Icon(Icons.arrow_forward_ios,
|
||||||
|
color: ColorsManager.lightGrayColor),
|
||||||
|
onPressed: onNextWeek,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
String _getMonthYearText(DateTime start, DateTime end) {
|
||||||
|
final startMonth = DateFormat('MMM').format(start);
|
||||||
|
final endMonth = DateFormat('MMM').format(end);
|
||||||
|
final year = start.year == end.year
|
||||||
|
? start.year.toString()
|
||||||
|
: '${start.year}-${end.year}';
|
||||||
|
|
||||||
|
if (start.month == end.month) {
|
||||||
|
return '$startMonth $year';
|
||||||
|
} else {
|
||||||
|
return '$startMonth - $endMonth $year';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,9 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:calendar_view/calendar_view.dart';
|
import 'package:calendar_view/calendar_view.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:syncrow_web/pages/access_management/booking_system/presentation/view/widgets/event_tile_widget.dart';
|
||||||
|
import 'package:syncrow_web/pages/access_management/booking_system/presentation/view/widgets/hatched_column_background.dart';
|
||||||
|
import 'package:syncrow_web/pages/access_management/booking_system/presentation/view/widgets/time_line_widget.dart';
|
||||||
|
import 'package:syncrow_web/pages/access_management/booking_system/presentation/view/widgets/week_day_header.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
|
||||||
class WeeklyCalendarPage extends StatelessWidget {
|
class WeeklyCalendarPage extends StatelessWidget {
|
||||||
@ -60,18 +63,39 @@ class WeeklyCalendarPage extends StatelessWidget {
|
|||||||
|
|
||||||
const double timeLineWidth = 80;
|
const double timeLineWidth = 80;
|
||||||
const int totalDays = 7;
|
const int totalDays = 7;
|
||||||
|
final DateTime highlightStart = DateTime(2025, 7, 10);
|
||||||
|
final DateTime highlightEnd = DateTime(2025, 7, 19);
|
||||||
return LayoutBuilder(
|
return LayoutBuilder(
|
||||||
builder: (context, constraints) {
|
builder: (context, constraints) {
|
||||||
final double calendarWidth = constraints.maxWidth;
|
final double calendarWidth = constraints.maxWidth;
|
||||||
final double dayColumnWidth =
|
final double dayColumnWidth =
|
||||||
(calendarWidth - timeLineWidth) / totalDays - 0.1;
|
(calendarWidth - timeLineWidth) / totalDays - 0.1;
|
||||||
|
bool isInRange(DateTime date, DateTime start, DateTime end) {
|
||||||
|
return !date.isBefore(start) && !date.isAfter(end);
|
||||||
|
}
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.only(left: 25.0, right: 25.0, top: 25),
|
padding: const EdgeInsets.only(left: 25.0, right: 25.0, top: 25),
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
WeekView(
|
WeekView(
|
||||||
|
weekDetectorBuilder: ({
|
||||||
|
required date,
|
||||||
|
required height,
|
||||||
|
required heightPerMinute,
|
||||||
|
required minuteSlotSize,
|
||||||
|
required width,
|
||||||
|
}) {
|
||||||
|
return isInRange(date, highlightStart, highlightEnd)
|
||||||
|
? HatchedColumnBackground(
|
||||||
|
backgroundColor: ColorsManager.grey800,
|
||||||
|
lineColor: ColorsManager.textGray,
|
||||||
|
opacity: 0.3,
|
||||||
|
stripeSpacing: 12,
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
)
|
||||||
|
: const SizedBox();
|
||||||
|
},
|
||||||
pageViewPhysics: const NeverScrollableScrollPhysics(),
|
pageViewPhysics: const NeverScrollableScrollPhysics(),
|
||||||
key: ValueKey(weekStart),
|
key: ValueKey(weekStart),
|
||||||
controller: eventController,
|
controller: eventController,
|
||||||
@ -88,70 +112,13 @@ class WeeklyCalendarPage extends StatelessWidget {
|
|||||||
height: 0,
|
height: 0,
|
||||||
),
|
),
|
||||||
weekDayBuilder: (date) {
|
weekDayBuilder: (date) {
|
||||||
final index = weekDays.indexWhere((d) => isSameDay(d, date));
|
return WeekDayHeader(
|
||||||
final isSelectedDay = index == selectedDayIndex;
|
date: date,
|
||||||
return Column(
|
isSelectedDay: isSameDay(date, selectedDate),
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
DateFormat('EEE').format(date).toUpperCase(),
|
|
||||||
style: TextStyle(
|
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
fontSize: 14,
|
|
||||||
color: isSelectedDay ? Colors.blue : Colors.black,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
DateFormat('d').format(date),
|
|
||||||
style: TextStyle(
|
|
||||||
fontWeight: FontWeight.w700,
|
|
||||||
fontSize: 20,
|
|
||||||
color: isSelectedDay
|
|
||||||
? ColorsManager.blue1
|
|
||||||
: ColorsManager.blackColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
timeLineBuilder: (date) {
|
timeLineBuilder: (date) {
|
||||||
int hour = date.hour == 0
|
return TimeLineWidget(date: date);
|
||||||
? 12
|
|
||||||
: (date.hour > 12 ? date.hour - 12 : date.hour);
|
|
||||||
String period = date.hour >= 12 ? 'PM' : 'AM';
|
|
||||||
return Container(
|
|
||||||
height: 60,
|
|
||||||
alignment: Alignment.center,
|
|
||||||
child: RichText(
|
|
||||||
text: TextSpan(
|
|
||||||
children: [
|
|
||||||
TextSpan(
|
|
||||||
text: '$hour',
|
|
||||||
style: const TextStyle(
|
|
||||||
fontWeight: FontWeight.w700,
|
|
||||||
fontSize: 24,
|
|
||||||
color: ColorsManager.blackColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
WidgetSpan(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 2, top: 6),
|
|
||||||
child: Text(
|
|
||||||
period,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
fontSize: 12,
|
|
||||||
color: ColorsManager.blackColor,
|
|
||||||
letterSpacing: 1,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
alignment: PlaceholderAlignment.baseline,
|
|
||||||
baseline: TextBaseline.alphabetic,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
timeLineWidth: timeLineWidth,
|
timeLineWidth: timeLineWidth,
|
||||||
weekPageHeaderBuilder: (start, end) => Container(),
|
weekPageHeaderBuilder: (start, end) => Container(),
|
||||||
@ -174,49 +141,8 @@ class WeeklyCalendarPage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
eventTileBuilder: (date, events, boundary, start, end) {
|
eventTileBuilder: (date, events, boundary, start, end) {
|
||||||
return Container(
|
return EventTileWidget(
|
||||||
margin:
|
events: events,
|
||||||
const EdgeInsets.symmetric(vertical: 2, horizontal: 2),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: events.map((event) {
|
|
||||||
final bool isEventEnded = event.endTime != null &&
|
|
||||||
event.endTime!.isBefore(DateTime.now());
|
|
||||||
return Expanded(
|
|
||||||
child: Container(
|
|
||||||
width: double.infinity,
|
|
||||||
padding: const EdgeInsets.all(6),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: isEventEnded
|
|
||||||
? ColorsManager.lightGrayBorderColor
|
|
||||||
: ColorsManager.blue1.withOpacity(0.25),
|
|
||||||
borderRadius: BorderRadius.circular(6),
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
DateFormat('h:mm a').format(event.startTime!),
|
|
||||||
style: const TextStyle(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontSize: 12,
|
|
||||||
color: Colors.black87,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 2),
|
|
||||||
Text(
|
|
||||||
event.title,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
color: ColorsManager.blackColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}).toList(),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -132,6 +132,8 @@ class _DynamicTableState extends State<DynamicTable> {
|
|||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
controller: _horizontalScrollController,
|
controller: _horizontalScrollController,
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
|
physics:
|
||||||
|
widget.isEmpty ? const NeverScrollableScrollPhysics() : null,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: _totalTableWidth,
|
width: _totalTableWidth,
|
||||||
child: Column(
|
child: Column(
|
||||||
@ -164,7 +166,6 @@ class _DynamicTableState extends State<DynamicTable> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: widget.isEmpty
|
child: widget.isEmpty
|
||||||
? _buildEmptyState()
|
? _buildEmptyState()
|
||||||
@ -265,7 +266,7 @@ class _DynamicTableState extends State<DynamicTable> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox(height: widget.size.height * 0.5),
|
SizedBox(height: widget.size.height * 0.2),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -46,15 +46,15 @@ class DeviceManagementBloc
|
|||||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||||
|
|
||||||
if (spaceBloc.state.selectedCommunities.isEmpty) {
|
if (spaceBloc.state.selectedCommunities.isEmpty) {
|
||||||
devices = await DevicesManagementApi().fetchDevices('', '', projectUuid);
|
devices = await DevicesManagementApi().fetchDevices(
|
||||||
|
projectUuid,
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
for (final community in spaceBloc.state.selectedCommunities) {
|
for (var community in spaceBloc.state.selectedCommunities) {
|
||||||
final spacesList =
|
final spacesList =
|
||||||
spaceBloc.state.selectedCommunityAndSpaces[community] ?? [];
|
spaceBloc.state.selectedCommunityAndSpaces[community] ?? [];
|
||||||
for (final space in spacesList) {
|
devices.addAll(await DevicesManagementApi()
|
||||||
devices.addAll(await DevicesManagementApi()
|
.fetchDevices(projectUuid, spacesId: spacesList));
|
||||||
.fetchDevices(community, space, projectUuid));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,12 +24,12 @@ class DeviceManagementPage extends StatefulWidget with HelperResponsiveLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _DeviceManagementPageState extends State<DeviceManagementPage> {
|
class _DeviceManagementPageState extends State<DeviceManagementPage> {
|
||||||
|
@override
|
||||||
@override
|
|
||||||
void initState() {
|
void initState() {
|
||||||
context.read<SpaceTreeBloc>().add(InitialEvent());
|
context.read<SpaceTreeBloc>().add(InitialEvent());
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MultiBlocProvider(
|
return MultiBlocProvider(
|
||||||
@ -90,7 +90,7 @@ class _DeviceManagementPageState extends State<DeviceManagementPage> {
|
|||||||
const TriggerSwitchTabsEvent(isRoutineTab: true));
|
const TriggerSwitchTabsEvent(isRoutineTab: true));
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
'Routines',
|
'Workflow Automation',
|
||||||
style: context.textTheme.titleMedium?.copyWith(
|
style: context.textTheme.titleMedium?.copyWith(
|
||||||
color: state.routineTab
|
color: state.routineTab
|
||||||
? ColorsManager.whiteColors
|
? ColorsManager.whiteColors
|
||||||
|
@ -29,7 +29,9 @@ class CountdownModeButtons extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: DefaultButton(
|
child: DefaultButton(
|
||||||
|
elevation: 2.5,
|
||||||
height: 40,
|
height: 40,
|
||||||
|
borderRadius: 8,
|
||||||
onPressed: () => Navigator.pop(context),
|
onPressed: () => Navigator.pop(context),
|
||||||
backgroundColor: ColorsManager.boxColor,
|
backgroundColor: ColorsManager.boxColor,
|
||||||
child: Text('Cancel', style: context.textTheme.bodyMedium),
|
child: Text('Cancel', style: context.textTheme.bodyMedium),
|
||||||
@ -39,6 +41,8 @@ class CountdownModeButtons extends StatelessWidget {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: isActive
|
child: isActive
|
||||||
? DefaultButton(
|
? DefaultButton(
|
||||||
|
elevation: 2.5,
|
||||||
|
borderRadius: 8,
|
||||||
height: 40,
|
height: 40,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
context.read<ScheduleBloc>().add(
|
context.read<ScheduleBloc>().add(
|
||||||
@ -49,10 +53,12 @@ class CountdownModeButtons extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
backgroundColor: Colors.red,
|
backgroundColor: ColorsManager.red100,
|
||||||
child: const Text('Stop'),
|
child: const Text('Stop'),
|
||||||
)
|
)
|
||||||
: DefaultButton(
|
: DefaultButton(
|
||||||
|
elevation: 2.5,
|
||||||
|
borderRadius: 8,
|
||||||
height: 40,
|
height: 40,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
context.read<ScheduleBloc>().add(
|
context.read<ScheduleBloc>().add(
|
||||||
@ -63,7 +69,7 @@ class CountdownModeButtons extends StatelessWidget {
|
|||||||
countDownCode: countDownCode),
|
countDownCode: countDownCode),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
backgroundColor: ColorsManager.primaryColor,
|
backgroundColor: ColorsManager.primaryColorWithOpacity,
|
||||||
child: const Text('Save'),
|
child: const Text('Save'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -226,6 +226,7 @@ class _CountdownInchingViewState extends State<CountdownInchingView> {
|
|||||||
index.toString().padLeft(2, '0'),
|
index.toString().padLeft(2, '0'),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 24,
|
fontSize: 24,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
color: isActive ? ColorsManager.grayColor : Colors.black,
|
color: isActive ? ColorsManager.grayColor : Colors.black,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -240,7 +241,8 @@ class _CountdownInchingViewState extends State<CountdownInchingView> {
|
|||||||
label,
|
label,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color: ColorsManager.grayColor,
|
color: ColorsManager.grayColor,
|
||||||
fontSize: 18,
|
fontSize: 24,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -31,12 +31,11 @@ class BuildScheduleView extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (_) => ScheduleBloc(
|
create: (_) => ScheduleBloc(deviceId: deviceUuid,)
|
||||||
deviceId: deviceUuid,
|
|
||||||
)
|
|
||||||
..add(ScheduleGetEvent(category: category))
|
..add(ScheduleGetEvent(category: category))
|
||||||
..add(ScheduleFetchStatusEvent(
|
..add(ScheduleFetchStatusEvent(
|
||||||
deviceId: deviceUuid, countdownCode: countdownCode ?? '')),
|
deviceId: deviceUuid,
|
||||||
|
countdownCode: countdownCode ?? '')),
|
||||||
child: Dialog(
|
child: Dialog(
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
insetPadding: const EdgeInsets.all(20),
|
insetPadding: const EdgeInsets.all(20),
|
||||||
@ -77,7 +76,8 @@ class BuildScheduleView extends StatelessWidget {
|
|||||||
category: category,
|
category: category,
|
||||||
time: '',
|
time: '',
|
||||||
function: Status(
|
function: Status(
|
||||||
code: code.toString(), value: null),
|
code: code.toString(),
|
||||||
|
value: true),
|
||||||
days: [],
|
days: [],
|
||||||
),
|
),
|
||||||
isEdit: false,
|
isEdit: false,
|
||||||
|
@ -13,9 +13,9 @@ class ScheduleHeader extends StatelessWidget {
|
|||||||
Text(
|
Text(
|
||||||
'Scheduling',
|
'Scheduling',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
color: ColorsManager.primaryColorWithOpacity,
|
||||||
fontSize: 22,
|
fontWeight: FontWeight.w700,
|
||||||
color: ColorsManager.dialogBlueTitle,
|
fontSize: 30,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
|
@ -27,7 +27,7 @@ class ScheduleManagementUI extends StatelessWidget {
|
|||||||
width: 170,
|
width: 170,
|
||||||
height: 40,
|
height: 40,
|
||||||
child: DefaultButton(
|
child: DefaultButton(
|
||||||
borderColor: ColorsManager.boxColor,
|
borderColor: ColorsManager.grayColor.withOpacity(0.5),
|
||||||
padding: 2,
|
padding: 2,
|
||||||
backgroundColor: ColorsManager.graysColor,
|
backgroundColor: ColorsManager.graysColor,
|
||||||
borderRadius: 15,
|
borderRadius: 15,
|
||||||
|
@ -19,6 +19,8 @@ class ScheduleModeButtons extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: DefaultButton(
|
child: DefaultButton(
|
||||||
|
elevation: 2.5,
|
||||||
|
borderRadius: 8,
|
||||||
height: 40,
|
height: 40,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
@ -33,9 +35,11 @@ class ScheduleModeButtons extends StatelessWidget {
|
|||||||
const SizedBox(width: 20),
|
const SizedBox(width: 20),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: DefaultButton(
|
child: DefaultButton(
|
||||||
|
elevation: 2.5,
|
||||||
|
borderRadius: 8,
|
||||||
height: 40,
|
height: 40,
|
||||||
onPressed: onSave,
|
onPressed: onSave,
|
||||||
backgroundColor: ColorsManager.primaryColor,
|
backgroundColor: ColorsManager.primaryColorWithOpacity,
|
||||||
child: const Text('Save'),
|
child: const Text('Save'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -35,12 +35,12 @@ class ScheduleModeSelector extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
||||||
children: [
|
children: [
|
||||||
_buildRadioTile(
|
_buildRadioTile(
|
||||||
context, 'Countdown', ScheduleModes.countdown, currentMode),
|
context, 'Countdown', ScheduleModes.countdown, currentMode),
|
||||||
_buildRadioTile(
|
_buildRadioTile(
|
||||||
context, 'Schedule', ScheduleModes.schedule, currentMode),
|
context, 'Schedule', ScheduleModes.schedule, currentMode),
|
||||||
|
const Spacer(flex: 1),
|
||||||
// _buildRadioTile(
|
// _buildRadioTile(
|
||||||
// context, 'Circulate', ScheduleModes.circulate, currentMode),
|
// context, 'Circulate', ScheduleModes.circulate, currentMode),
|
||||||
// _buildRadioTile(
|
// _buildRadioTile(
|
||||||
@ -65,6 +65,7 @@ class ScheduleModeSelector extends StatelessWidget {
|
|||||||
style: context.textTheme.bodySmall!.copyWith(
|
style: context.textTheme.bodySmall!.copyWith(
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
color: ColorsManager.blackColor,
|
color: ColorsManager.blackColor,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
leading: Radio<ScheduleModes>(
|
leading: Radio<ScheduleModes>(
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:syncrow_web/pages/device_managment/schedule_device/schedule_widgets/schedule_mode_buttons.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/water_heater/models/schedule_entry.dart';
|
import 'package:syncrow_web/pages/device_managment/water_heater/models/schedule_entry.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart';
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart';
|
||||||
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
|
||||||
class ScheduleDialogHelper {
|
class ScheduleDialogHelper {
|
||||||
static const List<String> allDays = [
|
static const List<String> allDays = [
|
||||||
@ -56,8 +58,9 @@ class ScheduleDialogHelper {
|
|||||||
Text(
|
Text(
|
||||||
isEdit ? 'Edit Schedule' : 'Add Schedule',
|
isEdit ? 'Edit Schedule' : 'Add Schedule',
|
||||||
style: Theme.of(context).textTheme.titleLarge!.copyWith(
|
style: Theme.of(context).textTheme.titleLarge!.copyWith(
|
||||||
color: Colors.blue,
|
color: ColorsManager.primaryColorWithOpacity,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.w700,
|
||||||
|
fontSize: 30,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(),
|
const SizedBox(),
|
||||||
@ -69,9 +72,9 @@ class ScheduleDialogHelper {
|
|||||||
height: 40,
|
height: 40,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: Colors.grey[200],
|
backgroundColor: ColorsManager.boxColor,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(15),
|
borderRadius: BorderRadius.circular(8),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
@ -110,39 +113,27 @@ class ScheduleDialogHelper {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
SizedBox(
|
ScheduleModeButtons(
|
||||||
width: 100,
|
onSave: () {
|
||||||
child: OutlinedButton(
|
dynamic temp;
|
||||||
onPressed: () {
|
if (deviceType == 'CUR_2') {
|
||||||
Navigator.pop(ctx, null);
|
temp = functionOn! ? 'open' : 'close';
|
||||||
},
|
} else {
|
||||||
child: const Text('Cancel'),
|
temp = functionOn;
|
||||||
),
|
}
|
||||||
|
final entry = ScheduleEntry(
|
||||||
|
category: schedule?.category ?? 'switch_1',
|
||||||
|
time: _formatTimeOfDayToISO(selectedTime),
|
||||||
|
function: Status(
|
||||||
|
code: code ?? 'switch_1',
|
||||||
|
value: temp,
|
||||||
|
),
|
||||||
|
days: _convertSelectedDaysToStrings(selectedDays),
|
||||||
|
scheduleId: schedule.scheduleId,
|
||||||
|
);
|
||||||
|
Navigator.pop(ctx, entry);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
SizedBox(
|
|
||||||
width: 100,
|
|
||||||
child: ElevatedButton(
|
|
||||||
onPressed: () {
|
|
||||||
dynamic temp;
|
|
||||||
if (deviceType == 'CUR_2') {
|
|
||||||
temp = functionOn! ? 'open' : 'close';
|
|
||||||
} else {
|
|
||||||
temp = functionOn;
|
|
||||||
}
|
|
||||||
final entry = ScheduleEntry(
|
|
||||||
category: schedule?.category ?? 'switch_1',
|
|
||||||
time: _formatTimeOfDayToISO(selectedTime),
|
|
||||||
function: Status(
|
|
||||||
code: code ?? 'switch_1',
|
|
||||||
value: temp,
|
|
||||||
),
|
|
||||||
days: _convertSelectedDaysToStrings(selectedDays),
|
|
||||||
scheduleId: schedule.scheduleId,
|
|
||||||
);
|
|
||||||
Navigator.pop(ctx, entry);
|
|
||||||
},
|
|
||||||
child: const Text('Save'),
|
|
||||||
)),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -153,6 +153,7 @@ class EditUserModel {
|
|||||||
final String? jobTitle; // can be empty
|
final String? jobTitle; // can be empty
|
||||||
final String roleType; // e.g. "ADMIN"
|
final String roleType; // e.g. "ADMIN"
|
||||||
final List<UserSpaceModel> spaces;
|
final List<UserSpaceModel> spaces;
|
||||||
|
final String? companyName;
|
||||||
|
|
||||||
EditUserModel({
|
EditUserModel({
|
||||||
required this.uuid,
|
required this.uuid,
|
||||||
@ -167,6 +168,7 @@ class EditUserModel {
|
|||||||
required this.jobTitle,
|
required this.jobTitle,
|
||||||
required this.roleType,
|
required this.roleType,
|
||||||
required this.spaces,
|
required this.spaces,
|
||||||
|
this.companyName,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// Create a [UserData] from JSON data
|
/// Create a [UserData] from JSON data
|
||||||
@ -182,6 +184,7 @@ class EditUserModel {
|
|||||||
invitedBy: json['invitedBy'] as String,
|
invitedBy: json['invitedBy'] as String,
|
||||||
phoneNumber: json['phoneNumber'] ?? '',
|
phoneNumber: json['phoneNumber'] ?? '',
|
||||||
jobTitle: json['jobTitle'] ?? '',
|
jobTitle: json['jobTitle'] ?? '',
|
||||||
|
companyName: json['companyName'] as String?,
|
||||||
roleType: json['roleType'] as String,
|
roleType: json['roleType'] as String,
|
||||||
spaces: (json['spaces'] as List<dynamic>)
|
spaces: (json['spaces'] as List<dynamic>)
|
||||||
.map((e) => UserSpaceModel.fromJson(e as Map<String, dynamic>))
|
.map((e) => UserSpaceModel.fromJson(e as Map<String, dynamic>))
|
||||||
|
@ -12,7 +12,7 @@ class RolesUserModel {
|
|||||||
final dynamic jobTitle;
|
final dynamic jobTitle;
|
||||||
final dynamic createdDate;
|
final dynamic createdDate;
|
||||||
final dynamic createdTime;
|
final dynamic createdTime;
|
||||||
|
final String? companyName;
|
||||||
RolesUserModel({
|
RolesUserModel({
|
||||||
required this.uuid,
|
required this.uuid,
|
||||||
required this.createdAt,
|
required this.createdAt,
|
||||||
@ -27,6 +27,7 @@ class RolesUserModel {
|
|||||||
this.jobTitle,
|
this.jobTitle,
|
||||||
required this.createdDate,
|
required this.createdDate,
|
||||||
required this.createdTime,
|
required this.createdTime,
|
||||||
|
this.companyName,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory RolesUserModel.fromJson(Map<String, dynamic> json) {
|
factory RolesUserModel.fromJson(Map<String, dynamic> json) {
|
||||||
@ -47,6 +48,7 @@ class RolesUserModel {
|
|||||||
: json['jobTitle'],
|
: json['jobTitle'],
|
||||||
createdDate: json['createdDate'],
|
createdDate: json['createdDate'],
|
||||||
createdTime: json['createdTime'],
|
createdTime: json['createdTime'],
|
||||||
|
companyName: json['companyName'] as String?,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ class UsersBloc extends Bloc<UsersEvent, UsersState> {
|
|||||||
final TextEditingController lastNameController = TextEditingController();
|
final TextEditingController lastNameController = TextEditingController();
|
||||||
final TextEditingController emailController = TextEditingController();
|
final TextEditingController emailController = TextEditingController();
|
||||||
final TextEditingController phoneController = TextEditingController();
|
final TextEditingController phoneController = TextEditingController();
|
||||||
final TextEditingController jobTitleController = TextEditingController();
|
final TextEditingController companyNameController = TextEditingController();
|
||||||
final TextEditingController roleSearchController = TextEditingController();
|
final TextEditingController roleSearchController = TextEditingController();
|
||||||
|
|
||||||
bool? isCompleteBasics;
|
bool? isCompleteBasics;
|
||||||
@ -352,7 +352,7 @@ class UsersBloc extends Bloc<UsersEvent, UsersState> {
|
|||||||
bool res = await UserPermissionApi().sendInviteUser(
|
bool res = await UserPermissionApi().sendInviteUser(
|
||||||
email: emailController.text,
|
email: emailController.text,
|
||||||
firstName: firstNameController.text,
|
firstName: firstNameController.text,
|
||||||
jobTitle: jobTitleController.text,
|
companyName: companyNameController.text,
|
||||||
lastName: lastNameController.text,
|
lastName: lastNameController.text,
|
||||||
phoneNumber: phoneController.text,
|
phoneNumber: phoneController.text,
|
||||||
roleUuid: roleSelected,
|
roleUuid: roleSelected,
|
||||||
@ -405,7 +405,7 @@ class UsersBloc extends Bloc<UsersEvent, UsersState> {
|
|||||||
bool res = await UserPermissionApi().editInviteUser(
|
bool res = await UserPermissionApi().editInviteUser(
|
||||||
userId: event.userId,
|
userId: event.userId,
|
||||||
firstName: firstNameController.text,
|
firstName: firstNameController.text,
|
||||||
jobTitle: jobTitleController.text,
|
companyName: companyNameController.text,
|
||||||
lastName: lastNameController.text,
|
lastName: lastNameController.text,
|
||||||
phoneNumber: phoneController.text,
|
phoneNumber: phoneController.text,
|
||||||
roleUuid: roleSelected,
|
roleUuid: roleSelected,
|
||||||
@ -455,7 +455,7 @@ class UsersBloc extends Bloc<UsersEvent, UsersState> {
|
|||||||
Future<void> checkEmail(
|
Future<void> checkEmail(
|
||||||
CheckEmailEvent event, Emitter<UsersState> emit) async {
|
CheckEmailEvent event, Emitter<UsersState> emit) async {
|
||||||
emit(UsersLoadingState());
|
emit(UsersLoadingState());
|
||||||
String? res = await UserPermissionApi().checkEmail(
|
String? res = await UserPermissionApi().checkEmail(
|
||||||
emailController.text,
|
emailController.text,
|
||||||
);
|
);
|
||||||
checkEmailValid = res!;
|
checkEmailValid = res!;
|
||||||
@ -529,7 +529,7 @@ class UsersBloc extends Bloc<UsersEvent, UsersState> {
|
|||||||
lastNameController.text = res.lastName;
|
lastNameController.text = res.lastName;
|
||||||
emailController.text = res.email;
|
emailController.text = res.email;
|
||||||
phoneController.text = res.phoneNumber ?? '';
|
phoneController.text = res.phoneNumber ?? '';
|
||||||
jobTitleController.text = res.jobTitle ?? '';
|
companyNameController.text = res.companyName ?? '';
|
||||||
res.roleType;
|
res.roleType;
|
||||||
res.spaces.map((space) {
|
res.spaces.map((space) {
|
||||||
selectedIds.add(space.uuid);
|
selectedIds.add(space.uuid);
|
||||||
@ -645,7 +645,7 @@ class UsersBloc extends Bloc<UsersEvent, UsersState> {
|
|||||||
lastNameController.dispose();
|
lastNameController.dispose();
|
||||||
emailController.dispose();
|
emailController.dispose();
|
||||||
phoneController.dispose();
|
phoneController.dispose();
|
||||||
jobTitleController.dispose();
|
companyNameController.dispose();
|
||||||
roleSearchController.dispose();
|
roleSearchController.dispose();
|
||||||
return super.close();
|
return super.close();
|
||||||
}
|
}
|
||||||
|
@ -317,7 +317,7 @@ class BasicsView extends StatelessWidget {
|
|||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'Job Title',
|
'Company Name',
|
||||||
style: context.textTheme.bodyMedium?.copyWith(
|
style: context.textTheme.bodyMedium?.copyWith(
|
||||||
fontWeight: FontWeight.w400,
|
fontWeight: FontWeight.w400,
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
@ -328,11 +328,11 @@ class BasicsView extends StatelessWidget {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
controller: _blocRole.jobTitleController,
|
controller: _blocRole.companyNameController,
|
||||||
style:
|
style:
|
||||||
const TextStyle(color: ColorsManager.blackColor),
|
const TextStyle(color: ColorsManager.blackColor),
|
||||||
decoration: inputTextFormDeco(
|
decoration: inputTextFormDeco(
|
||||||
hintText: "Job Title (Optional)")
|
hintText: 'Company Name (Optional)')
|
||||||
.copyWith(
|
.copyWith(
|
||||||
hintStyle: context.textTheme.bodyMedium?.copyWith(
|
hintStyle: context.textTheme.bodyMedium?.copyWith(
|
||||||
fontWeight: FontWeight.w400,
|
fontWeight: FontWeight.w400,
|
||||||
|
@ -411,7 +411,7 @@ class UsersPage extends StatelessWidget {
|
|||||||
titles: const [
|
titles: const [
|
||||||
"Full Name",
|
"Full Name",
|
||||||
"Email Address",
|
"Email Address",
|
||||||
"Job Title",
|
"Company Name",
|
||||||
"Role",
|
"Role",
|
||||||
"Creation Date",
|
"Creation Date",
|
||||||
"Creation Time",
|
"Creation Time",
|
||||||
@ -424,7 +424,7 @@ class UsersPage extends StatelessWidget {
|
|||||||
return [
|
return [
|
||||||
Text('${user.firstName} ${user.lastName}'),
|
Text('${user.firstName} ${user.lastName}'),
|
||||||
Text(user.email),
|
Text(user.email),
|
||||||
Text(user.jobTitle),
|
Center(child: Text(user.companyName ?? '-')),
|
||||||
Text(user.roleType ?? ''),
|
Text(user.roleType ?? ''),
|
||||||
Text(user.createdDate ?? ''),
|
Text(user.createdDate ?? ''),
|
||||||
Text(user.createdTime ?? ''),
|
Text(user.createdTime ?? ''),
|
||||||
|
@ -170,45 +170,45 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onLoadScenes(
|
Future<void> _onLoadScenes(
|
||||||
LoadScenes event, Emitter<RoutineState> emit) async {
|
LoadScenes event, Emitter<RoutineState> emit) async {
|
||||||
emit(state.copyWith(isLoading: true, errorMessage: null));
|
emit(state.copyWith(isLoading: true, errorMessage: null));
|
||||||
List<ScenesModel> scenes = [];
|
List<ScenesModel> scenes = [];
|
||||||
try {
|
try {
|
||||||
BuildContext context = NavigationService.navigatorKey.currentContext!;
|
BuildContext context = NavigationService.navigatorKey.currentContext!;
|
||||||
var createRoutineBloc = context.read<CreateRoutineBloc>();
|
var createRoutineBloc = context.read<CreateRoutineBloc>();
|
||||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||||
if (createRoutineBloc.selectedSpaceId == '' &&
|
if (createRoutineBloc.selectedSpaceId == '' &&
|
||||||
createRoutineBloc.selectedCommunityId == '') {
|
createRoutineBloc.selectedCommunityId == '') {
|
||||||
var spaceBloc = context.read<SpaceTreeBloc>();
|
var spaceBloc = context.read<SpaceTreeBloc>();
|
||||||
for (var communityId in spaceBloc.state.selectedCommunities) {
|
for (var communityId in spaceBloc.state.selectedCommunities) {
|
||||||
List<String> spacesList =
|
List<String> spacesList =
|
||||||
spaceBloc.state.selectedCommunityAndSpaces[communityId] ?? [];
|
spaceBloc.state.selectedCommunityAndSpaces[communityId] ?? [];
|
||||||
for (var spaceId in spacesList) {
|
for (var spaceId in spacesList) {
|
||||||
scenes.addAll(
|
scenes.addAll(
|
||||||
await SceneApi.getScenes(spaceId, communityId, projectUuid));
|
await SceneApi.getScenes(spaceId, communityId, projectUuid));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
scenes.addAll(await SceneApi.getScenes(
|
||||||
|
createRoutineBloc.selectedSpaceId,
|
||||||
|
createRoutineBloc.selectedCommunityId,
|
||||||
|
projectUuid));
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
scenes.addAll(await SceneApi.getScenes(
|
|
||||||
createRoutineBloc.selectedSpaceId,
|
|
||||||
createRoutineBloc.selectedCommunityId,
|
|
||||||
projectUuid));
|
|
||||||
}
|
|
||||||
|
|
||||||
emit(state.copyWith(
|
emit(state.copyWith(
|
||||||
scenes: scenes,
|
scenes: scenes,
|
||||||
isLoading: false,
|
|
||||||
));
|
|
||||||
} catch (e) {
|
|
||||||
emit(state.copyWith(
|
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
loadScenesErrorMessage: 'Failed to load scenes',
|
));
|
||||||
errorMessage: '',
|
} catch (e) {
|
||||||
loadAutomationErrorMessage: '',
|
emit(state.copyWith(
|
||||||
scenes: scenes));
|
isLoading: false,
|
||||||
|
loadScenesErrorMessage: 'Failed to load scenes',
|
||||||
|
errorMessage: '',
|
||||||
|
loadAutomationErrorMessage: '',
|
||||||
|
scenes: scenes));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _onLoadAutomation(
|
Future<void> _onLoadAutomation(
|
||||||
LoadAutomation event, Emitter<RoutineState> emit) async {
|
LoadAutomation event, Emitter<RoutineState> emit) async {
|
||||||
@ -936,16 +936,15 @@ Future<void> _onLoadScenes(
|
|||||||
for (var communityId in spaceBloc.state.selectedCommunities) {
|
for (var communityId in spaceBloc.state.selectedCommunities) {
|
||||||
List<String> spacesList =
|
List<String> spacesList =
|
||||||
spaceBloc.state.selectedCommunityAndSpaces[communityId] ?? [];
|
spaceBloc.state.selectedCommunityAndSpaces[communityId] ?? [];
|
||||||
for (var spaceId in spacesList) {
|
|
||||||
devices.addAll(await DevicesManagementApi()
|
devices.addAll(await DevicesManagementApi()
|
||||||
.fetchDevices(communityId, spaceId, projectUuid));
|
.fetchDevices(projectUuid, spacesId: spacesList));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
devices.addAll(await DevicesManagementApi().fetchDevices(
|
devices.addAll(await DevicesManagementApi().fetchDevices(
|
||||||
createRoutineBloc.selectedCommunityId,
|
projectUuid,
|
||||||
createRoutineBloc.selectedSpaceId,
|
spacesId: [createRoutineBloc.selectedSpaceId],
|
||||||
projectUuid));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
emit(state.copyWith(isLoading: false, devices: devices));
|
emit(state.copyWith(isLoading: false, devices: devices));
|
||||||
|
@ -96,9 +96,7 @@ class _WallPresenceSensorState extends State<FlushPresenceSensor> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
DialogHeader(widget.dialogType == 'THEN'
|
const DialogHeader('Presence Sensor'),
|
||||||
? 'Presence Sensor Functions'
|
|
||||||
: 'Presence Sensor Condition'),
|
|
||||||
Expanded(child: _buildMainContent(context, state)),
|
Expanded(child: _buildMainContent(context, state)),
|
||||||
_buildDialogFooter(context, state),
|
_buildDialogFooter(context, state),
|
||||||
],
|
],
|
||||||
|
@ -12,20 +12,16 @@ import 'package:syncrow_web/services/api/http_service.dart';
|
|||||||
import 'package:syncrow_web/utils/constants/api_const.dart';
|
import 'package:syncrow_web/utils/constants/api_const.dart';
|
||||||
|
|
||||||
class DevicesManagementApi {
|
class DevicesManagementApi {
|
||||||
Future<List<AllDevicesModel>> fetchDevices(
|
Future<List<AllDevicesModel>> fetchDevices(String projectId,
|
||||||
String communityId, String spaceId, String projectId) async {
|
{List<String>? spacesId}) async {
|
||||||
try {
|
try {
|
||||||
final response = await HTTPService().get(
|
final response = await HTTPService().get(
|
||||||
path: communityId.isNotEmpty && spaceId.isNotEmpty
|
path: ApiEndpoints.getSpaceDevices.replaceAll('{projectId}', projectId),
|
||||||
? ApiEndpoints.getSpaceDevices
|
queryParameters: {if (spacesId != null) 'spaces': spacesId},
|
||||||
.replaceAll('{spaceUuid}', spaceId)
|
|
||||||
.replaceAll('{communityUuid}', communityId)
|
|
||||||
.replaceAll('{projectId}', projectId)
|
|
||||||
: ApiEndpoints.getAllDevices.replaceAll('{projectId}', projectId),
|
|
||||||
showServerMessage: true,
|
showServerMessage: true,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
List<dynamic> jsonData = json['data'];
|
final List<dynamic> jsonData = json['data'] as List<dynamic>;
|
||||||
List<AllDevicesModel> devicesList = jsonData.map((jsonItem) {
|
final List<AllDevicesModel> devicesList = jsonData.map((jsonItem) {
|
||||||
return AllDevicesModel.fromJson(jsonItem);
|
return AllDevicesModel.fromJson(jsonItem);
|
||||||
}).toList();
|
}).toList();
|
||||||
return devicesList;
|
return devicesList;
|
||||||
@ -416,5 +412,4 @@ class DevicesManagementApi {
|
|||||||
);
|
);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,8 +34,9 @@ class UserPermissionApi {
|
|||||||
path: ApiEndpoints.roleTypes,
|
path: ApiEndpoints.roleTypes,
|
||||||
showServerMessage: true,
|
showServerMessage: true,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
final List<RoleTypeModel> fetchedRoles =
|
final List<RoleTypeModel> fetchedRoles = (json['data'] as List)
|
||||||
(json['data'] as List).map((item) => RoleTypeModel.fromJson(item)).toList();
|
.map((item) => RoleTypeModel.fromJson(item))
|
||||||
|
.toList();
|
||||||
return fetchedRoles;
|
return fetchedRoles;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -47,7 +48,9 @@ class UserPermissionApi {
|
|||||||
path: ApiEndpoints.permission.replaceAll("roleUuid", roleUuid),
|
path: ApiEndpoints.permission.replaceAll("roleUuid", roleUuid),
|
||||||
showServerMessage: true,
|
showServerMessage: true,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
return (json as List).map((data) => PermissionOption.fromJson(data)).toList();
|
return (json as List)
|
||||||
|
.map((data) => PermissionOption.fromJson(data))
|
||||||
|
.toList();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
return response ?? [];
|
return response ?? [];
|
||||||
@ -57,7 +60,7 @@ class UserPermissionApi {
|
|||||||
String? firstName,
|
String? firstName,
|
||||||
String? lastName,
|
String? lastName,
|
||||||
String? email,
|
String? email,
|
||||||
String? jobTitle,
|
String? companyName,
|
||||||
String? phoneNumber,
|
String? phoneNumber,
|
||||||
String? roleUuid,
|
String? roleUuid,
|
||||||
List<String>? spaceUuids,
|
List<String>? spaceUuids,
|
||||||
@ -68,7 +71,7 @@ class UserPermissionApi {
|
|||||||
"firstName": firstName,
|
"firstName": firstName,
|
||||||
"lastName": lastName,
|
"lastName": lastName,
|
||||||
"email": email,
|
"email": email,
|
||||||
"jobTitle": jobTitle != '' ? jobTitle : null,
|
"companyName": companyName != '' ? companyName : null,
|
||||||
"phoneNumber": phoneNumber != '' ? phoneNumber : null,
|
"phoneNumber": phoneNumber != '' ? phoneNumber : null,
|
||||||
"roleUuid": roleUuid,
|
"roleUuid": roleUuid,
|
||||||
"projectUuid": projectUuid,
|
"projectUuid": projectUuid,
|
||||||
@ -140,7 +143,7 @@ class UserPermissionApi {
|
|||||||
String? firstName,
|
String? firstName,
|
||||||
String? userId,
|
String? userId,
|
||||||
String? lastName,
|
String? lastName,
|
||||||
String? jobTitle,
|
String? companyName,
|
||||||
String? phoneNumber,
|
String? phoneNumber,
|
||||||
String? roleUuid,
|
String? roleUuid,
|
||||||
List<String>? spaceUuids,
|
List<String>? spaceUuids,
|
||||||
@ -150,8 +153,8 @@ class UserPermissionApi {
|
|||||||
final body = <String, dynamic>{
|
final body = <String, dynamic>{
|
||||||
"firstName": firstName,
|
"firstName": firstName,
|
||||||
"lastName": lastName,
|
"lastName": lastName,
|
||||||
"jobTitle": jobTitle != '' ? jobTitle : " ",
|
"companyName": companyName != '' ? companyName : ' ',
|
||||||
"phoneNumber": phoneNumber != '' ? phoneNumber : " ",
|
"phoneNumber": phoneNumber != '' ? phoneNumber : ' ',
|
||||||
"roleUuid": roleUuid,
|
"roleUuid": roleUuid,
|
||||||
"projectUuid": projectUuid,
|
"projectUuid": projectUuid,
|
||||||
"spaceUuids": spaceUuids,
|
"spaceUuids": spaceUuids,
|
||||||
@ -190,12 +193,17 @@ class UserPermissionApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> changeUserStatusById(userUuid, status, String projectUuid) async {
|
Future<bool> changeUserStatusById(
|
||||||
|
userUuid, status, String projectUuid) async {
|
||||||
try {
|
try {
|
||||||
Map<String, dynamic> bodya = {"disable": status, "projectUuid": projectUuid};
|
Map<String, dynamic> bodya = {
|
||||||
|
"disable": status,
|
||||||
|
"projectUuid": projectUuid
|
||||||
|
};
|
||||||
|
|
||||||
final response = await _httpService.put(
|
final response = await _httpService.put(
|
||||||
path: ApiEndpoints.changeUserStatus.replaceAll("{invitedUserUuid}", userUuid),
|
path: ApiEndpoints.changeUserStatus
|
||||||
|
.replaceAll("{invitedUserUuid}", userUuid),
|
||||||
body: bodya,
|
body: bodya,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
return json['success'];
|
return json['success'];
|
||||||
|
@ -69,7 +69,6 @@ abstract class ColorsManager {
|
|||||||
static const Color invitedOrange = Color(0xFFFFE193);
|
static const Color invitedOrange = Color(0xFFFFE193);
|
||||||
static const Color invitedOrangeText = Color(0xFFFFBF00);
|
static const Color invitedOrangeText = Color(0xFFFFBF00);
|
||||||
static const Color lightGrayBorderColor = Color(0xB2D5D5D5);
|
static const Color lightGrayBorderColor = Color(0xB2D5D5D5);
|
||||||
//background: #F8F8F8;
|
|
||||||
static const Color vividBlue = Color(0xFF023DFE);
|
static const Color vividBlue = Color(0xFF023DFE);
|
||||||
static const Color semiTransparentRed = Color(0x99FF0000);
|
static const Color semiTransparentRed = Color(0x99FF0000);
|
||||||
static const Color grey700 = Color(0xFF2D3748);
|
static const Color grey700 = Color(0xFF2D3748);
|
||||||
@ -85,4 +84,6 @@ abstract class ColorsManager {
|
|||||||
static const Color minBlueDot = Color(0xFF023DFE);
|
static const Color minBlueDot = Color(0xFF023DFE);
|
||||||
static const Color grey25 = Color(0xFFF9F9F9);
|
static const Color grey25 = Color(0xFFF9F9F9);
|
||||||
static const Color grey50 = Color(0xFF718096);
|
static const Color grey50 = Color(0xFF718096);
|
||||||
|
static const Color red100 = Color(0xFFFE0202);
|
||||||
|
static const Color grey800 = Color(0xffF8F8F8);
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,7 @@ abstract class ApiEndpoints {
|
|||||||
////// Devices Management ////////////////
|
////// Devices Management ////////////////
|
||||||
|
|
||||||
static const String getAllDevices = '/projects/{projectId}/devices';
|
static const String getAllDevices = '/projects/{projectId}/devices';
|
||||||
static const String getSpaceDevices =
|
static const String getSpaceDevices = '/projects/{projectId}/devices';
|
||||||
'/projects/{projectId}/communities/{communityUuid}/spaces/{spaceUuid}/devices';
|
|
||||||
static const String getDeviceStatus = '/devices/{uuid}/functions/status';
|
static const String getDeviceStatus = '/devices/{uuid}/functions/status';
|
||||||
static const String getBatchStatus = '/devices/batch';
|
static const String getBatchStatus = '/devices/batch';
|
||||||
|
|
||||||
@ -141,4 +140,5 @@ abstract class ApiEndpoints {
|
|||||||
static const String saveSchedule = '/schedule/{deviceUuid}';
|
static const String saveSchedule = '/schedule/{deviceUuid}';
|
||||||
|
|
||||||
static const String getBookableSpaces = '/bookable-spaces';
|
static const String getBookableSpaces = '/bookable-spaces';
|
||||||
|
static const String getCalendarEvents = '/api';
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user