mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-08-24 22:32:28 +00:00
Merge branch 'dev' into Implement-Spaces-Table-Empty-Filled-Failure-states-bookable-spaces
This commit is contained in:
@ -1,22 +1,9 @@
|
|||||||
import 'package:firebase_core/firebase_core.dart';
|
import 'package:firebase_core/firebase_core.dart';
|
||||||
import 'package:flutter/gestures.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
|
||||||
import 'package:syncrow_web/firebase_options.dart';
|
import 'package:syncrow_web/firebase_options.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/home/bloc/home_event.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/visitor_password/bloc/visitor_password_bloc.dart';
|
|
||||||
import 'package:syncrow_web/services/locator.dart';
|
import 'package:syncrow_web/services/locator.dart';
|
||||||
import 'package:syncrow_web/utils/app_routes.dart';
|
import 'package:syncrow_web/syncrow_app.dart';
|
||||||
import 'package:syncrow_web/utils/constants/routes_const.dart';
|
|
||||||
import 'package:syncrow_web/utils/navigation_service.dart';
|
|
||||||
import 'package:syncrow_web/utils/theme/theme.dart';
|
|
||||||
|
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
try {
|
try {
|
||||||
@ -33,59 +20,5 @@ Future<void> main() async {
|
|||||||
);
|
);
|
||||||
initialSetup();
|
initialSetup();
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
runApp(MyApp());
|
runApp(const SyncrowApp());
|
||||||
}
|
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
|
||||||
MyApp({super.key});
|
|
||||||
|
|
||||||
final GoRouter _router = GoRouter(
|
|
||||||
initialLocation: RoutesConst.auth,
|
|
||||||
routes: AppRoutes.getRoutes(),
|
|
||||||
redirect: (context, state) async {
|
|
||||||
final checkToken = await AuthBloc.getTokenAndValidate();
|
|
||||||
final loggedIn = checkToken == 'Success';
|
|
||||||
final goingToLogin = state.uri.toString() == RoutesConst.auth;
|
|
||||||
|
|
||||||
if (!loggedIn && !goingToLogin) return RoutesConst.auth;
|
|
||||||
if (loggedIn && goingToLogin) return RoutesConst.home;
|
|
||||||
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return MultiBlocProvider(
|
|
||||||
providers: [
|
|
||||||
BlocProvider<CreateRoutineBloc>(
|
|
||||||
create: (context) => CreateRoutineBloc(),
|
|
||||||
),
|
|
||||||
BlocProvider(create: (context) => HomeBloc()..add(const FetchUserInfo())),
|
|
||||||
BlocProvider<VisitorPasswordBloc>(
|
|
||||||
create: (context) => VisitorPasswordBloc(),
|
|
||||||
),
|
|
||||||
BlocProvider<RoutineBloc>(
|
|
||||||
create: (context) => RoutineBloc(),
|
|
||||||
),
|
|
||||||
BlocProvider<SpaceTreeBloc>(
|
|
||||||
create: (context) => SpaceTreeBloc(),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
child: MaterialApp.router(
|
|
||||||
debugShowCheckedModeBanner: false,
|
|
||||||
scrollBehavior: const MaterialScrollBehavior().copyWith(
|
|
||||||
dragDevices: {
|
|
||||||
PointerDeviceKind.mouse,
|
|
||||||
PointerDeviceKind.touch,
|
|
||||||
PointerDeviceKind.stylus,
|
|
||||||
PointerDeviceKind.unknown,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
key: NavigationService.navigatorKey,
|
|
||||||
// scaffoldMessengerKey: NavigationService.snackbarKey,
|
|
||||||
theme: myTheme,
|
|
||||||
routerConfig: _router,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,9 @@
|
|||||||
import 'package:firebase_core/firebase_core.dart';
|
import 'package:firebase_core/firebase_core.dart';
|
||||||
import 'package:flutter/gestures.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
|
||||||
import 'package:syncrow_web/firebase_options.dart';
|
import 'package:syncrow_web/firebase_options.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/home/bloc/home_event.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/visitor_password/bloc/visitor_password_bloc.dart';
|
|
||||||
import 'package:syncrow_web/services/locator.dart';
|
import 'package:syncrow_web/services/locator.dart';
|
||||||
import 'package:syncrow_web/utils/app_routes.dart';
|
import 'package:syncrow_web/syncrow_app.dart';
|
||||||
import 'package:syncrow_web/utils/constants/routes_const.dart';
|
|
||||||
import 'package:syncrow_web/utils/navigation_service.dart';
|
|
||||||
import 'package:syncrow_web/utils/theme/theme.dart';
|
|
||||||
|
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
try {
|
try {
|
||||||
@ -33,59 +20,5 @@ Future<void> main() async {
|
|||||||
);
|
);
|
||||||
initialSetup();
|
initialSetup();
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
runApp(MyApp());
|
runApp(const SyncrowApp());
|
||||||
}
|
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
|
||||||
MyApp({super.key});
|
|
||||||
|
|
||||||
final GoRouter _router = GoRouter(
|
|
||||||
initialLocation: RoutesConst.auth,
|
|
||||||
routes: AppRoutes.getRoutes(),
|
|
||||||
redirect: (context, state) async {
|
|
||||||
final checkToken = await AuthBloc.getTokenAndValidate();
|
|
||||||
final loggedIn = checkToken == 'Success';
|
|
||||||
final goingToLogin = state.uri.toString() == RoutesConst.auth;
|
|
||||||
|
|
||||||
if (!loggedIn && !goingToLogin) return RoutesConst.auth;
|
|
||||||
if (loggedIn && goingToLogin) return RoutesConst.home;
|
|
||||||
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return MultiBlocProvider(
|
|
||||||
providers: [
|
|
||||||
BlocProvider<CreateRoutineBloc>(
|
|
||||||
create: (context) => CreateRoutineBloc(),
|
|
||||||
),
|
|
||||||
BlocProvider(create: (context) => HomeBloc()..add(const FetchUserInfo())),
|
|
||||||
BlocProvider<VisitorPasswordBloc>(
|
|
||||||
create: (context) => VisitorPasswordBloc(),
|
|
||||||
),
|
|
||||||
BlocProvider<RoutineBloc>(
|
|
||||||
create: (context) => RoutineBloc(),
|
|
||||||
),
|
|
||||||
BlocProvider<SpaceTreeBloc>(
|
|
||||||
create: (context) => SpaceTreeBloc(),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
child: MaterialApp.router(
|
|
||||||
debugShowCheckedModeBanner: false,
|
|
||||||
scrollBehavior: const MaterialScrollBehavior().copyWith(
|
|
||||||
dragDevices: {
|
|
||||||
PointerDeviceKind.mouse,
|
|
||||||
PointerDeviceKind.touch,
|
|
||||||
PointerDeviceKind.stylus,
|
|
||||||
PointerDeviceKind.unknown,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
key: NavigationService.navigatorKey,
|
|
||||||
// scaffoldMessengerKey: NavigationService.snackbarKey,
|
|
||||||
theme: myTheme,
|
|
||||||
routerConfig: _router,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,26 +1,16 @@
|
|||||||
import 'package:firebase_core/firebase_core.dart';
|
import 'package:firebase_core/firebase_core.dart';
|
||||||
import 'package:flutter/gestures.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
|
||||||
import 'package:syncrow_web/firebase_options.dart';
|
import 'package:syncrow_web/firebase_options.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/home/bloc/home_event.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/visitor_password/bloc/visitor_password_bloc.dart';
|
|
||||||
import 'package:syncrow_web/services/locator.dart';
|
import 'package:syncrow_web/services/locator.dart';
|
||||||
import 'package:syncrow_web/utils/app_routes.dart';
|
import 'package:syncrow_web/syncrow_app.dart';
|
||||||
import 'package:syncrow_web/utils/constants/routes_const.dart';
|
|
||||||
import 'package:syncrow_web/utils/navigation_service.dart';
|
|
||||||
import 'package:syncrow_web/utils/theme/theme.dart';
|
|
||||||
|
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
try {
|
try {
|
||||||
const environment = String.fromEnvironment('FLAVOR', defaultValue: 'staging');
|
const environment = String.fromEnvironment(
|
||||||
|
'FLAVOR',
|
||||||
|
defaultValue: 'staging',
|
||||||
|
);
|
||||||
await dotenv.load(fileName: '.env.$environment');
|
await dotenv.load(fileName: '.env.$environment');
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
await Firebase.initializeApp(
|
await Firebase.initializeApp(
|
||||||
@ -30,59 +20,5 @@ Future<void> main() async {
|
|||||||
);
|
);
|
||||||
initialSetup();
|
initialSetup();
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
runApp(MyApp());
|
runApp(const SyncrowApp());
|
||||||
}
|
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
|
||||||
MyApp({super.key});
|
|
||||||
|
|
||||||
final GoRouter _router = GoRouter(
|
|
||||||
initialLocation: RoutesConst.auth,
|
|
||||||
routes: AppRoutes.getRoutes(),
|
|
||||||
redirect: (context, state) async {
|
|
||||||
final checkToken = await AuthBloc.getTokenAndValidate();
|
|
||||||
final loggedIn = checkToken == 'Success';
|
|
||||||
final goingToLogin = state.uri.toString() == RoutesConst.auth;
|
|
||||||
|
|
||||||
if (!loggedIn && !goingToLogin) return RoutesConst.auth;
|
|
||||||
if (loggedIn && goingToLogin) return RoutesConst.home;
|
|
||||||
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return MultiBlocProvider(
|
|
||||||
providers: [
|
|
||||||
BlocProvider<CreateRoutineBloc>(
|
|
||||||
create: (context) => CreateRoutineBloc(),
|
|
||||||
),
|
|
||||||
BlocProvider(create: (context) => HomeBloc()..add(const FetchUserInfo())),
|
|
||||||
BlocProvider<VisitorPasswordBloc>(
|
|
||||||
create: (context) => VisitorPasswordBloc(),
|
|
||||||
),
|
|
||||||
BlocProvider<RoutineBloc>(
|
|
||||||
create: (context) => RoutineBloc(),
|
|
||||||
),
|
|
||||||
BlocProvider<SpaceTreeBloc>(
|
|
||||||
create: (context) => SpaceTreeBloc(),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
child: MaterialApp.router(
|
|
||||||
debugShowCheckedModeBanner: false,
|
|
||||||
scrollBehavior: const MaterialScrollBehavior().copyWith(
|
|
||||||
dragDevices: {
|
|
||||||
PointerDeviceKind.mouse,
|
|
||||||
PointerDeviceKind.touch,
|
|
||||||
PointerDeviceKind.stylus,
|
|
||||||
PointerDeviceKind.unknown,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
key: NavigationService.navigatorKey,
|
|
||||||
// scaffoldMessengerKey: NavigationService.snackbarKey,
|
|
||||||
theme: myTheme,
|
|
||||||
routerConfig: _router,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ 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();
|
EventController eventController = EventController();
|
||||||
final CalendarSystemService calendarService;
|
final CalendarSystemService calendarService;
|
||||||
|
|
||||||
CalendarEventsBloc({
|
CalendarEventsBloc({
|
||||||
@ -20,7 +20,9 @@ class CalendarEventsBloc extends Bloc<CalendarEventsEvent, CalendarEventState> {
|
|||||||
on<AddEvent>(_onAddEvent);
|
on<AddEvent>(_onAddEvent);
|
||||||
on<DisposeResources>(_onDisposeResources);
|
on<DisposeResources>(_onDisposeResources);
|
||||||
on<GoToWeek>(_onGoToWeek);
|
on<GoToWeek>(_onGoToWeek);
|
||||||
|
on<ResetEvents>(_onResetEvents);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onLoadEvents(
|
Future<void> _onLoadEvents(
|
||||||
LoadEvents event,
|
LoadEvents event,
|
||||||
Emitter<CalendarEventState> emit,
|
Emitter<CalendarEventState> emit,
|
||||||
@ -126,4 +128,18 @@ class CalendarEventsBloc extends Bloc<CalendarEventsEvent, CalendarEventState> {
|
|||||||
eventController.dispose();
|
eventController.dispose();
|
||||||
return super.close();
|
return super.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _onResetEvents(
|
||||||
|
ResetEvents event,
|
||||||
|
Emitter<CalendarEventState> emit,
|
||||||
|
) {
|
||||||
|
if (calendarService is MemoryCalendarServiceWithRemoteFallback) {
|
||||||
|
(calendarService as MemoryCalendarServiceWithRemoteFallback)
|
||||||
|
.memoryService
|
||||||
|
.clear();
|
||||||
|
}
|
||||||
|
eventController.dispose();
|
||||||
|
eventController = EventController();
|
||||||
|
emit(EventsInitial());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,3 +29,10 @@ class CheckWeekHasEvents extends CalendarEventsEvent {
|
|||||||
final DateTime weekStart;
|
final DateTime weekStart;
|
||||||
const CheckWeekHasEvents(this.weekStart);
|
const CheckWeekHasEvents(this.weekStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ResetEvents extends CalendarEventsEvent {
|
||||||
|
const ResetEvents();
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object?> get props => [];
|
||||||
|
}
|
@ -1,3 +1,4 @@
|
|||||||
|
// booking_page.dart
|
||||||
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:calendar_view/calendar_view.dart';
|
import 'package:calendar_view/calendar_view.dart';
|
||||||
@ -26,7 +27,33 @@ class BookingPage extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _BookingPageState extends State<BookingPage> {
|
class _BookingPageState extends State<BookingPage> {
|
||||||
late final EventController _eventController;
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return MultiBlocProvider(
|
||||||
|
providers: [
|
||||||
|
BlocProvider(create: (_) => SelectedBookableSpaceBloc()),
|
||||||
|
BlocProvider(create: (_) => DateSelectionBloc()),
|
||||||
|
BlocProvider(
|
||||||
|
create: (_) => CalendarEventsBloc(
|
||||||
|
calendarService: MemoryCalendarServiceWithRemoteFallback(
|
||||||
|
remoteService: RemoteCalendarService(HTTPService()),
|
||||||
|
memoryService: MemoryCalendarService(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
child: _BookingPageContent(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _BookingPageContent extends StatefulWidget {
|
||||||
|
@override
|
||||||
|
State<_BookingPageContent> createState() => _BookingPageContentState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _BookingPageContentState extends State<_BookingPageContent> {
|
||||||
|
late EventController _eventController;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -40,7 +67,7 @@ class _BookingPageState extends State<BookingPage> {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _dispatchLoadEvents(BuildContext context) {
|
void _loadEvents(BuildContext context) {
|
||||||
final selectedRoom =
|
final selectedRoom =
|
||||||
context.read<SelectedBookableSpaceBloc>().state.selectedBookableSpace;
|
context.read<SelectedBookableSpaceBloc>().state.selectedBookableSpace;
|
||||||
final dateState = context.read<DateSelectionBloc>().state;
|
final dateState = context.read<DateSelectionBloc>().state;
|
||||||
@ -60,186 +87,170 @@ class _BookingPageState extends State<BookingPage> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MultiBlocProvider(
|
return BlocListener<SelectedBookableSpaceBloc, SelectedBookableSpaceState>(
|
||||||
providers: [
|
listener: (context, state) {
|
||||||
BlocProvider(create: (_) => SelectedBookableSpaceBloc()),
|
if (state.selectedBookableSpace != null) {
|
||||||
BlocProvider(create: (_) => DateSelectionBloc()),
|
// Reset events and clear cache when room changes
|
||||||
BlocProvider(
|
context.read<CalendarEventsBloc>().add(ResetEvents());
|
||||||
create: (_) => CalendarEventsBloc(
|
_loadEvents(context);
|
||||||
calendarService: MemoryCalendarServiceWithRemoteFallback(
|
}
|
||||||
remoteService: RemoteCalendarService(
|
},
|
||||||
HTTPService(),
|
child: BlocListener<DateSelectionBloc, DateSelectionState>(
|
||||||
),
|
listener: (context, state) {
|
||||||
memoryService: MemoryCalendarService(),
|
_loadEvents(context);
|
||||||
),
|
},
|
||||||
)),
|
child: BlocListener<CalendarEventsBloc, CalendarEventState>(
|
||||||
],
|
|
||||||
child: Builder(
|
|
||||||
builder: (context) =>
|
|
||||||
BlocListener<CalendarEventsBloc, CalendarEventState>(
|
|
||||||
listenWhen: (prev, curr) => curr is EventsLoaded,
|
|
||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
if (state is EventsLoaded) {
|
if (state is EventsLoaded) {
|
||||||
_eventController.removeWhere((_) => true);
|
_eventController.removeWhere((_) => true);
|
||||||
_eventController.addAll(state.events);
|
_eventController.addAll(state.events);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: BlocListener<SelectedBookableSpaceBloc,
|
child: Row(
|
||||||
SelectedBookableSpaceState>(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
listener: (context, state) => _dispatchLoadEvents(context),
|
children: [
|
||||||
child: BlocListener<DateSelectionBloc, DateSelectionState>(
|
Expanded(
|
||||||
listener: (context, state) => _dispatchLoadEvents(context),
|
child: Container(
|
||||||
child: Row(
|
decoration: BoxDecoration(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
color: ColorsManager.whiteColors,
|
||||||
children: [
|
boxShadow: [
|
||||||
Expanded(
|
BoxShadow(
|
||||||
child: Container(
|
color: ColorsManager.blackColor.withOpacity(0.1),
|
||||||
decoration: BoxDecoration(
|
offset: const Offset(3, 0),
|
||||||
color: ColorsManager.whiteColors,
|
blurRadius: 6,
|
||||||
boxShadow: [
|
spreadRadius: 0,
|
||||||
BoxShadow(
|
|
||||||
color: ColorsManager.blackColor.withOpacity(0.1),
|
|
||||||
offset: const Offset(3, 0),
|
|
||||||
blurRadius: 6,
|
|
||||||
spreadRadius: 0,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
child: Column(
|
],
|
||||||
children: [
|
|
||||||
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: Column(
|
||||||
flex: 5,
|
children: [
|
||||||
child: Padding(
|
Expanded(
|
||||||
padding: const EdgeInsets.all(20.0),
|
flex: 2,
|
||||||
child: Column(
|
child: BlocBuilder<SelectedBookableSpaceBloc,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
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(
|
||||||
|
flex: 5,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(20.0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
children: [
|
||||||
Row(
|
SvgTextButton(
|
||||||
children: [
|
svgAsset: Assets.homeIcon,
|
||||||
SvgTextButton(
|
label: 'Manage Bookable Spaces',
|
||||||
svgAsset: Assets.homeIcon,
|
onPressed: () {},
|
||||||
label: 'Manage Bookable Spaces',
|
|
||||||
onPressed: () {},
|
|
||||||
),
|
|
||||||
const SizedBox(width: 20),
|
|
||||||
SvgTextButton(
|
|
||||||
svgAsset: Assets.groupIcon,
|
|
||||||
label: 'Manage Users',
|
|
||||||
onPressed: () {},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
BlocBuilder<DateSelectionBloc,
|
const SizedBox(width: 20),
|
||||||
DateSelectionState>(
|
SvgTextButton(
|
||||||
builder: (context, state) {
|
svgAsset: Assets.groupIcon,
|
||||||
final weekStart = state.weekStart;
|
label: 'Manage Users',
|
||||||
final weekEnd =
|
onPressed: () {},
|
||||||
weekStart.add(const Duration(days: 6));
|
|
||||||
return WeekNavigation(
|
|
||||||
weekStart: weekStart,
|
|
||||||
weekEnd: weekEnd,
|
|
||||||
onPreviousWeek: () {
|
|
||||||
context
|
|
||||||
.read<DateSelectionBloc>()
|
|
||||||
.add(PreviousWeek());
|
|
||||||
},
|
|
||||||
onNextWeek: () {
|
|
||||||
context
|
|
||||||
.read<DateSelectionBloc>()
|
|
||||||
.add(NextWeek());
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Expanded(
|
BlocBuilder<DateSelectionBloc, DateSelectionState>(
|
||||||
flex: 5,
|
builder: (context, state) {
|
||||||
child: BlocBuilder<SelectedBookableSpaceBloc,
|
final weekStart = state.weekStart;
|
||||||
SelectedBookableSpaceState>(
|
final weekEnd =
|
||||||
builder: (context, roomState) {
|
weekStart.add(const Duration(days: 6));
|
||||||
final selectedRoom =
|
return WeekNavigation(
|
||||||
roomState.selectedBookableSpace;
|
weekStart: weekStart,
|
||||||
return BlocBuilder<DateSelectionBloc,
|
weekEnd: weekEnd,
|
||||||
DateSelectionState>(
|
onPreviousWeek: () {
|
||||||
builder: (context, dateState) {
|
context
|
||||||
return BlocListener<CalendarEventsBloc,
|
.read<DateSelectionBloc>()
|
||||||
CalendarEventState>(
|
.add(PreviousWeek());
|
||||||
listenWhen: (prev, curr) =>
|
},
|
||||||
curr is EventsLoaded,
|
onNextWeek: () {
|
||||||
listener: (context, state) {
|
context
|
||||||
if (state is EventsLoaded) {
|
.read<DateSelectionBloc>()
|
||||||
_eventController
|
.add(NextWeek());
|
||||||
.removeWhere((_) => true);
|
},
|
||||||
_eventController.addAll(state.events);
|
);
|
||||||
}
|
},
|
||||||
},
|
),
|
||||||
child: WeeklyCalendarPage(
|
],
|
||||||
startTime: selectedRoom
|
),
|
||||||
?.bookableConfig.startTime,
|
const SizedBox(height: 20),
|
||||||
endTime: selectedRoom
|
Expanded(
|
||||||
?.bookableConfig.endTime,
|
flex: 5,
|
||||||
weekStart: dateState.weekStart,
|
child: BlocBuilder<SelectedBookableSpaceBloc,
|
||||||
selectedDate: dateState.selectedDate,
|
SelectedBookableSpaceState>(
|
||||||
eventController: _eventController,
|
builder: (context, roomState) {
|
||||||
selectedDateFromSideBarCalender: context
|
final selectedRoom =
|
||||||
.watch<DateSelectionBloc>()
|
roomState.selectedBookableSpace;
|
||||||
.state
|
return BlocBuilder<DateSelectionBloc,
|
||||||
.selectedDateFromSideBarCalender,
|
DateSelectionState>(
|
||||||
),
|
builder: (context, dateState) {
|
||||||
|
return BlocBuilder<CalendarEventsBloc,
|
||||||
|
CalendarEventState>(
|
||||||
|
builder: (context, eventState) {
|
||||||
|
return WeeklyCalendarPage(
|
||||||
|
key: ValueKey(
|
||||||
|
selectedRoom?.uuid ?? 'no-room'),
|
||||||
|
startTime: selectedRoom
|
||||||
|
?.bookableConfig.startTime,
|
||||||
|
endTime:
|
||||||
|
selectedRoom?.bookableConfig.endTime,
|
||||||
|
weekStart: dateState.weekStart,
|
||||||
|
selectedDate: dateState.selectedDate,
|
||||||
|
eventController: _eventController,
|
||||||
|
selectedDateFromSideBarCalender: context
|
||||||
|
.watch<DateSelectionBloc>()
|
||||||
|
.state
|
||||||
|
.selectedDateFromSideBarCalender,
|
||||||
|
// isLoading: eventState is EventsLoading,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
);
|
||||||
),
|
},
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -76,21 +76,29 @@ class __SidebarContentState extends State<_SidebarContent> {
|
|||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
const _SidebarHeader(title: 'Spaces'),
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 10.0, bottom: 10.0),
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: ColorsManager.whiteColors,
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: ColorsManager.blackColor.withOpacity(0.1),
|
||||||
|
offset: const Offset(0, 4),
|
||||||
|
blurRadius: 4,
|
||||||
|
spreadRadius: 0,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: _SidebarHeader(title: 'Spaces')),
|
||||||
|
),
|
||||||
Container(
|
Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: ColorsManager.whiteColors,
|
color: ColorsManager.whiteColors,
|
||||||
borderRadius: BorderRadius.circular(8.0),
|
|
||||||
boxShadow: [
|
boxShadow: [
|
||||||
BoxShadow(
|
BoxShadow(
|
||||||
color: ColorsManager.blackColor.withOpacity(0.1),
|
color: ColorsManager.blackColor.withOpacity(0.1),
|
||||||
offset: const Offset(0, -2),
|
offset: const Offset(0, 4),
|
||||||
blurRadius: 4,
|
|
||||||
spreadRadius: 0,
|
|
||||||
),
|
|
||||||
BoxShadow(
|
|
||||||
color: ColorsManager.blackColor.withOpacity(0.1),
|
|
||||||
offset: const Offset(0, 2),
|
|
||||||
blurRadius: 4,
|
blurRadius: 4,
|
||||||
spreadRadius: 0,
|
spreadRadius: 0,
|
||||||
),
|
),
|
||||||
@ -220,7 +228,7 @@ class _SidebarHeader extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(10.0),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
|
@ -66,18 +66,28 @@ class _CustomCalendarPageState extends State<CustomCalendarPage> {
|
|||||||
weekdayLabels: const ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'],
|
weekdayLabels: const ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'],
|
||||||
);
|
);
|
||||||
|
|
||||||
return CalendarDatePicker2(
|
return Container(
|
||||||
config: config,
|
decoration: const BoxDecoration(
|
||||||
value: [_selectedDate],
|
border: Border(
|
||||||
onValueChanged: (dates) {
|
top: BorderSide(
|
||||||
final picked = dates.first;
|
color: ColorsManager.textGray,
|
||||||
if (picked != null) {
|
width: 1.0,
|
||||||
setState(() {
|
),
|
||||||
_selectedDate = picked;
|
),
|
||||||
});
|
),
|
||||||
widget.onDateChanged(picked.day, picked.month, picked.year);
|
child: CalendarDatePicker2(
|
||||||
}
|
config: config,
|
||||||
},
|
value: [_selectedDate],
|
||||||
|
onValueChanged: (dates) {
|
||||||
|
final picked = dates.first;
|
||||||
|
if (picked != null) {
|
||||||
|
setState(() {
|
||||||
|
_selectedDate = picked;
|
||||||
|
});
|
||||||
|
widget.onDateChanged(picked.day, picked.month, picked.year);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,15 +32,17 @@ class EventTileWidget extends StatelessWidget {
|
|||||||
return Expanded(
|
return Expanded(
|
||||||
child: Container(
|
child: Container(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
padding: EdgeInsets.all(5),
|
padding: const EdgeInsets.all(5),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: isEventEnded
|
color: isEventEnded
|
||||||
? ColorsManager.grayColor.withOpacity(0.1)
|
? ColorsManager.grayColor.withOpacity(0.1)
|
||||||
: ColorsManager.blue1.withOpacity(0.1),
|
: ColorsManager.blue1.withOpacity(0.1),
|
||||||
borderRadius: BorderRadius.circular(6),
|
borderRadius: BorderRadius.circular(6),
|
||||||
border: const Border(
|
border: Border(
|
||||||
left: BorderSide(
|
left: BorderSide(
|
||||||
color: ColorsManager.grayColor,
|
color: isEventEnded
|
||||||
|
? ColorsManager.grayColor
|
||||||
|
: ColorsManager.secondaryColor,
|
||||||
width: 4,
|
width: 4,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -21,7 +21,7 @@ class RoomListItem extends StatelessWidget {
|
|||||||
groupValue: isSelected ? room.uuid : null,
|
groupValue: isSelected ? room.uuid : null,
|
||||||
visualDensity: const VisualDensity(vertical: -4),
|
visualDensity: const VisualDensity(vertical: -4),
|
||||||
onChanged: (value) => onTap(),
|
onChanged: (value) => onTap(),
|
||||||
activeColor: ColorsManager.primaryColor,
|
activeColor: ColorsManager.secondaryColor,
|
||||||
title: Text(
|
title: Text(
|
||||||
room.spaceName,
|
room.spaceName,
|
||||||
maxLines: 2,
|
maxLines: 2,
|
||||||
|
@ -14,26 +14,33 @@ class WeekDayHeader extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Column(
|
return ColoredBox(
|
||||||
children: [
|
color: isSelectedDay
|
||||||
Text(
|
? ColorsManager.secondaryColor.withOpacity(0.1)
|
||||||
DateFormat('EEE').format(date).toUpperCase(),
|
: Colors.transparent,
|
||||||
style: TextStyle(
|
child: Column(
|
||||||
fontWeight: FontWeight.w400,
|
children: [
|
||||||
fontSize: 14,
|
const SizedBox(
|
||||||
color: isSelectedDay ? Colors.blue : Colors.black,
|
height: 10,
|
||||||
),
|
),
|
||||||
),
|
Text(
|
||||||
Text(
|
DateFormat('EEE').format(date).toUpperCase(),
|
||||||
DateFormat('d').format(date),
|
style: const TextStyle(
|
||||||
style: TextStyle(
|
fontWeight: FontWeight.w400,
|
||||||
fontWeight: FontWeight.w700,
|
fontSize: 14,
|
||||||
fontSize: 20,
|
color: ColorsManager.blackColor,
|
||||||
color:
|
),
|
||||||
isSelectedDay ? ColorsManager.blue1 : ColorsManager.blackColor,
|
|
||||||
),
|
),
|
||||||
),
|
Text(
|
||||||
],
|
DateFormat('d').format(date),
|
||||||
|
style: const TextStyle(
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
fontSize: 30,
|
||||||
|
color: ColorsManager.blackColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ class WeeklyCalendarPage extends StatelessWidget {
|
|||||||
});
|
});
|
||||||
static const double timeLineWidth = 65;
|
static const double timeLineWidth = 65;
|
||||||
static const int totalDays = 7;
|
static const int totalDays = 7;
|
||||||
static const double dayColumnWidth = 220;
|
static const double dayColumnWidth = 220;
|
||||||
|
|
||||||
final double calendarContentWidth =
|
final double calendarContentWidth =
|
||||||
timeLineWidth + (totalDays * dayColumnWidth);
|
timeLineWidth + (totalDays * dayColumnWidth);
|
||||||
@ -57,13 +57,10 @@ class WeeklyCalendarPage extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const double timeLineWidth = 90;
|
||||||
|
|
||||||
const double timeLineWidth = 65;
|
|
||||||
|
|
||||||
return LayoutBuilder(
|
return LayoutBuilder(
|
||||||
builder: (context, constraints) {
|
builder: (context, constraints) {
|
||||||
|
|
||||||
bool isInRange(DateTime date, DateTime start, DateTime end) {
|
bool isInRange(DateTime date, DateTime start, DateTime end) {
|
||||||
!date.isBefore(start) && !date.isAfter(end);
|
!date.isBefore(start) && !date.isAfter(end);
|
||||||
// remove this line and Check if the date is within the range
|
// remove this line and Check if the date is within the range
|
||||||
@ -100,7 +97,6 @@ class WeeklyCalendarPage extends StatelessWidget {
|
|||||||
width: width,
|
width: width,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.orange.withOpacity(0.13),
|
color: Colors.orange.withOpacity(0.13),
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else if (isSelected) {
|
} else if (isSelected) {
|
||||||
@ -110,7 +106,6 @@ class WeeklyCalendarPage extends StatelessWidget {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color:
|
color:
|
||||||
ColorsManager.spaceColor.withOpacity(0.07),
|
ColorsManager.spaceColor.withOpacity(0.07),
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -143,7 +138,7 @@ class WeeklyCalendarPage extends StatelessWidget {
|
|||||||
heightPerMinute: 1.7,
|
heightPerMinute: 1.7,
|
||||||
showLiveTimeLineInAllDays: false,
|
showLiveTimeLineInAllDays: false,
|
||||||
showVerticalLines: true,
|
showVerticalLines: true,
|
||||||
emulateVerticalOffsetBy: -80,
|
emulateVerticalOffsetBy: -95,
|
||||||
startDay: WeekDays.monday,
|
startDay: WeekDays.monday,
|
||||||
liveTimeIndicatorSettings:
|
liveTimeIndicatorSettings:
|
||||||
const LiveTimeIndicatorSettings(
|
const LiveTimeIndicatorSettings(
|
||||||
@ -161,7 +156,7 @@ class WeeklyCalendarPage extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
timeLineWidth: timeLineWidth,
|
timeLineWidth: timeLineWidth,
|
||||||
weekPageHeaderBuilder: (start, end) => Container(),
|
weekPageHeaderBuilder: (start, end) => Container(),
|
||||||
weekTitleHeight: 60,
|
weekTitleHeight: 90,
|
||||||
weekNumberBuilder: (firstDayOfWeek) => Padding(
|
weekNumberBuilder: (firstDayOfWeek) => Padding(
|
||||||
padding: const EdgeInsets.only(right: 15, bottom: 10),
|
padding: const EdgeInsets.only(right: 15, bottom: 10),
|
||||||
child: Column(
|
child: Column(
|
||||||
@ -208,8 +203,6 @@ class WeeklyCalendarPage extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isSameDay(DateTime d1, DateTime d2) {
|
bool isSameDay(DateTime d1, DateTime d2) {
|
||||||
|
@ -6,6 +6,7 @@ import 'package:syncrow_web/pages/device_managment/garage_door/bloc/garage_door_
|
|||||||
import 'package:syncrow_web/pages/device_managment/garage_door/helper/garage_door_helper.dart';
|
import 'package:syncrow_web/pages/device_managment/garage_door/helper/garage_door_helper.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/garage_door/models/garage_door_model.dart';
|
import 'package:syncrow_web/pages/device_managment/garage_door/models/garage_door_model.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/garage_door/schedule_view/schedule_garage_view.dart';
|
import 'package:syncrow_web/pages/device_managment/garage_door/schedule_view/schedule_garage_view.dart';
|
||||||
|
import 'package:syncrow_web/pages/device_managment/schedule_device/schedule_widgets/schedual_view.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/shared/icon_name_status_container.dart';
|
import 'package:syncrow_web/pages/device_managment/shared/icon_name_status_container.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/shared/table/report_table.dart';
|
import 'package:syncrow_web/pages/device_managment/shared/table/report_table.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/shared/toggle_widget.dart';
|
import 'package:syncrow_web/pages/device_managment/shared/toggle_widget.dart';
|
||||||
@ -94,11 +95,18 @@ class GarageDoorControlView extends StatelessWidget
|
|||||||
FetchGarageDoorSchedulesEvent(
|
FetchGarageDoorSchedulesEvent(
|
||||||
deviceId: deviceId, category: 'doorcontact_state'),
|
deviceId: deviceId, category: 'doorcontact_state'),
|
||||||
);
|
);
|
||||||
showDialog(
|
|
||||||
|
showDialog<void>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (ctx) => BlocProvider.value(
|
builder: (ctx) => BlocProvider.value(
|
||||||
value: BlocProvider.of<GarageDoorBloc>(context),
|
value: BlocProvider.of<GarageDoorBloc>(context),
|
||||||
child: BuildGarageDoorScheduleView(status: status),
|
child: BuildScheduleView(
|
||||||
|
deviceUuid: deviceId,
|
||||||
|
category: 'Timer',
|
||||||
|
code: 'doorcontact_state',
|
||||||
|
countdownCode: 'Timer',
|
||||||
|
deviceType: 'GD',
|
||||||
|
),
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
name: 'Scheduling',
|
name: 'Scheduling',
|
||||||
|
@ -287,7 +287,8 @@ class ScheduleBloc extends Bloc<ScheduleEvent, ScheduleState> {
|
|||||||
try {
|
try {
|
||||||
if (state is ScheduleLoaded) {
|
if (state is ScheduleLoaded) {
|
||||||
Status status = Status(code: '', value: '');
|
Status status = Status(code: '', value: '');
|
||||||
if (event.deviceType == 'CUR_2') {
|
if (event.deviceType == 'CUR_2' ||
|
||||||
|
event.deviceType == 'GD' ) {
|
||||||
status = status.copyWith(
|
status = status.copyWith(
|
||||||
code: 'control',
|
code: 'control',
|
||||||
value: event.functionOn == true ? 'open' : 'close');
|
value: event.functionOn == true ? 'open' : 'close');
|
||||||
|
@ -69,7 +69,7 @@ class CountdownModeButtons extends StatelessWidget {
|
|||||||
countDownCode: countDownCode),
|
countDownCode: countDownCode),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
backgroundColor: ColorsManager.primaryColorWithOpacity,
|
backgroundColor: ColorsManager.secondaryColor,
|
||||||
child: const Text('Save'),
|
child: const Text('Save'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -63,7 +63,7 @@ class InchingModeButtons extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
backgroundColor: ColorsManager.primaryColor,
|
backgroundColor: ColorsManager.secondaryColor,
|
||||||
child: const Text('Save'),
|
child: const Text('Save'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -31,11 +31,12 @@ class BuildScheduleView extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (_) => ScheduleBloc(deviceId: deviceUuid,)
|
create: (_) => ScheduleBloc(
|
||||||
|
deviceId: deviceUuid,
|
||||||
|
)
|
||||||
..add(ScheduleGetEvent(category: category))
|
..add(ScheduleGetEvent(category: category))
|
||||||
..add(ScheduleFetchStatusEvent(
|
..add(ScheduleFetchStatusEvent(
|
||||||
deviceId: deviceUuid,
|
deviceId: deviceUuid, countdownCode: countdownCode ?? '')),
|
||||||
countdownCode: countdownCode ?? '')),
|
|
||||||
child: Dialog(
|
child: Dialog(
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
insetPadding: const EdgeInsets.all(20),
|
insetPadding: const EdgeInsets.all(20),
|
||||||
@ -56,7 +57,7 @@ class BuildScheduleView extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
const ScheduleHeader(),
|
const ScheduleHeader(),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
if (deviceType == 'CUR_2')
|
if (deviceType == 'CUR_2' || deviceType == 'GD')
|
||||||
const SizedBox()
|
const SizedBox()
|
||||||
else
|
else
|
||||||
ScheduleModeSelector(
|
ScheduleModeSelector(
|
||||||
@ -76,8 +77,7 @@ class BuildScheduleView extends StatelessWidget {
|
|||||||
category: category,
|
category: category,
|
||||||
time: '',
|
time: '',
|
||||||
function: Status(
|
function: Status(
|
||||||
code: code.toString(),
|
code: code.toString(), value: true),
|
||||||
value: true),
|
|
||||||
days: [],
|
days: [],
|
||||||
),
|
),
|
||||||
isEdit: false,
|
isEdit: false,
|
||||||
@ -96,7 +96,7 @@ class BuildScheduleView extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
if (deviceType != 'CUR_2')
|
if (deviceType != 'CUR_2'|| deviceType != 'GD')
|
||||||
if (state.scheduleMode == ScheduleModes.countdown ||
|
if (state.scheduleMode == ScheduleModes.countdown ||
|
||||||
state.scheduleMode == ScheduleModes.inching)
|
state.scheduleMode == ScheduleModes.inching)
|
||||||
CountdownInchingView(
|
CountdownInchingView(
|
||||||
|
@ -24,12 +24,13 @@ class ScheduleManagementUI extends StatelessWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 170,
|
width: 177,
|
||||||
height: 40,
|
height: 40,
|
||||||
child: DefaultButton(
|
child: DefaultButton(
|
||||||
borderColor: ColorsManager.grayColor.withOpacity(0.5),
|
borderWidth: 4,
|
||||||
padding: 2,
|
borderColor: ColorsManager.neutralGray,
|
||||||
backgroundColor: ColorsManager.graysColor,
|
padding: 8,
|
||||||
|
backgroundColor: ColorsManager.textFieldGreyColor,
|
||||||
borderRadius: 15,
|
borderRadius: 15,
|
||||||
onPressed: onAddSchedule,
|
onPressed: onAddSchedule,
|
||||||
child: Row(
|
child: Row(
|
||||||
|
@ -39,7 +39,7 @@ class ScheduleModeButtons extends StatelessWidget {
|
|||||||
borderRadius: 8,
|
borderRadius: 8,
|
||||||
height: 40,
|
height: 40,
|
||||||
onPressed: onSave,
|
onPressed: onSave,
|
||||||
backgroundColor: ColorsManager.primaryColorWithOpacity,
|
backgroundColor: ColorsManager.secondaryColor,
|
||||||
child: const Text('Save'),
|
child: const Text('Save'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -194,7 +194,7 @@ class _ScheduleTableView extends StatelessWidget {
|
|||||||
child: Text(_getSelectedDays(
|
child: Text(_getSelectedDays(
|
||||||
ScheduleModel.parseSelectedDays(schedule.days)))),
|
ScheduleModel.parseSelectedDays(schedule.days)))),
|
||||||
Center(child: Text(formatIsoStringToTime(schedule.time, context))),
|
Center(child: Text(formatIsoStringToTime(schedule.time, context))),
|
||||||
if (deviceType == 'CUR_2')
|
if (deviceType == 'CUR_2' || deviceType == 'GD')
|
||||||
Center(
|
Center(
|
||||||
child: Text(schedule.function.value == true ? 'open' : 'close'))
|
child: Text(schedule.function.value == true ? 'open' : 'close'))
|
||||||
else
|
else
|
||||||
|
@ -23,7 +23,7 @@ class ScheduleDialogHelper {
|
|||||||
required String deviceType,
|
required String deviceType,
|
||||||
}) {
|
}) {
|
||||||
bool temp;
|
bool temp;
|
||||||
if (deviceType == 'CUR_2') {
|
if (deviceType == 'CUR_2' || deviceType == 'GD') {
|
||||||
temp = schedule!.function.value == 'open' ? true : false;
|
temp = schedule!.function.value == 'open' ? true : false;
|
||||||
} else {
|
} else {
|
||||||
temp = schedule!.function.value;
|
temp = schedule!.function.value;
|
||||||
@ -116,7 +116,7 @@ class ScheduleDialogHelper {
|
|||||||
ScheduleModeButtons(
|
ScheduleModeButtons(
|
||||||
onSave: () {
|
onSave: () {
|
||||||
dynamic temp;
|
dynamic temp;
|
||||||
if (deviceType == 'CUR_2') {
|
if (deviceType == 'CUR_2' || deviceType == 'GD') {
|
||||||
temp = functionOn! ? 'open' : 'close';
|
temp = functionOn! ? 'open' : 'close';
|
||||||
} else {
|
} else {
|
||||||
temp = functionOn;
|
temp = functionOn;
|
||||||
@ -202,18 +202,23 @@ class ScheduleDialogHelper {
|
|||||||
),
|
),
|
||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
Radio<bool>(
|
Radio<bool>(
|
||||||
|
activeColor: ColorsManager.secondaryColor,
|
||||||
|
focusColor: ColorsManager.secondaryColor,
|
||||||
value: true,
|
value: true,
|
||||||
groupValue: isOn,
|
groupValue: isOn,
|
||||||
onChanged: (val) => onChanged(true),
|
onChanged: (val) => onChanged(true),
|
||||||
),
|
),
|
||||||
Text(categor == 'CUR_2' ? 'open' : 'On'),
|
Text(categor == 'CUR_2' || categor == 'GD' ? 'open' : 'On'),
|
||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
Radio<bool>(
|
Radio<bool>(
|
||||||
|
activeColor: ColorsManager.secondaryColor,
|
||||||
|
focusColor: ColorsManager.secondaryColor,
|
||||||
|
|
||||||
value: false,
|
value: false,
|
||||||
groupValue: isOn,
|
groupValue: isOn,
|
||||||
onChanged: (val) => onChanged(false),
|
onChanged: (val) => onChanged(false),
|
||||||
),
|
),
|
||||||
Text(categor == 'CUR_2' ? 'close' : 'Off'),
|
Text(categor == 'CUR_2' || categor == 'GD' ? 'close' : 'Off'),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,7 @@ import 'package:syncrow_web/services/api/http_interceptor.dart';
|
|||||||
import 'package:syncrow_web/services/api/http_service.dart';
|
import 'package:syncrow_web/services/api/http_service.dart';
|
||||||
|
|
||||||
final GetIt serviceLocator = GetIt.instance;
|
final GetIt serviceLocator = GetIt.instance;
|
||||||
//setupLocator() // to search for dependency injection in flutter
|
void initialSetup() {
|
||||||
initialSetup() {
|
|
||||||
serviceLocator.registerSingleton<HTTPInterceptor>(HTTPInterceptor());
|
serviceLocator.registerSingleton<HTTPInterceptor>(HTTPInterceptor());
|
||||||
//Base classes
|
|
||||||
serviceLocator.registerSingleton<Dio>(HTTPService.setupDioClient());
|
serviceLocator.registerSingleton<Dio>(HTTPService.setupDioClient());
|
||||||
}
|
}
|
||||||
|
53
lib/syncrow_app.dart
Normal file
53
lib/syncrow_app.dart
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
import 'package:flutter/gestures.dart';
|
||||||
|
import 'package:flutter/material.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/routines/bloc/create_routine_bloc/create_routine_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/visitor_password/bloc/visitor_password_bloc.dart';
|
||||||
|
import 'package:syncrow_web/utils/app_routes.dart';
|
||||||
|
import 'package:syncrow_web/utils/navigation_service.dart';
|
||||||
|
import 'package:syncrow_web/utils/theme/theme.dart';
|
||||||
|
|
||||||
|
class SyncrowApp extends StatelessWidget {
|
||||||
|
const SyncrowApp({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return MultiBlocProvider(
|
||||||
|
providers: [
|
||||||
|
BlocProvider<CreateRoutineBloc>(
|
||||||
|
create: (context) => CreateRoutineBloc(),
|
||||||
|
),
|
||||||
|
BlocProvider(
|
||||||
|
create: (context) => HomeBloc()..add(const FetchUserInfo()),
|
||||||
|
),
|
||||||
|
BlocProvider<VisitorPasswordBloc>(
|
||||||
|
create: (context) => VisitorPasswordBloc(),
|
||||||
|
),
|
||||||
|
BlocProvider<RoutineBloc>(
|
||||||
|
create: (context) => RoutineBloc(),
|
||||||
|
),
|
||||||
|
BlocProvider<SpaceTreeBloc>(
|
||||||
|
create: (context) => SpaceTreeBloc(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
child: MaterialApp.router(
|
||||||
|
debugShowCheckedModeBanner: false,
|
||||||
|
scrollBehavior: const MaterialScrollBehavior().copyWith(
|
||||||
|
dragDevices: {
|
||||||
|
PointerDeviceKind.mouse,
|
||||||
|
PointerDeviceKind.touch,
|
||||||
|
PointerDeviceKind.stylus,
|
||||||
|
PointerDeviceKind.unknown,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
key: NavigationService.navigatorKey,
|
||||||
|
theme: myTheme,
|
||||||
|
routerConfig: AppRoutes.router,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,17 +1,31 @@
|
|||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:syncrow_web/pages/access_management/view/access_management.dart';
|
import 'package:syncrow_web/pages/access_management/view/access_management.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/modules/analytics/views/analytics_page.dart';
|
import 'package:syncrow_web/pages/analytics/modules/analytics/views/analytics_page.dart';
|
||||||
|
import 'package:syncrow_web/pages/auth/bloc/auth_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/auth/view/login_page.dart';
|
import 'package:syncrow_web/pages/auth/view/login_page.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/all_devices/view/device_managment_page.dart';
|
import 'package:syncrow_web/pages/device_managment/all_devices/view/device_managment_page.dart';
|
||||||
import 'package:syncrow_web/pages/home/view/home_page.dart';
|
import 'package:syncrow_web/pages/home/view/home_page.dart';
|
||||||
import 'package:syncrow_web/pages/roles_and_permission/view/roles_and_permission_page.dart';
|
import 'package:syncrow_web/pages/roles_and_permission/view/roles_and_permission_page.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/view/spaces_management_page.dart';
|
import 'package:syncrow_web/pages/space_management_v2/main_module/views/space_management_page.dart';
|
||||||
import 'package:syncrow_web/pages/visitor_password/view/visitor_password_dialog.dart';
|
import 'package:syncrow_web/pages/visitor_password/view/visitor_password_dialog.dart';
|
||||||
import 'package:syncrow_web/utils/constants/routes_const.dart';
|
import 'package:syncrow_web/utils/constants/routes_const.dart';
|
||||||
|
|
||||||
class AppRoutes {
|
abstract final class AppRoutes {
|
||||||
static List<GoRoute> getRoutes() {
|
const AppRoutes._();
|
||||||
return [
|
|
||||||
|
static final GoRouter router = GoRouter(
|
||||||
|
initialLocation: RoutesConst.auth,
|
||||||
|
redirect: (context, state) async {
|
||||||
|
final checkToken = await AuthBloc.getTokenAndValidate();
|
||||||
|
final loggedIn = checkToken == 'Success';
|
||||||
|
final goingToLogin = state.uri.toString() == RoutesConst.auth;
|
||||||
|
|
||||||
|
if (!loggedIn && !goingToLogin) return RoutesConst.auth;
|
||||||
|
if (loggedIn && goingToLogin) return RoutesConst.home;
|
||||||
|
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
routes: [
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: RoutesConst.auth,
|
path: RoutesConst.auth,
|
||||||
builder: (context, state) => const LoginPage(),
|
builder: (context, state) => const LoginPage(),
|
||||||
@ -43,6 +57,6 @@ class AppRoutes {
|
|||||||
name: 'analytics',
|
name: 'analytics',
|
||||||
builder: (context, state) => const AnalyticsPage(),
|
builder: (context, state) => const AnalyticsPage(),
|
||||||
),
|
),
|
||||||
];
|
],
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
|
@ -140,6 +140,7 @@ abstract class ApiEndpoints {
|
|||||||
static const String saveSchedule = '/schedule/{deviceUuid}';
|
static const String saveSchedule = '/schedule/{deviceUuid}';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////booking System
|
////booking System
|
||||||
static const String bookableSpaces = '/bookable-spaces';
|
static const String bookableSpaces = '/bookable-spaces';
|
||||||
static const String getCalendarEvents = '/api';
|
static const String getCalendarEvents = '/api';
|
||||||
|
Reference in New Issue
Block a user