mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-11 15:47:44 +00:00
Compare commits
3 Commits
web_bugs_f
...
bugfix/fix
Author | SHA1 | Date | |
---|---|---|---|
64e3fb7f34 | |||
e6e46be9b4 | |||
91dfd53477 |
@ -46,9 +46,10 @@ class CustomSearchBar extends StatelessWidget {
|
|||||||
filled: true,
|
filled: true,
|
||||||
fillColor: ColorsManager.textFieldGreyColor,
|
fillColor: ColorsManager.textFieldGreyColor,
|
||||||
hintText: hintText,
|
hintText: hintText,
|
||||||
hintStyle: Theme.of(context).textTheme.bodyLarge!.copyWith(
|
hintStyle: TextStyle(
|
||||||
color: ColorsManager.lightGrayColor,
|
color: Color(0xB2999999),
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
|
fontFamily: 'Aftika',
|
||||||
fontWeight: FontWeight.w400,
|
fontWeight: FontWeight.w400,
|
||||||
height: 0,
|
height: 0,
|
||||||
letterSpacing: -0.24,
|
letterSpacing: -0.24,
|
@ -1,25 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
|
|
||||||
|
|
||||||
class SpacesSideTree extends StatefulWidget {
|
|
||||||
final List<CommunityModel> communities;
|
|
||||||
final String? selectedSpaceUuid;
|
|
||||||
const SpacesSideTree({
|
|
||||||
super.key,
|
|
||||||
required this.communities,
|
|
||||||
this.selectedSpaceUuid,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<SpacesSideTree> createState() => _SpacesSideTreeState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _SpacesSideTreeState extends State<SpacesSideTree> {
|
|
||||||
String _searchQuery = '';
|
|
||||||
String? _selectedSpaceUuid;
|
|
||||||
String? _selectedId;
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return const Placeholder();
|
|
||||||
}
|
|
||||||
}
|
|
@ -6,9 +6,7 @@ import 'package:go_router/go_router.dart';
|
|||||||
import 'package:syncrow_web/pages/auth/bloc/auth_bloc.dart';
|
import 'package:syncrow_web/pages/auth/bloc/auth_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/home/bloc/home_bloc.dart';
|
import 'package:syncrow_web/pages/home/bloc/home_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/home/bloc/home_event.dart';
|
import 'package:syncrow_web/pages/home/bloc/home_event.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_event.dart';
|
|
||||||
import 'package:syncrow_web/pages/visitor_password/bloc/visitor_password_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/utils/app_routes.dart';
|
||||||
@ -17,7 +15,8 @@ import 'package:syncrow_web/utils/theme/theme.dart';
|
|||||||
|
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
try {
|
try {
|
||||||
const environment = String.fromEnvironment('FLAVOR', defaultValue: 'development');
|
const environment =
|
||||||
|
String.fromEnvironment('FLAVOR', defaultValue: 'development');
|
||||||
await dotenv.load(fileName: '.env.$environment');
|
await dotenv.load(fileName: '.env.$environment');
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
initialSetup();
|
initialSetup();
|
||||||
@ -49,16 +48,14 @@ class MyApp extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MultiBlocProvider(
|
return MultiBlocProvider(
|
||||||
providers: [
|
providers: [
|
||||||
BlocProvider(create: (context) => HomeBloc()..add(const FetchUserInfo())),
|
BlocProvider(
|
||||||
|
create: (context) => HomeBloc()..add(const FetchUserInfo())),
|
||||||
BlocProvider<VisitorPasswordBloc>(
|
BlocProvider<VisitorPasswordBloc>(
|
||||||
create: (context) => VisitorPasswordBloc(),
|
create: (context) => VisitorPasswordBloc(),
|
||||||
),
|
),
|
||||||
BlocProvider<RoutineBloc>(
|
BlocProvider<RoutineBloc>(
|
||||||
create: (context) => RoutineBloc(),
|
create: (context) => RoutineBloc(),
|
||||||
),
|
),
|
||||||
BlocProvider<SpaceTreeBloc>(
|
|
||||||
create: (context) => SpaceTreeBloc()..add(InitialEvent()),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
child: MaterialApp.router(
|
child: MaterialApp.router(
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
|
@ -31,8 +31,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
|
|
||||||
////////////////////////////// forget password //////////////////////////////////
|
////////////////////////////// forget password //////////////////////////////////
|
||||||
final TextEditingController forgetEmailController = TextEditingController();
|
final TextEditingController forgetEmailController = TextEditingController();
|
||||||
final TextEditingController forgetPasswordController =
|
final TextEditingController forgetPasswordController = TextEditingController();
|
||||||
TextEditingController();
|
|
||||||
final TextEditingController forgetOtp = TextEditingController();
|
final TextEditingController forgetOtp = TextEditingController();
|
||||||
final forgetFormKey = GlobalKey<FormState>();
|
final forgetFormKey = GlobalKey<FormState>();
|
||||||
final forgetEmailKey = GlobalKey<FormState>();
|
final forgetEmailKey = GlobalKey<FormState>();
|
||||||
@ -49,8 +48,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_remainingTime = 1;
|
_remainingTime = 1;
|
||||||
add(UpdateTimerEvent(
|
add(UpdateTimerEvent(remainingTime: _remainingTime, isButtonEnabled: false));
|
||||||
remainingTime: _remainingTime, isButtonEnabled: false));
|
|
||||||
try {
|
try {
|
||||||
forgetEmailValidate = '';
|
forgetEmailValidate = '';
|
||||||
_remainingTime = (await AuthenticationAPI.sendOtp(
|
_remainingTime = (await AuthenticationAPI.sendOtp(
|
||||||
@ -87,8 +85,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
_timer?.cancel();
|
_timer?.cancel();
|
||||||
add(const UpdateTimerEvent(remainingTime: 0, isButtonEnabled: true));
|
add(const UpdateTimerEvent(remainingTime: 0, isButtonEnabled: true));
|
||||||
} else {
|
} else {
|
||||||
add(UpdateTimerEvent(
|
add(UpdateTimerEvent(remainingTime: _remainingTime, isButtonEnabled: false));
|
||||||
remainingTime: _remainingTime, isButtonEnabled: false));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -98,8 +95,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
emit(const TimerState(isButtonEnabled: true, remainingTime: 0));
|
emit(const TimerState(isButtonEnabled: true, remainingTime: 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> changePassword(
|
Future<void> changePassword(ChangePasswordEvent event, Emitter<AuthState> emit) async {
|
||||||
ChangePasswordEvent event, Emitter<AuthState> emit) async {
|
|
||||||
emit(LoadingForgetState());
|
emit(LoadingForgetState());
|
||||||
try {
|
try {
|
||||||
var response = await AuthenticationAPI.verifyOtp(
|
var response = await AuthenticationAPI.verifyOtp(
|
||||||
@ -115,8 +111,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
}
|
}
|
||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
final errorData = e.response!.data;
|
final errorData = e.response!.data;
|
||||||
String errorMessage =
|
String errorMessage = errorData['error']['message'] ?? 'something went wrong';
|
||||||
errorData['error']['message'] ?? 'something went wrong';
|
|
||||||
validate = errorMessage;
|
validate = errorMessage;
|
||||||
emit(AuthInitialState());
|
emit(AuthInitialState());
|
||||||
}
|
}
|
||||||
@ -130,9 +125,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _onUpdateTimer(UpdateTimerEvent event, Emitter<AuthState> emit) {
|
void _onUpdateTimer(UpdateTimerEvent event, Emitter<AuthState> emit) {
|
||||||
emit(TimerState(
|
emit(TimerState(isButtonEnabled: event.isButtonEnabled, remainingTime: event.remainingTime));
|
||||||
isButtonEnabled: event.isButtonEnabled,
|
|
||||||
remainingTime: event.remainingTime));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////// login /////////////////////////////////////
|
///////////////////////////////////// login /////////////////////////////////////
|
||||||
@ -168,23 +161,15 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
password: event.password,
|
password: event.password,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} on DioException catch (e) {
|
} catch (failure) {
|
||||||
final errorData = e.response!.data;
|
|
||||||
String errorMessage = errorData['error']['message'];
|
|
||||||
if (errorMessage == "Access denied for web platform") {
|
|
||||||
validate = errorMessage;
|
|
||||||
} else {
|
|
||||||
validate = 'Invalid Credentials!';
|
validate = 'Invalid Credentials!';
|
||||||
}
|
|
||||||
emit(LoginInitial());
|
emit(LoginInitial());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (token.accessTokenIsNotEmpty) {
|
if (token.accessTokenIsNotEmpty) {
|
||||||
FlutterSecureStorage storage = const FlutterSecureStorage();
|
FlutterSecureStorage storage = const FlutterSecureStorage();
|
||||||
await storage.write(
|
await storage.write(key: Token.loginAccessTokenKey, value: token.accessToken);
|
||||||
key: Token.loginAccessTokenKey, value: token.accessToken);
|
|
||||||
const FlutterSecureStorage().write(
|
const FlutterSecureStorage().write(
|
||||||
key: UserModel.userUuidKey,
|
key: UserModel.userUuidKey,
|
||||||
value: Token.decodeToken(token.accessToken)['uuid'].toString());
|
value: Token.decodeToken(token.accessToken)['uuid'].toString());
|
||||||
@ -342,14 +327,12 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
static Future<String> getTokenAndValidate() async {
|
static Future<String> getTokenAndValidate() async {
|
||||||
try {
|
try {
|
||||||
const storage = FlutterSecureStorage();
|
const storage = FlutterSecureStorage();
|
||||||
final firstLaunch = await SharedPreferencesHelper.readBoolFromSP(
|
final firstLaunch =
|
||||||
StringsManager.firstLaunch) ??
|
await SharedPreferencesHelper.readBoolFromSP(StringsManager.firstLaunch) ?? true;
|
||||||
true;
|
|
||||||
if (firstLaunch) {
|
if (firstLaunch) {
|
||||||
storage.deleteAll();
|
storage.deleteAll();
|
||||||
}
|
}
|
||||||
await SharedPreferencesHelper.saveBoolToSP(
|
await SharedPreferencesHelper.saveBoolToSP(StringsManager.firstLaunch, false);
|
||||||
StringsManager.firstLaunch, false);
|
|
||||||
final value = await storage.read(key: Token.loginAccessTokenKey) ?? '';
|
final value = await storage.read(key: Token.loginAccessTokenKey) ?? '';
|
||||||
if (value.isEmpty) {
|
if (value.isEmpty) {
|
||||||
return 'Token not found';
|
return 'Token not found';
|
||||||
@ -402,9 +385,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
final String formattedTime = [
|
final String formattedTime = [
|
||||||
if (days > 0) '${days}d', // Append 'd' for days
|
if (days > 0) '${days}d', // Append 'd' for days
|
||||||
if (days > 0 || hours > 0)
|
if (days > 0 || hours > 0)
|
||||||
hours
|
hours.toString().padLeft(2, '0'), // Show hours if there are days or hours
|
||||||
.toString()
|
|
||||||
.padLeft(2, '0'), // Show hours if there are days or hours
|
|
||||||
minutes.toString().padLeft(2, '0'),
|
minutes.toString().padLeft(2, '0'),
|
||||||
seconds.toString().padLeft(2, '0'),
|
seconds.toString().padLeft(2, '0'),
|
||||||
].join(':');
|
].join(':');
|
||||||
|
@ -21,9 +21,7 @@ class LoginWithEmailModel {
|
|||||||
return {
|
return {
|
||||||
'email': email,
|
'email': email,
|
||||||
'password': password,
|
'password': password,
|
||||||
"platform": "web"
|
|
||||||
// 'regionUuid': regionUuid,
|
// 'regionUuid': regionUuid,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//tst@tst.com
|
|
@ -10,10 +10,6 @@ class UserModel {
|
|||||||
final String? phoneNumber;
|
final String? phoneNumber;
|
||||||
final bool? isEmailVerified;
|
final bool? isEmailVerified;
|
||||||
final bool? isAgreementAccepted;
|
final bool? isAgreementAccepted;
|
||||||
final bool? hasAcceptedWebAgreement;
|
|
||||||
final DateTime? webAgreementAcceptedAt;
|
|
||||||
final UserRole? role;
|
|
||||||
|
|
||||||
UserModel({
|
UserModel({
|
||||||
required this.uuid,
|
required this.uuid,
|
||||||
required this.email,
|
required this.email,
|
||||||
@ -23,9 +19,6 @@ class UserModel {
|
|||||||
required this.phoneNumber,
|
required this.phoneNumber,
|
||||||
required this.isEmailVerified,
|
required this.isEmailVerified,
|
||||||
required this.isAgreementAccepted,
|
required this.isAgreementAccepted,
|
||||||
required this.hasAcceptedWebAgreement,
|
|
||||||
required this.webAgreementAcceptedAt,
|
|
||||||
required this.role,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
factory UserModel.fromJson(Map<String, dynamic> json) {
|
factory UserModel.fromJson(Map<String, dynamic> json) {
|
||||||
@ -38,11 +31,6 @@ class UserModel {
|
|||||||
phoneNumber: json['phoneNumber'],
|
phoneNumber: json['phoneNumber'],
|
||||||
isEmailVerified: json['isEmailVerified'],
|
isEmailVerified: json['isEmailVerified'],
|
||||||
isAgreementAccepted: json['isAgreementAccepted'],
|
isAgreementAccepted: json['isAgreementAccepted'],
|
||||||
hasAcceptedWebAgreement: json['hasAcceptedWebAgreement'],
|
|
||||||
webAgreementAcceptedAt: json['webAgreementAcceptedAt'] != null
|
|
||||||
? DateTime.parse(json['webAgreementAcceptedAt'])
|
|
||||||
: null,
|
|
||||||
role: json['role'] != null ? UserRole.fromJson(json['role']) : null,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,9 +41,6 @@ class UserModel {
|
|||||||
Map<String, dynamic> tempJson = Token.decodeToken(token.accessToken);
|
Map<String, dynamic> tempJson = Token.decodeToken(token.accessToken);
|
||||||
|
|
||||||
return UserModel(
|
return UserModel(
|
||||||
hasAcceptedWebAgreement: null,
|
|
||||||
role: null,
|
|
||||||
webAgreementAcceptedAt: null,
|
|
||||||
uuid: tempJson['uuid'].toString(),
|
uuid: tempJson['uuid'].toString(),
|
||||||
email: tempJson['email'],
|
email: tempJson['email'],
|
||||||
firstName: null,
|
firstName: null,
|
||||||
@ -80,26 +65,3 @@ class UserModel {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class UserRole {
|
|
||||||
final String uuid;
|
|
||||||
final DateTime createdAt;
|
|
||||||
final DateTime updatedAt;
|
|
||||||
final String type;
|
|
||||||
|
|
||||||
UserRole({
|
|
||||||
required this.uuid,
|
|
||||||
required this.createdAt,
|
|
||||||
required this.updatedAt,
|
|
||||||
required this.type,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory UserRole.fromJson(Map<String, dynamic> json) {
|
|
||||||
return UserRole(
|
|
||||||
uuid: json['uuid'],
|
|
||||||
createdAt: DateTime.parse(json['createdAt']),
|
|
||||||
updatedAt: DateTime.parse(json['updatedAt']),
|
|
||||||
type: json['type'],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -6,7 +6,8 @@ import 'package:syncrow_web/services/devices_mang_api.dart';
|
|||||||
part 'device_managment_event.dart';
|
part 'device_managment_event.dart';
|
||||||
part 'device_managment_state.dart';
|
part 'device_managment_state.dart';
|
||||||
|
|
||||||
class DeviceManagementBloc extends Bloc<DeviceManagementEvent, DeviceManagementState> {
|
class DeviceManagementBloc
|
||||||
|
extends Bloc<DeviceManagementEvent, DeviceManagementState> {
|
||||||
int _selectedIndex = 0;
|
int _selectedIndex = 0;
|
||||||
List<AllDevicesModel> _devices = [];
|
List<AllDevicesModel> _devices = [];
|
||||||
int _onlineCount = 0;
|
int _onlineCount = 0;
|
||||||
@ -29,10 +30,11 @@ class DeviceManagementBloc extends Bloc<DeviceManagementEvent, DeviceManagementS
|
|||||||
on<UpdateSelection>(_onUpdateSelection);
|
on<UpdateSelection>(_onUpdateSelection);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onFetchDevices(FetchDevices event, Emitter<DeviceManagementState> emit) async {
|
Future<void> _onFetchDevices(
|
||||||
|
FetchDevices event, Emitter<DeviceManagementState> emit) async {
|
||||||
emit(DeviceManagementLoading());
|
emit(DeviceManagementLoading());
|
||||||
try {
|
try {
|
||||||
final devices = await DevicesManagementApi().fetchDevices(event.communityId, event.spaceId);
|
final devices = await DevicesManagementApi().fetchDevices();
|
||||||
_selectedDevices.clear();
|
_selectedDevices.clear();
|
||||||
_devices = devices;
|
_devices = devices;
|
||||||
_filteredDevices = devices;
|
_filteredDevices = devices;
|
||||||
@ -51,7 +53,8 @@ class DeviceManagementBloc extends Bloc<DeviceManagementEvent, DeviceManagementS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onFilterDevices(FilterDevices event, Emitter<DeviceManagementState> emit) async {
|
void _onFilterDevices(
|
||||||
|
FilterDevices event, Emitter<DeviceManagementState> emit) async {
|
||||||
if (_devices.isNotEmpty) {
|
if (_devices.isNotEmpty) {
|
||||||
_filteredDevices = List.from(_devices.where((device) {
|
_filteredDevices = List.from(_devices.where((device) {
|
||||||
switch (event.filter) {
|
switch (event.filter) {
|
||||||
@ -82,7 +85,8 @@ class DeviceManagementBloc extends Bloc<DeviceManagementEvent, DeviceManagementS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onResetFilters(ResetFilters event, Emitter<DeviceManagementState> emit) async {
|
Future<void> _onResetFilters(
|
||||||
|
ResetFilters event, Emitter<DeviceManagementState> emit) async {
|
||||||
currentProductName = '';
|
currentProductName = '';
|
||||||
_selectedDevices.clear();
|
_selectedDevices.clear();
|
||||||
_filteredDevices = List.from(_devices);
|
_filteredDevices = List.from(_devices);
|
||||||
@ -98,7 +102,8 @@ class DeviceManagementBloc extends Bloc<DeviceManagementEvent, DeviceManagementS
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onResetSelectedDevices(ResetSelectedDevices event, Emitter<DeviceManagementState> emit) {
|
void _onResetSelectedDevices(
|
||||||
|
ResetSelectedDevices event, Emitter<DeviceManagementState> emit) {
|
||||||
_selectedDevices.clear();
|
_selectedDevices.clear();
|
||||||
|
|
||||||
if (state is DeviceManagementLoaded) {
|
if (state is DeviceManagementLoaded) {
|
||||||
@ -124,12 +129,14 @@ class DeviceManagementBloc extends Bloc<DeviceManagementEvent, DeviceManagementS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onSelectedFilterChanged(SelectedFilterChanged event, Emitter<DeviceManagementState> emit) {
|
void _onSelectedFilterChanged(
|
||||||
|
SelectedFilterChanged event, Emitter<DeviceManagementState> emit) {
|
||||||
_selectedIndex = event.selectedIndex;
|
_selectedIndex = event.selectedIndex;
|
||||||
add(FilterDevices(_getFilterFromIndex(_selectedIndex)));
|
add(FilterDevices(_getFilterFromIndex(_selectedIndex)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onSelectDevice(SelectDevice event, Emitter<DeviceManagementState> emit) {
|
void _onSelectDevice(
|
||||||
|
SelectDevice event, Emitter<DeviceManagementState> emit) {
|
||||||
final selectedUuid = event.selectedDevice.uuid;
|
final selectedUuid = event.selectedDevice.uuid;
|
||||||
|
|
||||||
if (_selectedDevices.any((device) => device.uuid == selectedUuid)) {
|
if (_selectedDevices.any((device) => device.uuid == selectedUuid)) {
|
||||||
@ -140,7 +147,8 @@ class DeviceManagementBloc extends Bloc<DeviceManagementEvent, DeviceManagementS
|
|||||||
|
|
||||||
List<AllDevicesModel> clonedSelectedDevices = List.from(_selectedDevices);
|
List<AllDevicesModel> clonedSelectedDevices = List.from(_selectedDevices);
|
||||||
|
|
||||||
bool isControlButtonEnabled = _checkIfControlButtonEnabled(clonedSelectedDevices);
|
bool isControlButtonEnabled =
|
||||||
|
_checkIfControlButtonEnabled(clonedSelectedDevices);
|
||||||
|
|
||||||
if (state is DeviceManagementLoaded) {
|
if (state is DeviceManagementLoaded) {
|
||||||
emit(DeviceManagementLoaded(
|
emit(DeviceManagementLoaded(
|
||||||
@ -149,7 +157,8 @@ class DeviceManagementBloc extends Bloc<DeviceManagementEvent, DeviceManagementS
|
|||||||
onlineCount: _onlineCount,
|
onlineCount: _onlineCount,
|
||||||
offlineCount: _offlineCount,
|
offlineCount: _offlineCount,
|
||||||
lowBatteryCount: _lowBatteryCount,
|
lowBatteryCount: _lowBatteryCount,
|
||||||
selectedDevice: clonedSelectedDevices.isNotEmpty ? clonedSelectedDevices : null,
|
selectedDevice:
|
||||||
|
clonedSelectedDevices.isNotEmpty ? clonedSelectedDevices : null,
|
||||||
isControlButtonEnabled: isControlButtonEnabled,
|
isControlButtonEnabled: isControlButtonEnabled,
|
||||||
));
|
));
|
||||||
} else if (state is DeviceManagementFiltered) {
|
} else if (state is DeviceManagementFiltered) {
|
||||||
@ -159,13 +168,15 @@ class DeviceManagementBloc extends Bloc<DeviceManagementEvent, DeviceManagementS
|
|||||||
onlineCount: _onlineCount,
|
onlineCount: _onlineCount,
|
||||||
offlineCount: _offlineCount,
|
offlineCount: _offlineCount,
|
||||||
lowBatteryCount: _lowBatteryCount,
|
lowBatteryCount: _lowBatteryCount,
|
||||||
selectedDevice: clonedSelectedDevices.isNotEmpty ? clonedSelectedDevices : null,
|
selectedDevice:
|
||||||
|
clonedSelectedDevices.isNotEmpty ? clonedSelectedDevices : null,
|
||||||
isControlButtonEnabled: isControlButtonEnabled,
|
isControlButtonEnabled: isControlButtonEnabled,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onUpdateSelection(UpdateSelection event, Emitter<DeviceManagementState> emit) {
|
void _onUpdateSelection(
|
||||||
|
UpdateSelection event, Emitter<DeviceManagementState> emit) {
|
||||||
List<AllDevicesModel> selectedDevices = [];
|
List<AllDevicesModel> selectedDevices = [];
|
||||||
List<AllDevicesModel> devicesToSelectFrom = [];
|
List<AllDevicesModel> devicesToSelectFrom = [];
|
||||||
|
|
||||||
@ -208,7 +219,8 @@ class DeviceManagementBloc extends Bloc<DeviceManagementEvent, DeviceManagementS
|
|||||||
|
|
||||||
bool _checkIfControlButtonEnabled(List<AllDevicesModel> selectedDevices) {
|
bool _checkIfControlButtonEnabled(List<AllDevicesModel> selectedDevices) {
|
||||||
if (selectedDevices.length > 1) {
|
if (selectedDevices.length > 1) {
|
||||||
final productTypes = selectedDevices.map((device) => device.productType).toSet();
|
final productTypes =
|
||||||
|
selectedDevices.map((device) => device.productType).toSet();
|
||||||
return productTypes.length == 1;
|
return productTypes.length == 1;
|
||||||
} else if (selectedDevices.length == 1) {
|
} else if (selectedDevices.length == 1) {
|
||||||
return true;
|
return true;
|
||||||
@ -219,8 +231,10 @@ class DeviceManagementBloc extends Bloc<DeviceManagementEvent, DeviceManagementS
|
|||||||
void _calculateDeviceCounts() {
|
void _calculateDeviceCounts() {
|
||||||
_onlineCount = _devices.where((device) => device.online == true).length;
|
_onlineCount = _devices.where((device) => device.online == true).length;
|
||||||
_offlineCount = _devices.where((device) => device.online == false).length;
|
_offlineCount = _devices.where((device) => device.online == false).length;
|
||||||
_lowBatteryCount =
|
_lowBatteryCount = _devices
|
||||||
_devices.where((device) => device.batteryLevel != null && device.batteryLevel! < 20).length;
|
.where((device) =>
|
||||||
|
device.batteryLevel != null && device.batteryLevel! < 20)
|
||||||
|
.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
String _getFilterFromIndex(int index) {
|
String _getFilterFromIndex(int index) {
|
||||||
@ -236,7 +250,8 @@ class DeviceManagementBloc extends Bloc<DeviceManagementEvent, DeviceManagementS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onSearchDevices(SearchDevices event, Emitter<DeviceManagementState> emit) {
|
void _onSearchDevices(
|
||||||
|
SearchDevices event, Emitter<DeviceManagementState> emit) {
|
||||||
if ((event.community == null || event.community!.isEmpty) &&
|
if ((event.community == null || event.community!.isEmpty) &&
|
||||||
(event.unitName == null || event.unitName!.isEmpty) &&
|
(event.unitName == null || event.unitName!.isEmpty) &&
|
||||||
(event.productName == null || event.productName!.isEmpty)) {
|
(event.productName == null || event.productName!.isEmpty)) {
|
||||||
@ -265,22 +280,33 @@ class DeviceManagementBloc extends Bloc<DeviceManagementEvent, DeviceManagementS
|
|||||||
final filteredDevices = devicesToSearch.where((device) {
|
final filteredDevices = devicesToSearch.where((device) {
|
||||||
final matchesCommunity = event.community == null ||
|
final matchesCommunity = event.community == null ||
|
||||||
event.community!.isEmpty ||
|
event.community!.isEmpty ||
|
||||||
(device.community?.name?.toLowerCase().contains(event.community!.toLowerCase()) ??
|
(device.community?.name
|
||||||
|
?.toLowerCase()
|
||||||
|
.contains(event.community!.toLowerCase()) ??
|
||||||
false);
|
false);
|
||||||
final matchesUnit = event.unitName == null ||
|
final matchesUnit = event.unitName == null ||
|
||||||
event.unitName!.isEmpty ||
|
event.unitName!.isEmpty ||
|
||||||
(device.spaces != null &&
|
(device.spaces != null &&
|
||||||
device.spaces!.isNotEmpty &&
|
device.spaces!.isNotEmpty &&
|
||||||
device.spaces![0].spaceName!.toLowerCase().contains(event.unitName!.toLowerCase()));
|
device.spaces![0].spaceName
|
||||||
|
!.toLowerCase()
|
||||||
|
.contains(event.unitName!.toLowerCase()));
|
||||||
final matchesProductName = event.productName == null ||
|
final matchesProductName = event.productName == null ||
|
||||||
event.productName!.isEmpty ||
|
event.productName!.isEmpty ||
|
||||||
(device.name?.toLowerCase().contains(event.productName!.toLowerCase()) ?? false);
|
(device.name
|
||||||
|
?.toLowerCase()
|
||||||
|
.contains(event.productName!.toLowerCase()) ??
|
||||||
|
false);
|
||||||
final matchesDeviceName = event.productName == null ||
|
final matchesDeviceName = event.productName == null ||
|
||||||
event.productName!.isEmpty ||
|
event.productName!.isEmpty ||
|
||||||
(device.categoryName?.toLowerCase().contains(event.productName!.toLowerCase()) ??
|
(device.categoryName
|
||||||
|
?.toLowerCase()
|
||||||
|
.contains(event.productName!.toLowerCase()) ??
|
||||||
false);
|
false);
|
||||||
|
|
||||||
return matchesCommunity && matchesUnit && (matchesProductName || matchesDeviceName);
|
return matchesCommunity &&
|
||||||
|
matchesUnit &&
|
||||||
|
(matchesProductName || matchesDeviceName);
|
||||||
}).toList();
|
}).toList();
|
||||||
|
|
||||||
emit(DeviceManagementFiltered(
|
emit(DeviceManagementFiltered(
|
||||||
|
@ -7,14 +7,7 @@ abstract class DeviceManagementEvent extends Equatable {
|
|||||||
List<Object?> get props => [];
|
List<Object?> get props => [];
|
||||||
}
|
}
|
||||||
|
|
||||||
class FetchDevices extends DeviceManagementEvent {
|
class FetchDevices extends DeviceManagementEvent {}
|
||||||
final String communityId;
|
|
||||||
final String spaceId;
|
|
||||||
|
|
||||||
const FetchDevices(this.communityId, this.spaceId);
|
|
||||||
@override
|
|
||||||
List<Object?> get props => [communityId, spaceId];
|
|
||||||
}
|
|
||||||
|
|
||||||
class FilterDevices extends DeviceManagementEvent {
|
class FilterDevices extends DeviceManagementEvent {
|
||||||
final String filter;
|
final String filter;
|
||||||
|
@ -3,11 +3,11 @@ import 'package:syncrow_web/pages/device_managment/all_devices/models/device_spa
|
|||||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_subspace.model.dart';
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_subspace.model.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/room.dart';
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/room.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/unit.dart';
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/unit.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/ac/ac_function.dart';
|
import 'package:syncrow_web/pages/routiens/models/ac/ac_function.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
import 'package:syncrow_web/pages/routiens/models/device_functions.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/gang_switches/one_gang_switch/one_gang_switch.dart';
|
import 'package:syncrow_web/pages/routiens/models/gang_switches/one_gang_switch/one_gang_switch.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/gang_switches/three_gang_switch/three_gang_switch.dart';
|
import 'package:syncrow_web/pages/routiens/models/gang_switches/three_gang_switch/three_gang_switch.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/gang_switches/two_gang_switch/two_gang_switch.dart';
|
import 'package:syncrow_web/pages/routiens/models/gang_switches/two_gang_switch/two_gang_switch.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
import 'package:syncrow_web/utils/enum/device_types.dart';
|
import 'package:syncrow_web/utils/enum/device_types.dart';
|
||||||
|
|
||||||
@ -148,7 +148,9 @@ class AllDevicesModel {
|
|||||||
|
|
||||||
productName = json['productName']?.toString();
|
productName = json['productName']?.toString();
|
||||||
if (json['spaces'] != null && json['spaces'] is List) {
|
if (json['spaces'] != null && json['spaces'] is List) {
|
||||||
spaces = (json['spaces'] as List).map((space) => DeviceSpaceModel.fromJson(space)).toList();
|
spaces = (json['spaces'] as List)
|
||||||
|
.map((space) => DeviceSpaceModel.fromJson(space))
|
||||||
|
.toList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,7 +198,8 @@ SOS
|
|||||||
String tempIcon = '';
|
String tempIcon = '';
|
||||||
if (type == DeviceType.LightBulb) {
|
if (type == DeviceType.LightBulb) {
|
||||||
tempIcon = Assets.lightBulb;
|
tempIcon = Assets.lightBulb;
|
||||||
} else if (type == DeviceType.CeilingSensor || type == DeviceType.WallSensor) {
|
} else if (type == DeviceType.CeilingSensor ||
|
||||||
|
type == DeviceType.WallSensor) {
|
||||||
tempIcon = Assets.sensors;
|
tempIcon = Assets.sensors;
|
||||||
} else if (type == DeviceType.AC) {
|
} else if (type == DeviceType.AC) {
|
||||||
tempIcon = Assets.ac;
|
tempIcon = Assets.ac;
|
||||||
@ -251,25 +254,34 @@ SOS
|
|||||||
case '1G':
|
case '1G':
|
||||||
return [
|
return [
|
||||||
OneGangSwitchFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
|
OneGangSwitchFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||||
OneGangCountdownFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
|
OneGangCountdownFunction(
|
||||||
|
deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||||
];
|
];
|
||||||
|
|
||||||
case '2G':
|
case '2G':
|
||||||
return [
|
return [
|
||||||
TwoGangSwitch1Function(deviceId: uuid ?? '', deviceName: name ?? ''),
|
TwoGangSwitch1Function(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||||
TwoGangSwitch2Function(deviceId: uuid ?? '', deviceName: name ?? ''),
|
TwoGangSwitch2Function(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||||
TwoGangCountdown1Function(deviceId: uuid ?? '', deviceName: name ?? ''),
|
TwoGangCountdown1Function(
|
||||||
TwoGangCountdown2Function(deviceId: uuid ?? '', deviceName: name ?? ''),
|
deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||||
|
TwoGangCountdown2Function(
|
||||||
|
deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||||
];
|
];
|
||||||
|
|
||||||
case '3G':
|
case '3G':
|
||||||
return [
|
return [
|
||||||
ThreeGangSwitch1Function(deviceId: uuid ?? '', deviceName: name ?? ''),
|
ThreeGangSwitch1Function(
|
||||||
ThreeGangSwitch2Function(deviceId: uuid ?? '', deviceName: name ?? ''),
|
deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||||
ThreeGangSwitch3Function(deviceId: uuid ?? '', deviceName: name ?? ''),
|
ThreeGangSwitch2Function(
|
||||||
ThreeGangCountdown1Function(deviceId: uuid ?? '', deviceName: name ?? ''),
|
deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||||
ThreeGangCountdown2Function(deviceId: uuid ?? '', deviceName: name ?? ''),
|
ThreeGangSwitch3Function(
|
||||||
ThreeGangCountdown3Function(deviceId: uuid ?? '', deviceName: name ?? ''),
|
deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||||
|
ThreeGangCountdown1Function(
|
||||||
|
deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||||
|
ThreeGangCountdown2Function(
|
||||||
|
deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||||
|
ThreeGangCountdown3Function(
|
||||||
|
deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||||
];
|
];
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -3,9 +3,9 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||||||
import 'package:syncrow_web/pages/device_managment/all_devices/bloc/device_mgmt_bloc/device_managment_bloc.dart';
|
import 'package:syncrow_web/pages/device_managment/all_devices/bloc/device_mgmt_bloc/device_managment_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/all_devices/widgets/device_managment_body.dart';
|
import 'package:syncrow_web/pages/device_managment/all_devices/widgets/device_managment_body.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/shared/navigate_home_grid_view.dart';
|
import 'package:syncrow_web/pages/device_managment/shared/navigate_home_grid_view.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/view/create_new_routine_view.dart';
|
import 'package:syncrow_web/pages/routiens/view/create_new_routine_view.dart';
|
||||||
import 'package:syncrow_web/pages/routines/view/routines_view.dart';
|
import 'package:syncrow_web/pages/routiens/view/routines_view.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
||||||
@ -19,7 +19,7 @@ class DeviceManagementPage extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
return MultiBlocProvider(
|
return MultiBlocProvider(
|
||||||
providers: [
|
providers: [
|
||||||
BlocProvider(
|
BlocProvider(
|
||||||
create: (context) => DeviceManagementBloc()..add(const FetchDevices('', '')),
|
create: (context) => DeviceManagementBloc()..add(FetchDevices()),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
child: WebScaffold(
|
child: WebScaffold(
|
||||||
@ -80,7 +80,7 @@ class DeviceManagementPage extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
return BlocBuilder<DeviceManagementBloc, DeviceManagementState>(
|
return BlocBuilder<DeviceManagementBloc, DeviceManagementState>(
|
||||||
builder: (context, deviceState) {
|
builder: (context, deviceState) {
|
||||||
if (deviceState is DeviceManagementLoading) {
|
if (deviceState is DeviceManagementLoading) {
|
||||||
return const DeviceManagementBody(devices: []);
|
return const Center(child: CircularProgressIndicator());
|
||||||
} else if (deviceState is DeviceManagementLoaded) {
|
} else if (deviceState is DeviceManagementLoaded) {
|
||||||
return DeviceManagementBody(devices: deviceState.devices);
|
return DeviceManagementBody(devices: deviceState.devices);
|
||||||
} else if (deviceState is DeviceManagementFiltered) {
|
} else if (deviceState is DeviceManagementFiltered) {
|
||||||
|
@ -8,7 +8,6 @@ import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_mo
|
|||||||
import 'package:syncrow_web/pages/device_managment/all_devices/widgets/device_search_filters.dart';
|
import 'package:syncrow_web/pages/device_managment/all_devices/widgets/device_search_filters.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/shared/device_batch_control_dialog.dart';
|
import 'package:syncrow_web/pages/device_managment/shared/device_batch_control_dialog.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/shared/device_control_dialog.dart';
|
import 'package:syncrow_web/pages/device_managment/shared/device_control_dialog.dart';
|
||||||
import 'package:syncrow_web/pages/space_tree/view/space_tree_view.dart';
|
|
||||||
import 'package:syncrow_web/utils/format_date_time.dart';
|
import 'package:syncrow_web/utils/format_date_time.dart';
|
||||||
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
||||||
import 'package:syncrow_web/utils/style.dart';
|
import 'package:syncrow_web/utils/style.dart';
|
||||||
@ -60,24 +59,10 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
|
|
||||||
final buttonLabel = (selectedDevices.length > 1) ? 'Batch Control' : 'Control';
|
final buttonLabel = (selectedDevices.length > 1) ? 'Batch Control' : 'Control';
|
||||||
|
|
||||||
return Row(
|
return Column(
|
||||||
children: [
|
|
||||||
const Expanded(
|
|
||||||
child: SpaceTreeView(
|
|
||||||
// onSelectAction: (String communityId, String spaceId) {
|
|
||||||
// context.read<DeviceManagementBloc>().add(FetchDevices(communityId, spaceId));
|
|
||||||
// },
|
|
||||||
)),
|
|
||||||
Expanded(
|
|
||||||
flex: 3,
|
|
||||||
child: state is DeviceManagementLoading
|
|
||||||
? const Center(child: CircularProgressIndicator())
|
|
||||||
: Column(
|
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
padding: isLargeScreenSize(context)
|
padding: isLargeScreenSize(context) ? const EdgeInsets.all(30) : const EdgeInsets.all(15),
|
||||||
? const EdgeInsets.all(30)
|
|
||||||
: const EdgeInsets.all(15),
|
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@ -86,9 +71,7 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
tabs: tabs,
|
tabs: tabs,
|
||||||
selectedIndex: selectedIndex,
|
selectedIndex: selectedIndex,
|
||||||
onTabChanged: (index) {
|
onTabChanged: (index) {
|
||||||
context
|
context.read<DeviceManagementBloc>().add(SelectedFilterChanged(index));
|
||||||
.read<DeviceManagementBloc>()
|
|
||||||
.add(SelectedFilterChanged(index));
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
@ -110,9 +93,7 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else if (selectedDevices.length > 1) {
|
} else if (selectedDevices.length > 1) {
|
||||||
final productTypes = selectedDevices
|
final productTypes = selectedDevices.map((device) => device.productType).toSet();
|
||||||
.map((device) => device.productType)
|
|
||||||
.toSet();
|
|
||||||
if (productTypes.length == 1) {
|
if (productTypes.length == 1) {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
@ -141,17 +122,13 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: isLargeScreenSize(context)
|
padding: isLargeScreenSize(context) ? const EdgeInsets.all(30) : const EdgeInsets.all(15),
|
||||||
? const EdgeInsets.all(30)
|
|
||||||
: const EdgeInsets.all(15),
|
|
||||||
child: DynamicTable(
|
child: DynamicTable(
|
||||||
withSelectAll: true,
|
withSelectAll: true,
|
||||||
cellDecoration: containerDecoration,
|
cellDecoration: containerDecoration,
|
||||||
onRowSelected: (index, isSelected, row) {
|
onRowSelected: (index, isSelected, row) {
|
||||||
final selectedDevice = devicesToShow[index];
|
final selectedDevice = devicesToShow[index];
|
||||||
context
|
context.read<DeviceManagementBloc>().add(SelectDevice(selectedDevice));
|
||||||
.read<DeviceManagementBloc>()
|
|
||||||
.add(SelectDevice(selectedDevice));
|
|
||||||
},
|
},
|
||||||
withCheckBox: true,
|
withCheckBox: true,
|
||||||
size: MediaQuery.of(context).size,
|
size: MediaQuery.of(context).size,
|
||||||
@ -170,45 +147,31 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
data: devicesToShow.map((device) {
|
data: devicesToShow.map((device) {
|
||||||
final combinedSpaceNames = device.spaces != null
|
final combinedSpaceNames = device.spaces != null
|
||||||
? device.spaces!.map((space) => space.spaceName).join(' > ') +
|
? device.spaces!.map((space) => space.spaceName).join(' > ') +
|
||||||
(device.community != null
|
(device.community != null ? ' > ${device.community!.name}' : '')
|
||||||
? ' > ${device.community!.name}'
|
|
||||||
: '')
|
|
||||||
: (device.community != null ? device.community!.name : '');
|
: (device.community != null ? device.community!.name : '');
|
||||||
|
|
||||||
return [
|
return [
|
||||||
device.name ?? '',
|
device.name ?? '',
|
||||||
device.productName ?? '',
|
device.productName ?? '',
|
||||||
device.uuid ?? '',
|
device.uuid ?? '',
|
||||||
(device.spaces != null && device.spaces!.isNotEmpty)
|
(device.spaces != null && device.spaces!.isNotEmpty) ? device.spaces![0].spaceName : '',
|
||||||
? device.spaces![0].spaceName
|
|
||||||
: '',
|
|
||||||
combinedSpaceNames,
|
combinedSpaceNames,
|
||||||
device.batteryLevel != null ? '${device.batteryLevel}%' : '-',
|
device.batteryLevel != null ? '${device.batteryLevel}%' : '-',
|
||||||
formatDateTime(DateTime.fromMillisecondsSinceEpoch(
|
formatDateTime(DateTime.fromMillisecondsSinceEpoch((device.createTime ?? 0) * 1000)),
|
||||||
(device.createTime ?? 0) * 1000)),
|
|
||||||
device.online == true ? 'Online' : 'Offline',
|
device.online == true ? 'Online' : 'Offline',
|
||||||
formatDateTime(DateTime.fromMillisecondsSinceEpoch(
|
formatDateTime(DateTime.fromMillisecondsSinceEpoch((device.updateTime ?? 0) * 1000)),
|
||||||
(device.updateTime ?? 0) * 1000)),
|
|
||||||
];
|
];
|
||||||
}).toList(),
|
}).toList(),
|
||||||
onSelectionChanged: (selectedRows) {
|
onSelectionChanged: (selectedRows) {
|
||||||
context
|
context.read<DeviceManagementBloc>().add(UpdateSelection(selectedRows));
|
||||||
.read<DeviceManagementBloc>()
|
|
||||||
.add(UpdateSelection(selectedRows));
|
|
||||||
},
|
},
|
||||||
initialSelectedIds: context
|
initialSelectedIds:
|
||||||
.read<DeviceManagementBloc>()
|
context.read<DeviceManagementBloc>().selectedDevices.map((device) => device.uuid!).toList(),
|
||||||
.selectedDevices
|
|
||||||
.map((device) => device.uuid!)
|
|
||||||
.toList(),
|
|
||||||
isEmpty: devicesToShow.isEmpty,
|
isEmpty: devicesToShow.isEmpty,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -12,7 +12,8 @@ class DeviceSearchFilters extends StatefulWidget {
|
|||||||
State<DeviceSearchFilters> createState() => _DeviceSearchFiltersState();
|
State<DeviceSearchFilters> createState() => _DeviceSearchFiltersState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _DeviceSearchFiltersState extends State<DeviceSearchFilters> with HelperResponsiveLayout {
|
class _DeviceSearchFiltersState extends State<DeviceSearchFilters>
|
||||||
|
with HelperResponsiveLayout {
|
||||||
final TextEditingController communityController = TextEditingController();
|
final TextEditingController communityController = TextEditingController();
|
||||||
final TextEditingController unitNameController = TextEditingController();
|
final TextEditingController unitNameController = TextEditingController();
|
||||||
final TextEditingController productNameController = TextEditingController();
|
final TextEditingController productNameController = TextEditingController();
|
||||||
@ -26,7 +27,8 @@ class _DeviceSearchFiltersState extends State<DeviceSearchFilters> with HelperRe
|
|||||||
const SizedBox(width: 20),
|
const SizedBox(width: 20),
|
||||||
_buildSearchField("Space Name", unitNameController, 200),
|
_buildSearchField("Space Name", unitNameController, 200),
|
||||||
const SizedBox(width: 20),
|
const SizedBox(width: 20),
|
||||||
_buildSearchField("Device Name / Product Name", productNameController, 300),
|
_buildSearchField(
|
||||||
|
"Device Name / Product Name", productNameController, 300),
|
||||||
const SizedBox(width: 20),
|
const SizedBox(width: 20),
|
||||||
_buildSearchResetButtons(),
|
_buildSearchResetButtons(),
|
||||||
],
|
],
|
||||||
@ -51,7 +53,8 @@ class _DeviceSearchFiltersState extends State<DeviceSearchFilters> with HelperRe
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildSearchField(String title, TextEditingController controller, double width) {
|
Widget _buildSearchField(
|
||||||
|
String title, TextEditingController controller, double width) {
|
||||||
return Container(
|
return Container(
|
||||||
child: StatefulTextField(
|
child: StatefulTextField(
|
||||||
title: title,
|
title: title,
|
||||||
@ -85,7 +88,7 @@ class _DeviceSearchFiltersState extends State<DeviceSearchFilters> with HelperRe
|
|||||||
productNameController.clear();
|
productNameController.clear();
|
||||||
context.read<DeviceManagementBloc>()
|
context.read<DeviceManagementBloc>()
|
||||||
..add(ResetFilters())
|
..add(ResetFilters())
|
||||||
..add(const FetchDevices('', ''));
|
..add(FetchDevices());
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,96 +1,56 @@
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
// import 'package:graphview/GraphView.dart';
|
import 'package:graphview/GraphView.dart';
|
||||||
import 'package:syncrow_web/pages/auth/model/user_model.dart';
|
import 'package:syncrow_web/pages/auth/model/user_model.dart';
|
||||||
import 'package:syncrow_web/pages/home/bloc/home_event.dart';
|
import 'package:syncrow_web/pages/home/bloc/home_event.dart';
|
||||||
import 'package:syncrow_web/pages/home/bloc/home_state.dart';
|
import 'package:syncrow_web/pages/home/bloc/home_state.dart';
|
||||||
import 'package:syncrow_web/pages/home/home_model/home_item_model.dart';
|
import 'package:syncrow_web/pages/home/home_model/home_item_model.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/services/home_api.dart';
|
import 'package:syncrow_web/services/home_api.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';
|
||||||
import 'package:syncrow_web/utils/constants/routes_const.dart';
|
import 'package:syncrow_web/utils/constants/routes_const.dart';
|
||||||
|
|
||||||
class HomeBloc extends Bloc<HomeEvent, HomeState> {
|
class HomeBloc extends Bloc<HomeEvent, HomeState> {
|
||||||
// final Graph graph = Graph()..isTree = true;
|
final Graph graph = Graph()..isTree = true;
|
||||||
// final BuchheimWalkerConfiguration builder = BuchheimWalkerConfiguration();
|
final BuchheimWalkerConfiguration builder = BuchheimWalkerConfiguration();
|
||||||
// List<Node> sourcesList = [];
|
List<Node> sourcesList = [];
|
||||||
// List<Node> destinationsList = [];
|
List<Node> destinationsList = [];
|
||||||
UserModel? user;
|
UserModel? user;
|
||||||
String terms = '';
|
|
||||||
String policy = '';
|
|
||||||
|
|
||||||
HomeBloc() : super((HomeInitial())) {
|
HomeBloc() : super((HomeInitial())) {
|
||||||
// on<CreateNewNode>(_createNode);
|
on<CreateNewNode>(_createNode);
|
||||||
on<FetchUserInfo>(_fetchUserInfo);
|
on<FetchUserInfo>(_fetchUserInfo);
|
||||||
on<FetchTermEvent>(_fetchTerms);
|
|
||||||
on<FetchPolicyEvent>(_fetchPolicy);
|
|
||||||
on<ConfirmUserAgreementEvent>(_confirmUserAgreement);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// void _createNode(CreateNewNode event, Emitter<HomeState> emit) async {
|
void _createNode(CreateNewNode event, Emitter<HomeState> emit) async {
|
||||||
// emit(HomeInitial());
|
emit(HomeInitial());
|
||||||
// sourcesList.add(event.sourceNode);
|
sourcesList.add(event.sourceNode);
|
||||||
// destinationsList.add(event.destinationNode);
|
destinationsList.add(event.destinationNode);
|
||||||
// for (int i = 0; i < sourcesList.length; i++) {
|
for (int i = 0; i < sourcesList.length; i++) {
|
||||||
// graph.addEdge(sourcesList[i], destinationsList[i]);
|
graph.addEdge(sourcesList[i], destinationsList[i]);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// builder
|
builder
|
||||||
// ..siblingSeparation = (100)
|
..siblingSeparation = (100)
|
||||||
// ..levelSeparation = (150)
|
..levelSeparation = (150)
|
||||||
// ..subtreeSeparation = (150)
|
..subtreeSeparation = (150)
|
||||||
// ..orientation = (BuchheimWalkerConfiguration.ORIENTATION_TOP_BOTTOM);
|
..orientation = (BuchheimWalkerConfiguration.ORIENTATION_TOP_BOTTOM);
|
||||||
// emit(HomeUpdateTree(graph: graph, builder: builder));
|
emit(HomeUpdateTree(graph: graph, builder: builder));
|
||||||
// }
|
}
|
||||||
|
|
||||||
Future _fetchUserInfo(FetchUserInfo event, Emitter<HomeState> emit) async {
|
Future _fetchUserInfo(FetchUserInfo event, Emitter<HomeState> emit) async {
|
||||||
try {
|
try {
|
||||||
var uuid =
|
var uuid =
|
||||||
await const FlutterSecureStorage().read(key: UserModel.userUuidKey);
|
await const FlutterSecureStorage().read(key: UserModel.userUuidKey);
|
||||||
user = await HomeApi().fetchUserInfo(uuid);
|
user = await HomeApi().fetchUserInfo(uuid);
|
||||||
add(FetchTermEvent());
|
|
||||||
emit(HomeInitial());
|
emit(HomeInitial());
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future _fetchTerms(FetchTermEvent event, Emitter<HomeState> emit) async {
|
|
||||||
try {
|
|
||||||
emit(LoadingHome());
|
|
||||||
terms = await HomeApi().fetchTerms();
|
|
||||||
add(FetchPolicyEvent());
|
|
||||||
emit(PolicyAgreement());
|
|
||||||
} catch (e) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future _fetchPolicy(FetchPolicyEvent event, Emitter<HomeState> emit) async {
|
|
||||||
try {
|
|
||||||
emit(LoadingHome());
|
|
||||||
policy = await HomeApi().fetchPolicy();
|
|
||||||
emit(PolicyAgreement());
|
|
||||||
} catch (e) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future _confirmUserAgreement(
|
|
||||||
ConfirmUserAgreementEvent event, Emitter<HomeState> emit) async {
|
|
||||||
try {
|
|
||||||
emit(LoadingHome());
|
|
||||||
var uuid =
|
|
||||||
await const FlutterSecureStorage().read(key: UserModel.userUuidKey);
|
|
||||||
policy = await HomeApi().confirmUserAgreements(uuid);
|
|
||||||
emit(PolicyAgreement());
|
|
||||||
} catch (e) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// static Future fetchUserInfo() async {
|
// static Future fetchUserInfo() async {
|
||||||
// try {
|
// try {
|
||||||
// var uuid =
|
// var uuid =
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
// import 'package:graphview/GraphView.dart';
|
import 'package:graphview/GraphView.dart';
|
||||||
|
|
||||||
abstract class HomeEvent extends Equatable {
|
abstract class HomeEvent extends Equatable {
|
||||||
const HomeEvent();
|
const HomeEvent();
|
||||||
@ -8,22 +8,16 @@ abstract class HomeEvent extends Equatable {
|
|||||||
List<Object> get props => [];
|
List<Object> get props => [];
|
||||||
}
|
}
|
||||||
|
|
||||||
// class CreateNewNode extends HomeEvent {
|
class CreateNewNode extends HomeEvent {
|
||||||
// final Node sourceNode;
|
final Node sourceNode;
|
||||||
// final Node destinationNode;
|
final Node destinationNode;
|
||||||
// const CreateNewNode(
|
const CreateNewNode(
|
||||||
// {required this.sourceNode, required this.destinationNode});
|
{required this.sourceNode, required this.destinationNode});
|
||||||
|
|
||||||
// @override
|
@override
|
||||||
// List<Object> get props => [sourceNode, destinationNode];
|
List<Object> get props => [sourceNode, destinationNode];
|
||||||
// }
|
}
|
||||||
|
|
||||||
class FetchUserInfo extends HomeEvent {
|
class FetchUserInfo extends HomeEvent {
|
||||||
const FetchUserInfo();
|
const FetchUserInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
class FetchTermEvent extends HomeEvent {}
|
|
||||||
|
|
||||||
class FetchPolicyEvent extends HomeEvent {}
|
|
||||||
|
|
||||||
class ConfirmUserAgreementEvent extends HomeEvent {}
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
// import 'package:graphview/GraphView.dart';
|
import 'package:graphview/GraphView.dart';
|
||||||
|
|
||||||
abstract class HomeState extends Equatable {
|
abstract class HomeState extends Equatable {
|
||||||
const HomeState();
|
const HomeState();
|
||||||
@ -8,25 +8,19 @@ abstract class HomeState extends Equatable {
|
|||||||
List<Object> get props => [];
|
List<Object> get props => [];
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadingHome extends HomeState {}
|
|
||||||
|
|
||||||
class HomeInitial extends HomeState {}
|
class HomeInitial extends HomeState {}
|
||||||
|
|
||||||
class TermsAgreement extends HomeState {}
|
class HomeCounterState extends HomeState {
|
||||||
|
final int counter;
|
||||||
|
const HomeCounterState(this.counter);
|
||||||
|
}
|
||||||
|
|
||||||
class PolicyAgreement extends HomeState {}
|
class HomeUpdateTree extends HomeState {
|
||||||
|
final Graph graph;
|
||||||
|
final BuchheimWalkerConfiguration builder;
|
||||||
|
|
||||||
// class HomeCounterState extends HomeState {
|
const HomeUpdateTree({required this.graph, required this.builder});
|
||||||
// final int counter;
|
|
||||||
// const HomeCounterState(this.counter);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// class HomeUpdateTree extends HomeState {
|
@override
|
||||||
// final Graph graph;
|
List<Object> get props => [graph, builder];
|
||||||
// final BuchheimWalkerConfiguration builder;
|
}
|
||||||
|
|
||||||
// const HomeUpdateTree({required this.graph, required this.builder});
|
|
||||||
|
|
||||||
// @override
|
|
||||||
// List<Object> get props => [graph, builder];
|
|
||||||
// }
|
|
||||||
|
@ -1,178 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_html/flutter_html.dart';
|
|
||||||
import 'package:go_router/go_router.dart';
|
|
||||||
import 'package:syncrow_web/pages/auth/bloc/auth_bloc.dart';
|
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
|
||||||
import 'package:syncrow_web/utils/constants/routes_const.dart';
|
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
|
||||||
|
|
||||||
class AgreementAndPrivacyDialog extends StatefulWidget {
|
|
||||||
final String terms;
|
|
||||||
final String policy;
|
|
||||||
|
|
||||||
const AgreementAndPrivacyDialog({
|
|
||||||
super.key,
|
|
||||||
required this.terms,
|
|
||||||
required this.policy,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
_AgreementAndPrivacyDialogState createState() =>
|
|
||||||
_AgreementAndPrivacyDialogState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _AgreementAndPrivacyDialogState extends State<AgreementAndPrivacyDialog> {
|
|
||||||
final ScrollController _scrollController = ScrollController();
|
|
||||||
bool _isAtEnd = false;
|
|
||||||
int _currentPage = 1;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
_scrollController.addListener(_onScroll);
|
|
||||||
WidgetsBinding.instance
|
|
||||||
.addPostFrameCallback((_) => _checkScrollRequirement());
|
|
||||||
}
|
|
||||||
|
|
||||||
void _checkScrollRequirement() {
|
|
||||||
final scrollPosition = _scrollController.position;
|
|
||||||
if (scrollPosition.maxScrollExtent <= 0) {
|
|
||||||
setState(() {
|
|
||||||
_isAtEnd = true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_scrollController.removeListener(_onScroll);
|
|
||||||
_scrollController.dispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
void _onScroll() {
|
|
||||||
if (_scrollController.position.atEdge) {
|
|
||||||
final isAtBottom = _scrollController.position.pixels ==
|
|
||||||
_scrollController.position.maxScrollExtent;
|
|
||||||
if (isAtBottom && !_isAtEnd) {
|
|
||||||
setState(() {
|
|
||||||
_isAtEnd = true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String get _dialogTitle =>
|
|
||||||
_currentPage == 1 ? 'User Agreement' : 'Privacy Policy';
|
|
||||||
|
|
||||||
String get _dialogContent => _currentPage == 1 ? widget.terms : widget.policy;
|
|
||||||
final String staticText =
|
|
||||||
'<h5 style="color: #FF5722;">If you cancel you will be logged out.</h5>';
|
|
||||||
|
|
||||||
Widget _buildScrollableContent() {
|
|
||||||
return Container(
|
|
||||||
padding: const EdgeInsets.all(40),
|
|
||||||
width: MediaQuery.of(context).size.width * 0.8,
|
|
||||||
height: MediaQuery.of(context).size.height * 0.75,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.grey[200],
|
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(20)),
|
|
||||||
),
|
|
||||||
child: Scrollbar(
|
|
||||||
thumbVisibility: true,
|
|
||||||
trackVisibility: true,
|
|
||||||
interactive: true,
|
|
||||||
controller: _scrollController,
|
|
||||||
child: SingleChildScrollView(
|
|
||||||
controller: _scrollController,
|
|
||||||
padding: const EdgeInsets.all(25),
|
|
||||||
child: Html(
|
|
||||||
data: "$_dialogContent $staticText",
|
|
||||||
onLinkTap: (url, attributes, element) async {
|
|
||||||
if (url != null) {
|
|
||||||
final uri = Uri.parse(url);
|
|
||||||
await launchUrl(uri, mode: LaunchMode.externalApplication);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
style: {
|
|
||||||
"body": Style(
|
|
||||||
fontSize: FontSize(14),
|
|
||||||
color: Colors.black87,
|
|
||||||
lineHeight: LineHeight(1.5),
|
|
||||||
),
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildActionButton() {
|
|
||||||
final String buttonText = _currentPage == 2 ? "I Agree" : "Next";
|
|
||||||
|
|
||||||
return InkWell(
|
|
||||||
onTap: _isAtEnd
|
|
||||||
? () {
|
|
||||||
if (_currentPage == 1) {
|
|
||||||
setState(() {
|
|
||||||
_currentPage = 2;
|
|
||||||
_isAtEnd = false;
|
|
||||||
_scrollController.jumpTo(0);
|
|
||||||
WidgetsBinding.instance
|
|
||||||
.addPostFrameCallback((_) => _checkScrollRequirement());
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
Navigator.of(context).pop(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
child: Text(
|
|
||||||
buttonText,
|
|
||||||
style: TextStyle(
|
|
||||||
color: _isAtEnd ? ColorsManager.secondaryColor : Colors.grey,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Dialog(
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(16.0),
|
|
||||||
child: Text(
|
|
||||||
_dialogTitle,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 20,
|
|
||||||
fontWeight: FontWeight.w700,
|
|
||||||
color: ColorsManager.secondaryColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const Divider(),
|
|
||||||
_buildScrollableContent(),
|
|
||||||
const Divider(),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
||||||
children: [
|
|
||||||
InkWell(
|
|
||||||
onTap: () {
|
|
||||||
AuthBloc.logout();
|
|
||||||
context.go(RoutesConst.auth);
|
|
||||||
},
|
|
||||||
child: const Text("Cancel"),
|
|
||||||
),
|
|
||||||
_buildActionButton(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -41,7 +41,8 @@ class HomeMobilePage extends StatelessWidget {
|
|||||||
SizedBox(height: size.height * 0.05),
|
SizedBox(height: size.height * 0.05),
|
||||||
const Text(
|
const Text(
|
||||||
'ACCESS YOUR APPS',
|
'ACCESS YOUR APPS',
|
||||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w700),
|
style:
|
||||||
|
TextStyle(fontSize: 20, fontWeight: FontWeight.w700),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 30),
|
const SizedBox(height: 30),
|
||||||
Expanded(
|
Expanded(
|
||||||
@ -50,8 +51,9 @@ class HomeMobilePage extends StatelessWidget {
|
|||||||
height: size.height * 0.6,
|
height: size.height * 0.6,
|
||||||
width: size.width * 0.68,
|
width: size.width * 0.68,
|
||||||
child: GridView.builder(
|
child: GridView.builder(
|
||||||
itemCount: 3,
|
itemCount: 8,
|
||||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
gridDelegate:
|
||||||
|
const SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
crossAxisCount: 2,
|
crossAxisCount: 2,
|
||||||
crossAxisSpacing: 20.0,
|
crossAxisSpacing: 20.0,
|
||||||
mainAxisSpacing: 20.0,
|
mainAxisSpacing: 20.0,
|
||||||
@ -63,7 +65,8 @@ class HomeMobilePage extends StatelessWidget {
|
|||||||
active: homeItems[index]['active'],
|
active: homeItems[index]['active'],
|
||||||
name: homeItems[index]['title'],
|
name: homeItems[index]['title'],
|
||||||
img: homeItems[index]['icon'],
|
img: homeItems[index]['icon'],
|
||||||
onTap: () => homeBloc.homeItems[index].onPress(context),
|
onTap: () =>
|
||||||
|
homeBloc.homeItems[index].onPress(context),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -94,33 +97,33 @@ class HomeMobilePage extends StatelessWidget {
|
|||||||
'icon': Assets.devicesIcon,
|
'icon': Assets.devicesIcon,
|
||||||
'active': true,
|
'active': true,
|
||||||
},
|
},
|
||||||
// {
|
{
|
||||||
// 'title': 'Move in',
|
'title': 'Move in',
|
||||||
// 'icon': Assets.moveinIcon,
|
'icon': Assets.moveinIcon,
|
||||||
// 'active': false,
|
'active': false,
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// 'title': 'Construction',
|
'title': 'Construction',
|
||||||
// 'icon': Assets.constructionIcon,
|
'icon': Assets.constructionIcon,
|
||||||
// 'active': false,
|
'active': false,
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// 'title': 'Energy',
|
'title': 'Energy',
|
||||||
// 'icon': Assets.energyIcon,
|
'icon': Assets.energyIcon,
|
||||||
// 'color': ColorsManager.slidingBlueColor.withOpacity(0.2),
|
'color': ColorsManager.slidingBlueColor.withOpacity(0.2),
|
||||||
// 'active': false,
|
'active': false,
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// 'title': 'Integrations',
|
'title': 'Integrations',
|
||||||
// 'icon': Assets.integrationsIcon,
|
'icon': Assets.integrationsIcon,
|
||||||
// 'color': ColorsManager.slidingBlueColor.withOpacity(0.2),
|
'color': ColorsManager.slidingBlueColor.withOpacity(0.2),
|
||||||
// 'active': false,
|
'active': false,
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// 'title': 'Asset',
|
'title': 'Asset',
|
||||||
// 'icon': Assets.assetIcon,
|
'icon': Assets.assetIcon,
|
||||||
// 'color': ColorsManager.slidingBlueColor.withOpacity(0.2),
|
'color': ColorsManager.slidingBlueColor.withOpacity(0.2),
|
||||||
// 'active': false,
|
'active': false,
|
||||||
// },
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
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:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:syncrow_web/pages/home/bloc/home_event.dart';
|
|
||||||
import 'package:syncrow_web/pages/home/view/agreement_and_privacy_dialog.dart';
|
|
||||||
import 'package:syncrow_web/pages/home/bloc/home_bloc.dart';
|
import 'package:syncrow_web/pages/home/bloc/home_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/home/bloc/home_state.dart';
|
import 'package:syncrow_web/pages/home/bloc/home_state.dart';
|
||||||
import 'package:syncrow_web/pages/home/view/home_card.dart';
|
import 'package:syncrow_web/pages/home/view/home_card.dart';
|
||||||
@ -11,40 +9,16 @@ import 'package:syncrow_web/web_layout/web_scaffold.dart';
|
|||||||
|
|
||||||
class HomeWebPage extends StatelessWidget {
|
class HomeWebPage extends StatelessWidget {
|
||||||
const HomeWebPage({super.key});
|
const HomeWebPage({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
Size size = MediaQuery.of(context).size;
|
Size size = MediaQuery.of(context).size;
|
||||||
final homeBloc = BlocProvider.of<HomeBloc>(context);
|
|
||||||
|
|
||||||
return PopScope(
|
return PopScope(
|
||||||
canPop: false,
|
canPop: false,
|
||||||
onPopInvoked: (didPop) => false,
|
onPopInvoked: (didPop) => false,
|
||||||
child: BlocConsumer<HomeBloc, HomeState>(
|
child: BlocConsumer<HomeBloc, HomeState>(
|
||||||
listener: (BuildContext context, state) {
|
listener: (BuildContext context, state) {},
|
||||||
if (state is HomeInitial) {
|
|
||||||
if (homeBloc.user!.hasAcceptedWebAgreement == false) {
|
|
||||||
Future.delayed(const Duration(seconds: 2), () {
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
barrierDismissible: false,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return AgreementAndPrivacyDialog(
|
|
||||||
terms: homeBloc.terms,
|
|
||||||
policy: homeBloc.policy,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
).then((v) {
|
|
||||||
if (v != null) {
|
|
||||||
homeBloc.add(ConfirmUserAgreementEvent());
|
|
||||||
homeBloc.add(const FetchUserInfo());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
|
final homeBloc = BlocProvider.of<HomeBloc>(context);
|
||||||
return WebScaffold(
|
return WebScaffold(
|
||||||
enableMenuSidebar: false,
|
enableMenuSidebar: false,
|
||||||
appBarTitle: Row(
|
appBarTitle: Row(
|
||||||
@ -58,10 +32,7 @@ class HomeWebPage extends StatelessWidget {
|
|||||||
scaffoldBody: SizedBox(
|
scaffoldBody: SizedBox(
|
||||||
height: size.height,
|
height: size.height,
|
||||||
width: size.width,
|
width: size.width,
|
||||||
child: Row(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
@ -82,7 +53,7 @@ class HomeWebPage extends StatelessWidget {
|
|||||||
child: GridView.builder(
|
child: GridView.builder(
|
||||||
itemCount: 3, //8
|
itemCount: 3, //8
|
||||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
crossAxisCount: 3, //4
|
crossAxisCount: 4,
|
||||||
crossAxisSpacing: 20.0,
|
crossAxisSpacing: 20.0,
|
||||||
mainAxisSpacing: 20.0,
|
mainAxisSpacing: 20.0,
|
||||||
childAspectRatio: 1.5,
|
childAspectRatio: 1.5,
|
||||||
@ -101,8 +72,6 @@ class HomeWebPage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -1,185 +1,185 @@
|
|||||||
// 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:graphview/GraphView.dart';
|
import 'package:graphview/GraphView.dart';
|
||||||
// import 'package:syncrow_web/pages/home/bloc/home_bloc.dart';
|
import 'package:syncrow_web/pages/home/bloc/home_bloc.dart';
|
||||||
// import 'package:syncrow_web/pages/home/bloc/home_event.dart';
|
import 'package:syncrow_web/pages/home/bloc/home_event.dart';
|
||||||
// import 'package:syncrow_web/pages/home/bloc/home_state.dart';
|
import 'package:syncrow_web/pages/home/bloc/home_state.dart';
|
||||||
|
|
||||||
// class TreeWidget extends StatelessWidget {
|
class TreeWidget extends StatelessWidget {
|
||||||
// const TreeWidget({super.key});
|
const TreeWidget({super.key});
|
||||||
|
|
||||||
// @override
|
@override
|
||||||
// Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// // final HomeBloc homeBloc = BlocProvider.of<HomeBloc>(context);
|
// final HomeBloc homeBloc = BlocProvider.of<HomeBloc>(context);
|
||||||
// String firstNodeName = '';
|
String firstNodeName = '';
|
||||||
// String secondNodeName = '';
|
String secondNodeName = '';
|
||||||
|
|
||||||
// return SafeArea(
|
return SafeArea(
|
||||||
// child: Container(
|
child: Container(
|
||||||
// padding: const EdgeInsets.all(24),
|
padding: const EdgeInsets.all(24),
|
||||||
// width: MediaQuery.sizeOf(context).width,
|
width: MediaQuery.sizeOf(context).width,
|
||||||
// height: MediaQuery.sizeOf(context).height,
|
height: MediaQuery.sizeOf(context).height,
|
||||||
// alignment: AlignmentDirectional.center,
|
alignment: AlignmentDirectional.center,
|
||||||
// child: Column(
|
child: Column(
|
||||||
// mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
// mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
// children: [
|
children: [
|
||||||
// BlocBuilder<HomeBloc, HomeState>(builder: (context, state) {
|
BlocBuilder<HomeBloc, HomeState>(builder: (context, state) {
|
||||||
// if (state is HomeInitial) {
|
if (state is HomeInitial) {
|
||||||
// return Wrap(
|
return Wrap(
|
||||||
// children: [
|
children: [
|
||||||
// SizedBox(
|
SizedBox(
|
||||||
// width: 100,
|
width: 100,
|
||||||
// child: TextFormField(
|
child: TextFormField(
|
||||||
// decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
// labelText: "Subtree separation"),
|
labelText: "Subtree separation"),
|
||||||
// onChanged: (text) {
|
onChanged: (text) {
|
||||||
// firstNodeName = text;
|
firstNodeName = text;
|
||||||
// },
|
},
|
||||||
// ),
|
),
|
||||||
// ),
|
),
|
||||||
// const SizedBox(
|
const SizedBox(
|
||||||
// width: 8,
|
width: 8,
|
||||||
// ),
|
),
|
||||||
// Container(
|
Container(
|
||||||
// width: 100,
|
width: 100,
|
||||||
// child: TextFormField(
|
child: TextFormField(
|
||||||
// decoration: InputDecoration(labelText: "Node Name"),
|
decoration: InputDecoration(labelText: "Node Name"),
|
||||||
// onChanged: (text) {
|
onChanged: (text) {
|
||||||
// secondNodeName = text;
|
secondNodeName = text;
|
||||||
// },
|
},
|
||||||
// ),
|
),
|
||||||
// ),
|
),
|
||||||
// ElevatedButton(
|
ElevatedButton(
|
||||||
// onPressed: () {
|
onPressed: () {
|
||||||
// final node1 = Node.Id(firstNodeName);
|
final node1 = Node.Id(firstNodeName);
|
||||||
// final node2 = Node.Id(secondNodeName);
|
final node2 = Node.Id(secondNodeName);
|
||||||
// context.read<HomeBloc>().add(CreateNewNode(
|
context.read<HomeBloc>().add(CreateNewNode(
|
||||||
// sourceNode: node1, destinationNode: node2));
|
sourceNode: node1, destinationNode: node2));
|
||||||
// },
|
},
|
||||||
// child: Text("Add"),
|
child: Text("Add"),
|
||||||
// )
|
)
|
||||||
// ],
|
],
|
||||||
// );
|
);
|
||||||
// }
|
}
|
||||||
// if (state is HomeUpdateTree) {
|
if (state is HomeUpdateTree) {
|
||||||
// return Expanded(
|
return Expanded(
|
||||||
// child: InteractiveViewer(
|
child: InteractiveViewer(
|
||||||
// constrained: false,
|
constrained: false,
|
||||||
// boundaryMargin: const EdgeInsets.all(100),
|
boundaryMargin: const EdgeInsets.all(100),
|
||||||
// minScale: 0.01,
|
minScale: 0.01,
|
||||||
// maxScale: 5.6,
|
maxScale: 5.6,
|
||||||
// child: GraphView(
|
child: GraphView(
|
||||||
// graph: state.graph,
|
graph: state.graph,
|
||||||
// algorithm: BuchheimWalkerAlgorithm(
|
algorithm: BuchheimWalkerAlgorithm(
|
||||||
// state.builder, TreeEdgeRenderer(state.builder)),
|
state.builder, TreeEdgeRenderer(state.builder)),
|
||||||
// paint: Paint()
|
paint: Paint()
|
||||||
// ..color = Colors.green
|
..color = Colors.green
|
||||||
// ..strokeWidth = 1
|
..strokeWidth = 1
|
||||||
// ..style = PaintingStyle.stroke,
|
..style = PaintingStyle.stroke,
|
||||||
// builder: (Node node) {
|
builder: (Node node) {
|
||||||
// // I can decide what widget should be shown here based on the id
|
// I can decide what widget should be shown here based on the id
|
||||||
// var nodeName = node.key!.value;
|
var nodeName = node.key!.value;
|
||||||
// return rectangleWidget(nodeName, node, context);
|
return rectangleWidget(nodeName, node, context);
|
||||||
// },
|
},
|
||||||
// )),
|
)),
|
||||||
// );
|
);
|
||||||
// } else {
|
} else {
|
||||||
// return Container();
|
return Container();
|
||||||
// }
|
}
|
||||||
// })
|
})
|
||||||
// ],
|
],
|
||||||
// ),
|
),
|
||||||
// ),
|
),
|
||||||
// );
|
);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// Widget rectangleWidget(String text, Node node, BuildContext blocContext) {
|
Widget rectangleWidget(String text, Node node, BuildContext blocContext) {
|
||||||
// String nodeName = '';
|
String nodeName = '';
|
||||||
// return InkWell(
|
return InkWell(
|
||||||
// onTap: () {
|
onTap: () {
|
||||||
// showDialog(
|
showDialog(
|
||||||
// context: blocContext,
|
context: blocContext,
|
||||||
// builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
// return AlertDialog(
|
return AlertDialog(
|
||||||
// title: const Text('Add a child'),
|
title: const Text('Add a child'),
|
||||||
// content: TextField(
|
content: TextField(
|
||||||
// decoration:
|
decoration:
|
||||||
// const InputDecoration(hintText: 'Enter your text here'),
|
const InputDecoration(hintText: 'Enter your text here'),
|
||||||
// onChanged: (value) {
|
onChanged: (value) {
|
||||||
// nodeName = value;
|
nodeName = value;
|
||||||
// },
|
},
|
||||||
// ),
|
),
|
||||||
// actions: <Widget>[
|
actions: <Widget>[
|
||||||
// TextButton(
|
TextButton(
|
||||||
// onPressed: () {
|
onPressed: () {
|
||||||
// Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
// },
|
},
|
||||||
// child: Text('Close'),
|
child: Text('Close'),
|
||||||
// ),
|
),
|
||||||
// TextButton(
|
TextButton(
|
||||||
// onPressed: () {
|
onPressed: () {
|
||||||
// if (nodeName.isNotEmpty) {
|
if (nodeName.isNotEmpty) {
|
||||||
// final newNode = Node.Id(nodeName);
|
final newNode = Node.Id(nodeName);
|
||||||
// blocContext.read<HomeBloc>().add(CreateNewNode(
|
blocContext.read<HomeBloc>().add(CreateNewNode(
|
||||||
// sourceNode: node, destinationNode: newNode));
|
sourceNode: node, destinationNode: newNode));
|
||||||
// }
|
}
|
||||||
// Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
// },
|
},
|
||||||
// child: Text('Add'),
|
child: Text('Add'),
|
||||||
// ),
|
),
|
||||||
// ],
|
],
|
||||||
// );
|
);
|
||||||
// },
|
},
|
||||||
// );
|
);
|
||||||
// },
|
},
|
||||||
// child: Container(
|
child: Container(
|
||||||
// width: MediaQuery.of(blocContext).size.width * 0.2,
|
width: MediaQuery.of(blocContext).size.width * 0.2,
|
||||||
// margin: EdgeInsets.symmetric(vertical: 10.0, horizontal: 20.0),
|
margin: EdgeInsets.symmetric(vertical: 10.0, horizontal: 20.0),
|
||||||
// padding: EdgeInsets.all(20.0),
|
padding: EdgeInsets.all(20.0),
|
||||||
// decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
// color: Colors.white,
|
color: Colors.white,
|
||||||
// borderRadius: BorderRadius.circular(10.0),
|
borderRadius: BorderRadius.circular(10.0),
|
||||||
// boxShadow: [
|
boxShadow: [
|
||||||
// BoxShadow(
|
BoxShadow(
|
||||||
// color: Colors.grey.withOpacity(0.5),
|
color: Colors.grey.withOpacity(0.5),
|
||||||
// spreadRadius: 2,
|
spreadRadius: 2,
|
||||||
// blurRadius: 5,
|
blurRadius: 5,
|
||||||
// offset: Offset(0, 3), // changes position of shadow
|
offset: Offset(0, 3), // changes position of shadow
|
||||||
// ),
|
),
|
||||||
// ],
|
],
|
||||||
// ),
|
),
|
||||||
// child: Row(
|
child: Row(
|
||||||
// children: [
|
children: [
|
||||||
// const SizedBox(
|
const SizedBox(
|
||||||
// child: Icon(
|
child: Icon(
|
||||||
// Icons.location_on,
|
Icons.location_on,
|
||||||
// color: Colors.blue,
|
color: Colors.blue,
|
||||||
// size: 40.0,
|
size: 40.0,
|
||||||
// ),
|
),
|
||||||
// ),
|
),
|
||||||
// const SizedBox(width: 10.0),
|
const SizedBox(width: 10.0),
|
||||||
// SizedBox(
|
SizedBox(
|
||||||
// child: Text(
|
child: Text(
|
||||||
// text,
|
text,
|
||||||
// style: const TextStyle(
|
style: const TextStyle(
|
||||||
// fontSize: 24.0,
|
fontSize: 24.0,
|
||||||
// fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
// ),
|
),
|
||||||
// ),
|
),
|
||||||
// ),
|
),
|
||||||
// const Spacer(),
|
const Spacer(),
|
||||||
// Container(
|
Container(
|
||||||
// child: const Icon(
|
child: const Icon(
|
||||||
// Icons.add_circle_outline,
|
Icons.add_circle_outline,
|
||||||
// color: Colors.grey,
|
color: Colors.grey,
|
||||||
// size: 24.0,
|
size: 24.0,
|
||||||
// ),
|
),
|
||||||
// ),
|
),
|
||||||
// ],
|
],
|
||||||
// ),
|
),
|
||||||
// ),
|
),
|
||||||
// );
|
);
|
||||||
// }
|
}
|
||||||
|
@ -42,9 +42,7 @@ class RolesUserModel {
|
|||||||
invitedBy:
|
invitedBy:
|
||||||
json['invitedBy'].toString().toLowerCase().replaceAll("_", " "),
|
json['invitedBy'].toString().toLowerCase().replaceAll("_", " "),
|
||||||
phoneNumber: json['phoneNumber'],
|
phoneNumber: json['phoneNumber'],
|
||||||
jobTitle: json['jobTitle'] == null || json['jobTitle'] == " "
|
jobTitle: json['jobTitle'] ?? "-",
|
||||||
? "_"
|
|
||||||
: json['jobTitle'],
|
|
||||||
createdDate: json['createdDate'],
|
createdDate: json['createdDate'],
|
||||||
createdTime: json['createdTime'],
|
createdTime: json['createdTime'],
|
||||||
);
|
);
|
||||||
|
@ -79,14 +79,13 @@ class UsersBloc extends Bloc<UsersEvent, UsersState> {
|
|||||||
|
|
||||||
List<TreeNode> updatedCommunities = [];
|
List<TreeNode> updatedCommunities = [];
|
||||||
List<TreeNode> spacesNodes = [];
|
List<TreeNode> spacesNodes = [];
|
||||||
List<String> communityIds = [];
|
|
||||||
_onLoadCommunityAndSpaces(
|
_onLoadCommunityAndSpaces(
|
||||||
LoadCommunityAndSpacesEvent event, Emitter<UsersState> emit) async {
|
LoadCommunityAndSpacesEvent event, Emitter<UsersState> emit) async {
|
||||||
try {
|
try {
|
||||||
emit(UsersLoadingState());
|
emit(UsersLoadingState());
|
||||||
List<CommunityModel> communities =
|
List<CommunityModel> communities =
|
||||||
await CommunitySpaceManagementApi().fetchCommunities();
|
await CommunitySpaceManagementApi().fetchCommunities();
|
||||||
communityIds = communities.map((community) => community.uuid).toList();
|
|
||||||
updatedCommunities = await Future.wait(
|
updatedCommunities = await Future.wait(
|
||||||
communities.map((community) async {
|
communities.map((community) async {
|
||||||
List<SpaceModel> spaces =
|
List<SpaceModel> spaces =
|
||||||
@ -103,6 +102,7 @@ class UsersBloc extends Bloc<UsersEvent, UsersState> {
|
|||||||
}).toList(),
|
}).toList(),
|
||||||
);
|
);
|
||||||
emit(const SpacesLoadedState());
|
emit(const SpacesLoadedState());
|
||||||
|
return updatedCommunities;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(ErrorState('Error loading communities and spaces: $e'));
|
emit(ErrorState('Error loading communities and spaces: $e'));
|
||||||
}
|
}
|
||||||
@ -177,6 +177,7 @@ class UsersBloc extends Bloc<UsersEvent, UsersState> {
|
|||||||
try {
|
try {
|
||||||
emit(UsersLoadingState());
|
emit(UsersLoadingState());
|
||||||
roles = await UserPermissionApi().fetchRoles();
|
roles = await UserPermissionApi().fetchRoles();
|
||||||
|
// add(PermissionEvent(roleUuid: roles.first.uuid));
|
||||||
emit(RolePermissionInitial());
|
emit(RolePermissionInitial());
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(ErrorState('Error loading communities and spaces: $e'));
|
emit(ErrorState('Error loading communities and spaces: $e'));
|
||||||
@ -207,13 +208,10 @@ class UsersBloc extends Bloc<UsersEvent, UsersState> {
|
|||||||
return anyMatch;
|
return anyMatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _sendInvitUser(SendInviteUsers event, Emitter<UsersState> emit) async {
|
_sendInvitUser(SendInviteUsers event, Emitter<UsersState> emit) async {
|
||||||
try {
|
try {
|
||||||
emit(UsersLoadingState());
|
emit(UsersLoadingState());
|
||||||
List<String> selectedIds = getSelectedIds(updatedCommunities)
|
List<String> selectedIds = getSelectedIds(updatedCommunities);
|
||||||
.where((id) => !communityIds.contains(id))
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
bool res = await UserPermissionApi().sendInviteUser(
|
bool res = await UserPermissionApi().sendInviteUser(
|
||||||
email: emailController.text,
|
email: emailController.text,
|
||||||
firstName: firstNameController.text,
|
firstName: firstNameController.text,
|
||||||
@ -223,8 +221,7 @@ class UsersBloc extends Bloc<UsersEvent, UsersState> {
|
|||||||
roleUuid: roleSelected,
|
roleUuid: roleSelected,
|
||||||
spaceUuids: selectedIds,
|
spaceUuids: selectedIds,
|
||||||
);
|
);
|
||||||
|
if (res == true) {
|
||||||
if (res) {
|
|
||||||
showCustomDialog(
|
showCustomDialog(
|
||||||
barrierDismissible: false,
|
barrierDismissible: false,
|
||||||
context: event.context,
|
context: event.context,
|
||||||
@ -251,14 +248,10 @@ class UsersBloc extends Bloc<UsersEvent, UsersState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_editInviteUser(EditInviteUsers event, Emitter<UsersState> emit) async {
|
_editInviteUser(EditInviteUsers event, Emitter<UsersState> emit) async {
|
||||||
try {
|
try {
|
||||||
emit(UsersLoadingState());
|
emit(UsersLoadingState());
|
||||||
List<String> selectedIds = getSelectedIds(updatedCommunities)
|
List<String> selectedIds = getSelectedIds(updatedCommunities);
|
||||||
.where((id) => !communityIds.contains(id))
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
bool res = await UserPermissionApi().editInviteUser(
|
bool res = await UserPermissionApi().editInviteUser(
|
||||||
userId: event.userId,
|
userId: event.userId,
|
||||||
firstName: firstNameController.text,
|
firstName: firstNameController.text,
|
||||||
|
@ -218,7 +218,7 @@ class BasicsView extends StatelessWidget {
|
|||||||
if (_blocRole.checkEmailValid != "Valid email") {
|
if (_blocRole.checkEmailValid != "Valid email") {
|
||||||
return _blocRole.checkEmailValid;
|
return _blocRole.checkEmailValid;
|
||||||
}
|
}
|
||||||
// return null;
|
return null;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -81,7 +81,7 @@ Future<void> showPopUpFilterMenu({
|
|||||||
),
|
),
|
||||||
const Divider(),
|
const Divider(),
|
||||||
const Text(
|
const Text(
|
||||||
"Filter by ",
|
"Filter by Status",
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
|
@ -40,7 +40,9 @@ class UserTableBloc extends Bloc<UserTableEvent, UserTableState> {
|
|||||||
roleTypes.clear();
|
roleTypes.clear();
|
||||||
jobTitle.clear();
|
jobTitle.clear();
|
||||||
createdBy.clear();
|
createdBy.clear();
|
||||||
|
// deActivate.clear();
|
||||||
users = await UserPermissionApi().fetchUsers();
|
users = await UserPermissionApi().fetchUsers();
|
||||||
|
|
||||||
users.sort((a, b) {
|
users.sort((a, b) {
|
||||||
final dateA = _parseDateTime(a.createdDate);
|
final dateA = _parseDateTime(a.createdDate);
|
||||||
final dateB = _parseDateTime(b.createdDate);
|
final dateB = _parseDateTime(b.createdDate);
|
||||||
@ -55,12 +57,15 @@ class UserTableBloc extends Bloc<UserTableEvent, UserTableState> {
|
|||||||
for (var user in users) {
|
for (var user in users) {
|
||||||
createdBy.add(user.invitedBy.toString());
|
createdBy.add(user.invitedBy.toString());
|
||||||
}
|
}
|
||||||
|
// for (var user in users) {
|
||||||
|
// deActivate.add(user.status.toString());
|
||||||
|
// }
|
||||||
initialUsers = List.from(users);
|
initialUsers = List.from(users);
|
||||||
roleTypes = roleTypes.toSet().toList();
|
roleTypes = roleTypes.toSet().toList();
|
||||||
jobTitle = jobTitle.toSet().toList();
|
jobTitle = jobTitle.toSet().toList();
|
||||||
createdBy = createdBy.toSet().toList();
|
createdBy = createdBy.toSet().toList();
|
||||||
|
// deActivate = deActivate.toSet().toList();
|
||||||
_handlePageChange(ChangePage(1), emit);
|
_handlePageChange(ChangePage(1), emit);
|
||||||
add(ChangePage(currentPage));
|
|
||||||
emit(UsersLoadedState(users: users));
|
emit(UsersLoadedState(users: users));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(ErrorState(e.toString()));
|
emit(ErrorState(e.toString()));
|
||||||
@ -120,10 +125,6 @@ class UserTableBloc extends Bloc<UserTableEvent, UserTableState> {
|
|||||||
|
|
||||||
void _toggleSortUsersByNameAsc(
|
void _toggleSortUsersByNameAsc(
|
||||||
SortUsersByNameAsc event, Emitter<UserTableState> emit) {
|
SortUsersByNameAsc event, Emitter<UserTableState> emit) {
|
||||||
selectedRoles.clear();
|
|
||||||
selectedJobTitles.clear();
|
|
||||||
selectedCreatedBy.clear();
|
|
||||||
selectedStatuses.clear();
|
|
||||||
if (currentSortOrder == "Asc") {
|
if (currentSortOrder == "Asc") {
|
||||||
emit(UsersLoadingState());
|
emit(UsersLoadingState());
|
||||||
currentSortOrder = "";
|
currentSortOrder = "";
|
||||||
@ -142,16 +143,13 @@ class UserTableBloc extends Bloc<UserTableEvent, UserTableState> {
|
|||||||
|
|
||||||
void _toggleSortUsersByNameDesc(
|
void _toggleSortUsersByNameDesc(
|
||||||
SortUsersByNameDesc event, Emitter<UserTableState> emit) {
|
SortUsersByNameDesc event, Emitter<UserTableState> emit) {
|
||||||
selectedRoles.clear();
|
|
||||||
selectedJobTitles.clear();
|
|
||||||
selectedCreatedBy.clear();
|
|
||||||
selectedStatuses.clear();
|
|
||||||
if (currentSortOrder == "Desc") {
|
if (currentSortOrder == "Desc") {
|
||||||
emit(UsersLoadingState());
|
emit(UsersLoadingState());
|
||||||
currentSortOrder = "";
|
currentSortOrder = "";
|
||||||
users = List.from(initialUsers);
|
users = List.from(initialUsers); // Reset to saved initial state
|
||||||
emit(UsersLoadedState(users: users));
|
emit(UsersLoadedState(users: users));
|
||||||
} else {
|
} else {
|
||||||
|
// Sort descending
|
||||||
emit(UsersLoadingState());
|
emit(UsersLoadingState());
|
||||||
currentSortOrder = "Desc";
|
currentSortOrder = "Desc";
|
||||||
users.sort((a, b) => b.firstName!.compareTo(a.firstName!));
|
users.sort((a, b) => b.firstName!.compareTo(a.firstName!));
|
||||||
@ -161,10 +159,6 @@ class UserTableBloc extends Bloc<UserTableEvent, UserTableState> {
|
|||||||
|
|
||||||
void _toggleSortUsersByDateNewestToOldest(
|
void _toggleSortUsersByDateNewestToOldest(
|
||||||
DateNewestToOldestEvent event, Emitter<UserTableState> emit) {
|
DateNewestToOldestEvent event, Emitter<UserTableState> emit) {
|
||||||
selectedRoles.clear();
|
|
||||||
selectedJobTitles.clear();
|
|
||||||
selectedCreatedBy.clear();
|
|
||||||
selectedStatuses.clear();
|
|
||||||
if (currentSortOrderDate == "NewestToOldest") {
|
if (currentSortOrderDate == "NewestToOldest") {
|
||||||
emit(UsersLoadingState());
|
emit(UsersLoadingState());
|
||||||
currentSortOrder = "";
|
currentSortOrder = "";
|
||||||
@ -185,10 +179,6 @@ class UserTableBloc extends Bloc<UserTableEvent, UserTableState> {
|
|||||||
|
|
||||||
void _toggleSortUsersByDateOldestToNewest(
|
void _toggleSortUsersByDateOldestToNewest(
|
||||||
DateOldestToNewestEvent event, Emitter<UserTableState> emit) {
|
DateOldestToNewestEvent event, Emitter<UserTableState> emit) {
|
||||||
selectedRoles.clear();
|
|
||||||
selectedJobTitles.clear();
|
|
||||||
selectedCreatedBy.clear();
|
|
||||||
selectedStatuses.clear();
|
|
||||||
if (currentSortOrderDate == "OldestToNewest") {
|
if (currentSortOrderDate == "OldestToNewest") {
|
||||||
emit(UsersLoadingState());
|
emit(UsersLoadingState());
|
||||||
currentSortOrder = "";
|
currentSortOrder = "";
|
||||||
@ -347,20 +337,7 @@ class UserTableBloc extends Bloc<UserTableEvent, UserTableState> {
|
|||||||
|
|
||||||
final filteredUsers = initialUsers.where((user) {
|
final filteredUsers = initialUsers.where((user) {
|
||||||
if (selectedStatuses.isEmpty) return true;
|
if (selectedStatuses.isEmpty) return true;
|
||||||
|
return selectedStatuses.contains(user.status);
|
||||||
return selectedStatuses.any((status) {
|
|
||||||
final userStatus = user.status?.toLowerCase() ?? '';
|
|
||||||
switch (status.toLowerCase()) {
|
|
||||||
case 'active':
|
|
||||||
return user.isEnabled == true && userStatus != 'invited';
|
|
||||||
case 'disabled':
|
|
||||||
return user.isEnabled == false;
|
|
||||||
case 'invited':
|
|
||||||
return userStatus == 'invited';
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}).toList();
|
}).toList();
|
||||||
if (event.sortOrder == "Asc") {
|
if (event.sortOrder == "Asc") {
|
||||||
currentSortOrder = "Asc";
|
currentSortOrder = "Asc";
|
||||||
@ -374,11 +351,9 @@ class UserTableBloc extends Bloc<UserTableEvent, UserTableState> {
|
|||||||
} else {
|
} else {
|
||||||
currentSortOrder = "";
|
currentSortOrder = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
emit(UsersLoadedState(users: filteredUsers));
|
emit(UsersLoadedState(users: filteredUsers));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void _resetAllFilters(Emitter<UserTableState> emit) {
|
void _resetAllFilters(Emitter<UserTableState> emit) {
|
||||||
selectedRoles.clear();
|
selectedRoles.clear();
|
||||||
selectedJobTitles.clear();
|
selectedJobTitles.clear();
|
||||||
|
@ -12,7 +12,7 @@ Future<void> showDateFilterMenu({
|
|||||||
Overlay.of(context).context.findRenderObject() as RenderBox;
|
Overlay.of(context).context.findRenderObject() as RenderBox;
|
||||||
final RelativeRect position = RelativeRect.fromRect(
|
final RelativeRect position = RelativeRect.fromRect(
|
||||||
Rect.fromLTRB(
|
Rect.fromLTRB(
|
||||||
overlay.size.width / 3,
|
overlay.size.width / 2,
|
||||||
240,
|
240,
|
||||||
0,
|
0,
|
||||||
overlay.size.height,
|
overlay.size.height,
|
||||||
@ -40,6 +40,7 @@ Future<void> showDateFilterMenu({
|
|||||||
),
|
),
|
||||||
title: Text(
|
title: Text(
|
||||||
"Sort from newest to oldest",
|
"Sort from newest to oldest",
|
||||||
|
// style: context.textTheme.bodyMedium,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: isSelected == "NewestToOldest"
|
color: isSelected == "NewestToOldest"
|
||||||
? Colors.black
|
? Colors.black
|
||||||
@ -64,5 +65,9 @@ Future<void> showDateFilterMenu({
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
).then((value) {});
|
).then((value) {
|
||||||
|
// setState(() {
|
||||||
|
// _isDropdownOpen = false;
|
||||||
|
// });
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@ Future<void> showDeActivateFilterMenu({
|
|||||||
),
|
),
|
||||||
title: Text(
|
title: Text(
|
||||||
"Sort A to Z",
|
"Sort A to Z",
|
||||||
|
// style: context.textTheme.bodyMedium,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: isSelected == "NewestToOldest"
|
color: isSelected == "NewestToOldest"
|
||||||
? Colors.black
|
? Colors.black
|
||||||
@ -64,5 +65,9 @@ Future<void> showDeActivateFilterMenu({
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
).then((value) {});
|
).then((value) {
|
||||||
|
// setState(() {
|
||||||
|
// _isDropdownOpen = false;
|
||||||
|
// });
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ Future<void> showNameMenu({
|
|||||||
Overlay.of(context).context.findRenderObject() as RenderBox;
|
Overlay.of(context).context.findRenderObject() as RenderBox;
|
||||||
final RelativeRect position = RelativeRect.fromRect(
|
final RelativeRect position = RelativeRect.fromRect(
|
||||||
Rect.fromLTRB(
|
Rect.fromLTRB(
|
||||||
overlay.size.width / 35,
|
overlay.size.width / 25,
|
||||||
240,
|
240,
|
||||||
0,
|
0,
|
||||||
overlay.size.height,
|
overlay.size.height,
|
||||||
@ -40,6 +40,7 @@ Future<void> showNameMenu({
|
|||||||
),
|
),
|
||||||
title: Text(
|
title: Text(
|
||||||
"Sort A to Z",
|
"Sort A to Z",
|
||||||
|
// style: context.textTheme.bodyMedium,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: isSelected == "Asc" ? Colors.black : Colors.blueGrey),
|
color: isSelected == "Asc" ? Colors.black : Colors.blueGrey),
|
||||||
),
|
),
|
||||||
@ -60,5 +61,9 @@ Future<void> showNameMenu({
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
).then((value) {});
|
).then((value) {
|
||||||
|
// setState(() {
|
||||||
|
// _isDropdownOpen = false;
|
||||||
|
// });
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,264 +1,260 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/svg.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';
|
||||||
import 'package:syncrow_web/utils/style.dart';
|
import 'package:syncrow_web/utils/style.dart';
|
||||||
|
|
||||||
class _HeaderColumn extends StatelessWidget {
|
|
||||||
final String title;
|
|
||||||
final double width;
|
|
||||||
final bool showFilter;
|
|
||||||
final VoidCallback? onFilter;
|
|
||||||
final Function(double) onResize;
|
|
||||||
|
|
||||||
const _HeaderColumn({
|
|
||||||
required this.title,
|
|
||||||
required this.width,
|
|
||||||
required this.showFilter,
|
|
||||||
required this.onResize,
|
|
||||||
this.onFilter,
|
|
||||||
Key? key,
|
|
||||||
}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return MouseRegion(
|
|
||||||
cursor: SystemMouseCursors.resizeColumn,
|
|
||||||
child: GestureDetector(
|
|
||||||
onHorizontalDragUpdate: (details) => onResize(details.delta.dx),
|
|
||||||
child: Container(
|
|
||||||
width: width,
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
|
||||||
decoration: const BoxDecoration(
|
|
||||||
border: Border(right: BorderSide(color: ColorsManager.boxDivider)),
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
title,
|
|
||||||
maxLines: 2,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
fontSize: 13,
|
|
||||||
color: ColorsManager.grayColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (showFilter)
|
|
||||||
IconButton(
|
|
||||||
icon: SvgPicture.asset(Assets.filterTableIcon),
|
|
||||||
onPressed: onFilter,
|
|
||||||
padding: EdgeInsets.zero,
|
|
||||||
constraints: const BoxConstraints(),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _TableRow extends StatelessWidget {
|
|
||||||
final List<Widget> cells;
|
|
||||||
final List<double> columnWidths;
|
|
||||||
final bool isLast;
|
|
||||||
|
|
||||||
const _TableRow({
|
|
||||||
required this.cells,
|
|
||||||
required this.columnWidths,
|
|
||||||
required this.isLast,
|
|
||||||
Key? key,
|
|
||||||
}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Column(
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
for (int i = 0; i < cells.length; i++)
|
|
||||||
Container(
|
|
||||||
width: columnWidths[i],
|
|
||||||
padding:
|
|
||||||
const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
|
||||||
// decoration: BoxDecoration(
|
|
||||||
// border: Border(
|
|
||||||
// right: BorderSide(color: ColorsManager.boxDivider),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
child: cells[i],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
if (!isLast)
|
|
||||||
Divider(
|
|
||||||
height: 1,
|
|
||||||
thickness: 1,
|
|
||||||
color: ColorsManager.boxDivider,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//===========================================================================
|
|
||||||
|
|
||||||
class DynamicTableScreen extends StatefulWidget {
|
class DynamicTableScreen extends StatefulWidget {
|
||||||
final List<String> titles;
|
final List<String> titles;
|
||||||
final List<List<Widget>> rows;
|
final List<List<Widget>> rows;
|
||||||
final void Function(int columnIndex)? onFilter;
|
final void Function(int columnIndex)? onFilter;
|
||||||
|
|
||||||
const DynamicTableScreen({
|
DynamicTableScreen(
|
||||||
required this.titles,
|
{required this.titles, required this.rows, required this.onFilter});
|
||||||
required this.rows,
|
|
||||||
required this.onFilter,
|
|
||||||
Key? key,
|
|
||||||
}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_DynamicTableScreenState createState() => _DynamicTableScreenState();
|
_DynamicTableScreenState createState() => _DynamicTableScreenState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _DynamicTableScreenState extends State<DynamicTableScreen> {
|
class _DynamicTableScreenState extends State<DynamicTableScreen>
|
||||||
|
with WidgetsBindingObserver {
|
||||||
late List<double> columnWidths;
|
late List<double> columnWidths;
|
||||||
final double _minColumnWidth = 100.0;
|
late double totalWidth;
|
||||||
final double _maxColumnWidth = 300.0;
|
|
||||||
final double _dividerWidth = 1.0;
|
|
||||||
double _lastAvailableWidth = 0;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
columnWidths = List.filled(widget.titles.length, _minColumnWidth);
|
columnWidths = List<double>.filled(widget.titles.length, 150.0);
|
||||||
|
totalWidth = columnWidths.reduce((a, b) => a + b);
|
||||||
|
WidgetsBinding.instance.addObserver(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleColumnResize(int index, double delta) {
|
@override
|
||||||
setState(() {
|
void dispose() {
|
||||||
double newWidth = columnWidths[index] + delta;
|
WidgetsBinding.instance.removeObserver(this);
|
||||||
newWidth = newWidth.clamp(_minColumnWidth, _maxColumnWidth);
|
super.dispose();
|
||||||
double actualDelta = newWidth - columnWidths[index];
|
}
|
||||||
if (actualDelta == 0) return;
|
|
||||||
|
|
||||||
int nextIndex = (index + 1) % columnWidths.length;
|
@override
|
||||||
columnWidths[index] = newWidth;
|
void didChangeMetrics() {
|
||||||
columnWidths[nextIndex] = (columnWidths[nextIndex] - actualDelta)
|
super.didChangeMetrics();
|
||||||
.clamp(_minColumnWidth, _maxColumnWidth);
|
final newScreenWidth = MediaQuery.of(context).size.width;
|
||||||
|
setState(() {
|
||||||
|
columnWidths = List<double>.generate(widget.titles.length, (index) {
|
||||||
|
if (index == 1) {
|
||||||
|
return newScreenWidth *
|
||||||
|
0.12; // 20% of screen width for the second column
|
||||||
|
} else if (index == 9) {
|
||||||
|
return newScreenWidth *
|
||||||
|
0.1; // 25% of screen width for the tenth column
|
||||||
|
}
|
||||||
|
return newScreenWidth *
|
||||||
|
0.09; // Default to 10% of screen width for other columns
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildHeader() {
|
@override
|
||||||
return Container(
|
Widget build(BuildContext context) {
|
||||||
|
final screenWidth = MediaQuery.of(context).size.width;
|
||||||
|
if (columnWidths.every((width) => width == screenWidth * 7)) {
|
||||||
|
columnWidths = List<double>.generate(widget.titles.length, (index) {
|
||||||
|
if (index == 1) {
|
||||||
|
return screenWidth * 0.11;
|
||||||
|
} else if (index == 9) {
|
||||||
|
return screenWidth * 0.1;
|
||||||
|
}
|
||||||
|
return screenWidth * 0.09;
|
||||||
|
});
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
return SingleChildScrollView(
|
||||||
|
clipBehavior: Clip.none,
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
child: Container(
|
||||||
|
decoration: containerDecoration.copyWith(
|
||||||
|
color: ColorsManager.whiteColors,
|
||||||
|
borderRadius: const BorderRadius.all(Radius.circular(20))),
|
||||||
|
child: FittedBox(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: totalWidth,
|
||||||
decoration: containerDecoration.copyWith(
|
decoration: containerDecoration.copyWith(
|
||||||
color: ColorsManager.circleRolesBackground,
|
color: ColorsManager.circleRolesBackground,
|
||||||
borderRadius: const BorderRadius.only(
|
borderRadius: const BorderRadius.only(
|
||||||
topLeft: Radius.circular(15),
|
topLeft: Radius.circular(15),
|
||||||
topRight: Radius.circular(15),
|
topRight: Radius.circular(15))),
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Row(
|
child: Row(
|
||||||
|
children: List.generate(widget.titles.length, (index) {
|
||||||
|
return Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
for (int i = 0; i < widget.titles.length; i++)
|
FittedBox(
|
||||||
_HeaderColumn(
|
child: Container(
|
||||||
title: widget.titles[i],
|
padding: const EdgeInsets.only(left: 5, right: 5),
|
||||||
width: columnWidths[i],
|
width: columnWidths[index],
|
||||||
showFilter: i != 1 && i != 9 && i != 8 && i != 5,
|
child: Row(
|
||||||
onFilter: () => widget.onFilter?.call(i),
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
onResize: (delta) => _handleColumnResize(i, delta),
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
child: Text(
|
||||||
|
widget.titles[index],
|
||||||
|
maxLines: 2,
|
||||||
|
style: const TextStyle(
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
fontSize: 13,
|
||||||
|
color: ColorsManager.grayColor,
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (index != 1 &&
|
||||||
|
index != 9 &&
|
||||||
|
index != 8 &&
|
||||||
|
index != 5)
|
||||||
|
FittedBox(
|
||||||
|
child: IconButton(
|
||||||
|
icon: SvgPicture.asset(
|
||||||
|
Assets.filterTableIcon,
|
||||||
|
fit: BoxFit.none,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
if (widget.onFilter != null) {
|
||||||
|
widget.onFilter!(index);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
GestureDetector(
|
||||||
|
onHorizontalDragUpdate: (details) {
|
||||||
|
setState(() {
|
||||||
|
columnWidths[index] =
|
||||||
|
(columnWidths[index] + details.delta.dx)
|
||||||
|
.clamp(150.0, 300.0);
|
||||||
|
totalWidth = columnWidths.reduce((a, b) => a + b);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
child: MouseRegion(
|
||||||
|
cursor: SystemMouseCursors.resizeColumn,
|
||||||
|
child: Container(
|
||||||
|
color: Colors.green,
|
||||||
|
child: Container(
|
||||||
|
color: ColorsManager.boxDivider,
|
||||||
|
width: 1,
|
||||||
|
height: 50,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}),
|
||||||
|
),
|
||||||
Widget _buildBody() {
|
),
|
||||||
if (widget.rows.isEmpty) {
|
widget.rows.isEmpty
|
||||||
return SizedBox(
|
? SizedBox(
|
||||||
height: 300,
|
height: MediaQuery.of(context).size.height / 2,
|
||||||
child: Center(
|
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
children: [
|
children: [
|
||||||
SvgPicture.asset(Assets.emptyTable),
|
SvgPicture.asset(Assets.emptyTable),
|
||||||
const SizedBox(height: 15),
|
const SizedBox(
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
const Text(
|
const Text(
|
||||||
'No Users',
|
'No Users',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: ColorsManager.lightGrayColor,
|
color: ColorsManager.lightGrayColor,
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
fontWeight: FontWeight.w700,
|
fontWeight: FontWeight.w700),
|
||||||
),
|
)
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
);
|
: Center(
|
||||||
}
|
child: Container(
|
||||||
|
width: totalWidth,
|
||||||
return Container(
|
|
||||||
decoration: containerDecoration.copyWith(
|
decoration: containerDecoration.copyWith(
|
||||||
color: ColorsManager.whiteColors,
|
color: ColorsManager.whiteColors,
|
||||||
borderRadius: const BorderRadius.only(
|
borderRadius: const BorderRadius.only(
|
||||||
bottomLeft: Radius.circular(15),
|
bottomLeft: Radius.circular(15),
|
||||||
bottomRight: Radius.circular(15),
|
bottomRight: Radius.circular(15))),
|
||||||
),
|
child: ListView.builder(
|
||||||
),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
child: Column(
|
shrinkWrap: true,
|
||||||
|
itemCount: widget.rows.length,
|
||||||
|
itemBuilder: (context, rowIndex) {
|
||||||
|
if (columnWidths.every((width) => width == 120.0)) {
|
||||||
|
columnWidths = List<double>.generate(
|
||||||
|
widget.titles.length, (index) {
|
||||||
|
if (index == 1) {
|
||||||
|
return screenWidth * 0.11;
|
||||||
|
} else if (index == 9) {
|
||||||
|
return screenWidth * 0.2;
|
||||||
|
}
|
||||||
|
return screenWidth * 0.11;
|
||||||
|
});
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
final row = widget.rows[rowIndex];
|
||||||
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
for (int rowIndex = 0; rowIndex < widget.rows.length; rowIndex++)
|
Container(
|
||||||
_TableRow(
|
child: Padding(
|
||||||
cells: widget.rows[rowIndex],
|
padding: const EdgeInsets.only(
|
||||||
columnWidths: columnWidths,
|
left: 5, top: 10, right: 5, bottom: 10),
|
||||||
isLast: rowIndex == widget.rows.length - 1,
|
child: Row(
|
||||||
|
children:
|
||||||
|
List.generate(row.length, (index) {
|
||||||
|
return SizedBox(
|
||||||
|
width: columnWidths[index],
|
||||||
|
child: SizedBox(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
left: 15, right: 10),
|
||||||
|
child: row[index],
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}),
|
||||||
|
),
|
||||||
@override
|
),
|
||||||
Widget build(BuildContext context) {
|
),
|
||||||
return LayoutBuilder(
|
if (rowIndex < widget.rows.length - 1)
|
||||||
builder: (context, constraints) {
|
Row(
|
||||||
final availableWidth = constraints.maxWidth;
|
children: List.generate(
|
||||||
final totalDividersWidth = (widget.titles.length - 1) * _dividerWidth;
|
widget.titles.length, (index) {
|
||||||
|
return SizedBox(
|
||||||
if (_lastAvailableWidth != availableWidth) {
|
width: columnWidths[index],
|
||||||
final equalWidth =
|
child: const Divider(
|
||||||
(availableWidth - totalDividersWidth) / widget.titles.length;
|
color: ColorsManager.boxDivider,
|
||||||
final clampedWidth =
|
thickness: 1,
|
||||||
equalWidth.clamp(_minColumnWidth, _maxColumnWidth);
|
height: 1,
|
||||||
|
),
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
);
|
||||||
setState(() {
|
}),
|
||||||
columnWidths = List.filled(widget.titles.length, clampedWidth);
|
|
||||||
_lastAvailableWidth = availableWidth;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
final totalTableWidth =
|
|
||||||
columnWidths.fold(0.0, (sum, w) => sum + w) + totalDividersWidth;
|
|
||||||
return SingleChildScrollView(
|
|
||||||
scrollDirection: Axis.horizontal,
|
|
||||||
child: Container(
|
|
||||||
width: totalTableWidth,
|
|
||||||
decoration: containerDecoration.copyWith(
|
|
||||||
color: ColorsManager.whiteColors,
|
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(20)),
|
|
||||||
),
|
),
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
_buildHeader(),
|
|
||||||
_buildBody(),
|
|
||||||
],
|
],
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,6 +108,7 @@ class UsersPage extends StatelessWidget {
|
|||||||
final screenSize = MediaQuery.of(context).size;
|
final screenSize = MediaQuery.of(context).size;
|
||||||
final _blocRole = BlocProvider.of<UserTableBloc>(context);
|
final _blocRole = BlocProvider.of<UserTableBloc>(context);
|
||||||
if (state is UsersLoadingState) {
|
if (state is UsersLoadingState) {
|
||||||
|
_blocRole.add(ChangePage(_blocRole.currentPage));
|
||||||
return const Center(child: CircularProgressIndicator());
|
return const Center(child: CircularProgressIndicator());
|
||||||
} else if (state is UsersLoadedState) {
|
} else if (state is UsersLoadedState) {
|
||||||
return Padding(
|
return Padding(
|
||||||
@ -214,7 +215,7 @@ class UsersPage extends StatelessWidget {
|
|||||||
|
|
||||||
showPopUpFilterMenu(
|
showPopUpFilterMenu(
|
||||||
position: RelativeRect.fromLTRB(
|
position: RelativeRect.fromLTRB(
|
||||||
overlay.size.width / 5.3,
|
overlay.size.width / 4,
|
||||||
240,
|
240,
|
||||||
overlay.size.width / 4,
|
overlay.size.width / 4,
|
||||||
0,
|
0,
|
||||||
@ -224,7 +225,6 @@ class UsersPage extends StatelessWidget {
|
|||||||
checkboxStates: checkboxStates,
|
checkboxStates: checkboxStates,
|
||||||
isSelected: _blocRole.currentSortOrder,
|
isSelected: _blocRole.currentSortOrder,
|
||||||
onOkPressed: () {
|
onOkPressed: () {
|
||||||
searchController.clear();
|
|
||||||
_blocRole.add(FilterClearEvent());
|
_blocRole.add(FilterClearEvent());
|
||||||
final selectedItems = checkboxStates.entries
|
final selectedItems = checkboxStates.entries
|
||||||
.where((entry) => entry.value)
|
.where((entry) => entry.value)
|
||||||
@ -265,7 +265,6 @@ class UsersPage extends StatelessWidget {
|
|||||||
checkboxStates: checkboxStates,
|
checkboxStates: checkboxStates,
|
||||||
isSelected: _blocRole.currentSortOrder,
|
isSelected: _blocRole.currentSortOrder,
|
||||||
onOkPressed: () {
|
onOkPressed: () {
|
||||||
searchController.clear();
|
|
||||||
_blocRole.add(FilterClearEvent());
|
_blocRole.add(FilterClearEvent());
|
||||||
final selectedItems = checkboxStates.entries
|
final selectedItems = checkboxStates.entries
|
||||||
.where((entry) => entry.value)
|
.where((entry) => entry.value)
|
||||||
@ -321,7 +320,6 @@ class UsersPage extends StatelessWidget {
|
|||||||
checkboxStates: checkboxStates,
|
checkboxStates: checkboxStates,
|
||||||
isSelected: _blocRole.currentSortOrder,
|
isSelected: _blocRole.currentSortOrder,
|
||||||
onOkPressed: () {
|
onOkPressed: () {
|
||||||
searchController.clear();
|
|
||||||
_blocRole.add(FilterClearEvent());
|
_blocRole.add(FilterClearEvent());
|
||||||
final selectedItems = checkboxStates.entries
|
final selectedItems = checkboxStates.entries
|
||||||
.where((entry) => entry.value)
|
.where((entry) => entry.value)
|
||||||
@ -345,7 +343,6 @@ class UsersPage extends StatelessWidget {
|
|||||||
for (var item in _blocRole.status)
|
for (var item in _blocRole.status)
|
||||||
item: _blocRole.selectedStatuses.contains(item),
|
item: _blocRole.selectedStatuses.contains(item),
|
||||||
};
|
};
|
||||||
|
|
||||||
final RenderBox overlay = Overlay.of(context)
|
final RenderBox overlay = Overlay.of(context)
|
||||||
.context
|
.context
|
||||||
.findRenderObject() as RenderBox;
|
.findRenderObject() as RenderBox;
|
||||||
@ -353,7 +350,7 @@ class UsersPage extends StatelessWidget {
|
|||||||
position: RelativeRect.fromLTRB(
|
position: RelativeRect.fromLTRB(
|
||||||
overlay.size.width / 0,
|
overlay.size.width / 0,
|
||||||
240,
|
240,
|
||||||
overlay.size.width / 5,
|
overlay.size.width / 4,
|
||||||
0,
|
0,
|
||||||
),
|
),
|
||||||
list: _blocRole.status,
|
list: _blocRole.status,
|
||||||
@ -361,8 +358,8 @@ class UsersPage extends StatelessWidget {
|
|||||||
checkboxStates: checkboxStates,
|
checkboxStates: checkboxStates,
|
||||||
isSelected: _blocRole.currentSortOrder,
|
isSelected: _blocRole.currentSortOrder,
|
||||||
onOkPressed: () {
|
onOkPressed: () {
|
||||||
searchController.clear();
|
|
||||||
_blocRole.add(FilterClearEvent());
|
_blocRole.add(FilterClearEvent());
|
||||||
|
|
||||||
final selectedItems = checkboxStates.entries
|
final selectedItems = checkboxStates.entries
|
||||||
.where((entry) => entry.value)
|
.where((entry) => entry.value)
|
||||||
.map((entry) => entry.key)
|
.map((entry) => entry.key)
|
||||||
@ -413,7 +410,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),
|
Text(user.jobTitle ?? '-'),
|
||||||
Text(user.roleType ?? ''),
|
Text(user.roleType ?? ''),
|
||||||
Text(user.createdDate ?? ''),
|
Text(user.createdDate ?? ''),
|
||||||
Text(user.createdTime ?? ''),
|
Text(user.createdTime ?? ''),
|
||||||
@ -430,6 +427,11 @@ class UsersPage extends StatelessWidget {
|
|||||||
userId: user.uuid,
|
userId: user.uuid,
|
||||||
onTap: user.status != "invited"
|
onTap: user.status != "invited"
|
||||||
? () {
|
? () {
|
||||||
|
// final newStatus = user.status == 'active'
|
||||||
|
// ? 'disabled'
|
||||||
|
// : user.status == 'disabled'
|
||||||
|
// ? 'invited'
|
||||||
|
// : 'active';
|
||||||
context.read<UserTableBloc>().add(
|
context.read<UserTableBloc>().add(
|
||||||
ChangeUserStatus(
|
ChangeUserStatus(
|
||||||
userId: user.uuid,
|
userId: user.uuid,
|
||||||
@ -441,6 +443,10 @@ class UsersPage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
|
// actionButton(
|
||||||
|
// title: "Activity Log",
|
||||||
|
// onTap: () {},
|
||||||
|
// ),
|
||||||
actionButton(
|
actionButton(
|
||||||
title: "Edit",
|
title: "Edit",
|
||||||
onTap: () {
|
onTap: () {
|
||||||
@ -480,9 +486,11 @@ class UsersPage extends StatelessWidget {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
).then((v) {
|
).then((v) {
|
||||||
|
if (v != null) {
|
||||||
if (v != null) {
|
if (v != null) {
|
||||||
_blocRole.add(const GetUsers());
|
_blocRole.add(const GetUsers());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/effective_period/effect_period_event.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/effective_period/effect_period_event.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/effective_period/effect_period_state.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/effective_period/effect_period_state.dart';
|
||||||
import 'package:syncrow_web/utils/constants/app_enum.dart';
|
import 'package:syncrow_web/utils/constants/app_enum.dart';
|
||||||
|
|
||||||
class EffectPeriodBloc extends Bloc<EffectPeriodEvent, EffectPeriodState> {
|
class EffectPeriodBloc extends Bloc<EffectPeriodEvent, EffectPeriodState> {
|
@ -1,5 +1,5 @@
|
|||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/create_scene_and_autoamtion/create_automation_model.dart';
|
import 'package:syncrow_web/pages/routiens/models/create_scene_and_autoamtion/create_automation_model.dart';
|
||||||
import 'package:syncrow_web/utils/constants/app_enum.dart';
|
import 'package:syncrow_web/utils/constants/app_enum.dart';
|
||||||
|
|
||||||
abstract class EffectPeriodEvent extends Equatable {
|
abstract class EffectPeriodEvent extends Equatable {
|
@ -2,7 +2,7 @@ import 'dart:async';
|
|||||||
|
|
||||||
import 'package:bloc/bloc.dart';
|
import 'package:bloc/bloc.dart';
|
||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
import 'package:syncrow_web/pages/routiens/models/device_functions.dart';
|
||||||
|
|
||||||
part 'functions_bloc_event.dart';
|
part 'functions_bloc_event.dart';
|
||||||
part 'functions_bloc_state.dart';
|
part 'functions_bloc_state.dart';
|
||||||
@ -26,7 +26,8 @@ class FunctionBloc extends Bloc<FunctionBlocEvent, FunctionBlocState> {
|
|||||||
functionCode: event.functionData.functionCode,
|
functionCode: event.functionData.functionCode,
|
||||||
operationName: event.functionData.operationName,
|
operationName: event.functionData.operationName,
|
||||||
value: event.functionData.value ?? existingData.value,
|
value: event.functionData.value ?? existingData.value,
|
||||||
valueDescription: event.functionData.valueDescription ?? existingData.valueDescription,
|
valueDescription: event.functionData.valueDescription ??
|
||||||
|
existingData.valueDescription,
|
||||||
condition: event.functionData.condition ?? existingData.condition,
|
condition: event.functionData.condition ?? existingData.condition,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@ -58,8 +59,10 @@ class FunctionBloc extends Bloc<FunctionBlocEvent, FunctionBlocState> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
FutureOr<void> _onSelectFunction(SelectFunction event, Emitter<FunctionBlocState> emit) {
|
FutureOr<void> _onSelectFunction(
|
||||||
|
SelectFunction event, Emitter<FunctionBlocState> emit) {
|
||||||
emit(state.copyWith(
|
emit(state.copyWith(
|
||||||
selectedFunction: event.functionCode, selectedOperationName: event.operationName));
|
selectedFunction: event.functionCode,
|
||||||
|
selectedOperationName: event.operationName));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,12 +4,12 @@ import 'package:bloc/bloc.dart';
|
|||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/create_scene_and_autoamtion/create_automation_model.dart';
|
import 'package:syncrow_web/pages/routiens/models/create_scene_and_autoamtion/create_automation_model.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/create_scene_and_autoamtion/create_scene_model.dart';
|
import 'package:syncrow_web/pages/routiens/models/create_scene_and_autoamtion/create_scene_model.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/delay/delay_fucntions.dart';
|
import 'package:syncrow_web/pages/routiens/models/delay/delay_fucntions.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
import 'package:syncrow_web/pages/routiens/models/device_functions.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/routine_details_model.dart';
|
import 'package:syncrow_web/pages/routiens/models/routine_details_model.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/routine_model.dart';
|
import 'package:syncrow_web/pages/routiens/models/routine_model.dart';
|
||||||
import 'package:syncrow_web/services/devices_mang_api.dart';
|
import 'package:syncrow_web/services/devices_mang_api.dart';
|
||||||
import 'package:syncrow_web/services/routines_api.dart';
|
import 'package:syncrow_web/services/routines_api.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
@ -19,8 +19,8 @@ import 'package:uuid/uuid.dart';
|
|||||||
part 'routine_event.dart';
|
part 'routine_event.dart';
|
||||||
part 'routine_state.dart';
|
part 'routine_state.dart';
|
||||||
|
|
||||||
String spaceId = '25c96044-fadf-44bb-93c7-3c079e527ce6';
|
const spaceId = '25c96044-fadf-44bb-93c7-3c079e527ce6';
|
||||||
String communityId = 'aff21a57-2f91-4e5c-b99b-0182c3ab65a9';
|
const communityId = 'aff21a57-2f91-4e5c-b99b-0182c3ab65a9';
|
||||||
|
|
||||||
class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||||
RoutineBloc() : super(const RoutineState()) {
|
RoutineBloc() : super(const RoutineState()) {
|
||||||
@ -57,8 +57,8 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
emit(state.copyWith(routineTab: event.isRoutineTab, createRoutineView: false));
|
emit(state.copyWith(routineTab: event.isRoutineTab, createRoutineView: false));
|
||||||
add(ResetRoutineState());
|
add(ResetRoutineState());
|
||||||
if (event.isRoutineTab) {
|
if (event.isRoutineTab) {
|
||||||
add(LoadScenes(spaceId, communityId));
|
add(const LoadScenes(spaceId, communityId));
|
||||||
add(LoadAutomation(spaceId));
|
add(const LoadAutomation(spaceId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,14 +156,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
emit(state.copyWith(isLoading: true, errorMessage: null));
|
emit(state.copyWith(isLoading: true, errorMessage: null));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
spaceId = event.spaceId;
|
final scenes = await SceneApi.getScenesByUnitId(event.unitId, event.communityId);
|
||||||
communityId = event.communityId;
|
|
||||||
|
|
||||||
List<ScenesModel> scenes = [];
|
|
||||||
|
|
||||||
if (communityId.isNotEmpty && spaceId.isNotEmpty) {
|
|
||||||
scenes = await SceneApi.getScenes(event.spaceId, event.communityId);
|
|
||||||
}
|
|
||||||
emit(state.copyWith(
|
emit(state.copyWith(
|
||||||
scenes: scenes,
|
scenes: scenes,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
@ -174,7 +167,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
loadScenesErrorMessage: 'Failed to load scenes',
|
loadScenesErrorMessage: 'Failed to load scenes',
|
||||||
errorMessage: '',
|
errorMessage: '',
|
||||||
loadAutomationErrorMessage: '',
|
loadAutomationErrorMessage: '',
|
||||||
scenes: []));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,22 +175,27 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
emit(state.copyWith(isLoading: true, errorMessage: null));
|
emit(state.copyWith(isLoading: true, errorMessage: null));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
spaceId = event.spaceId;
|
final automations = await SceneApi.getAutomationByUnitId(event.unitId);
|
||||||
List<ScenesModel> automations = [];
|
if (automations.isNotEmpty) {
|
||||||
if (spaceId.isNotEmpty) {
|
|
||||||
automations = await SceneApi.getAutomation(event.spaceId);
|
|
||||||
}
|
|
||||||
emit(state.copyWith(
|
emit(state.copyWith(
|
||||||
automations: automations,
|
automations: automations,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
));
|
));
|
||||||
|
} else {
|
||||||
|
emit(state.copyWith(
|
||||||
|
isLoading: false,
|
||||||
|
loadAutomationErrorMessage: 'Failed to load automations',
|
||||||
|
errorMessage: '',
|
||||||
|
loadScenesErrorMessage: '',
|
||||||
|
));
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(state.copyWith(
|
emit(state.copyWith(
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
loadAutomationErrorMessage: 'Failed to load automations',
|
loadAutomationErrorMessage: 'Failed to load automations',
|
||||||
errorMessage: '',
|
errorMessage: '',
|
||||||
loadScenesErrorMessage: '',
|
loadScenesErrorMessage: '',
|
||||||
automations: []));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,8 +290,8 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
final result = await SceneApi.createScene(createSceneModel);
|
final result = await SceneApi.createScene(createSceneModel);
|
||||||
if (result['success']) {
|
if (result['success']) {
|
||||||
add(ResetRoutineState());
|
add(ResetRoutineState());
|
||||||
add(LoadScenes(spaceId, communityId));
|
add(const LoadScenes(spaceId, communityId));
|
||||||
add(LoadAutomation(spaceId));
|
add(const LoadAutomation(spaceId));
|
||||||
} else {
|
} else {
|
||||||
emit(state.copyWith(
|
emit(state.copyWith(
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
@ -421,8 +419,8 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
final result = await SceneApi.createAutomation(createAutomationModel);
|
final result = await SceneApi.createAutomation(createAutomationModel);
|
||||||
if (result['success']) {
|
if (result['success']) {
|
||||||
add(ResetRoutineState());
|
add(ResetRoutineState());
|
||||||
add(LoadAutomation(spaceId));
|
add(const LoadAutomation(spaceId));
|
||||||
add(LoadScenes(spaceId, communityId));
|
add(const LoadScenes(spaceId, communityId));
|
||||||
} else {
|
} else {
|
||||||
emit(state.copyWith(
|
emit(state.copyWith(
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
@ -787,8 +785,8 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
SceneApi.deleteAutomation(unitUuid: spaceId, automationId: state.automationId ?? '');
|
SceneApi.deleteAutomation(unitUuid: spaceId, automationId: state.automationId ?? '');
|
||||||
}
|
}
|
||||||
|
|
||||||
add(LoadScenes(spaceId, communityId));
|
add(const LoadScenes(spaceId, communityId));
|
||||||
add(LoadAutomation(spaceId));
|
add(const LoadAutomation(spaceId));
|
||||||
add(ResetRoutineState());
|
add(ResetRoutineState());
|
||||||
emit(state.copyWith(isLoading: false, createRoutineView: false));
|
emit(state.copyWith(isLoading: false, createRoutineView: false));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -816,7 +814,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
FutureOr<void> _fetchDevices(FetchDevicesInRoutine event, Emitter<RoutineState> emit) async {
|
FutureOr<void> _fetchDevices(FetchDevicesInRoutine event, Emitter<RoutineState> emit) async {
|
||||||
emit(state.copyWith(isLoading: true));
|
emit(state.copyWith(isLoading: true));
|
||||||
try {
|
try {
|
||||||
final devices = await DevicesManagementApi().fetchDevices(communityId, spaceId);
|
final devices = await DevicesManagementApi().fetchDevices();
|
||||||
|
|
||||||
emit(state.copyWith(isLoading: false, devices: devices));
|
emit(state.copyWith(isLoading: false, devices: devices));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -894,8 +892,8 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
final result = await SceneApi.updateScene(createSceneModel, state.sceneId ?? '');
|
final result = await SceneApi.updateScene(createSceneModel, state.sceneId ?? '');
|
||||||
if (result['success']) {
|
if (result['success']) {
|
||||||
add(ResetRoutineState());
|
add(ResetRoutineState());
|
||||||
add(LoadScenes(spaceId, communityId));
|
add(const LoadScenes(spaceId, communityId));
|
||||||
add(LoadAutomation(spaceId));
|
add(const LoadAutomation(spaceId));
|
||||||
} else {
|
} else {
|
||||||
emit(state.copyWith(
|
emit(state.copyWith(
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
@ -1023,8 +1021,8 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
|
|
||||||
if (result['success']) {
|
if (result['success']) {
|
||||||
add(ResetRoutineState());
|
add(ResetRoutineState());
|
||||||
add(LoadAutomation(spaceId));
|
add(const LoadAutomation(spaceId));
|
||||||
add(LoadScenes(spaceId, communityId));
|
add(const LoadScenes(spaceId, communityId));
|
||||||
} else {
|
} else {
|
||||||
emit(state.copyWith(
|
emit(state.copyWith(
|
||||||
isLoading: false,
|
isLoading: false,
|
@ -27,22 +27,22 @@ class AddToThenContainer extends RoutineEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class LoadScenes extends RoutineEvent {
|
class LoadScenes extends RoutineEvent {
|
||||||
final String spaceId;
|
final String unitId;
|
||||||
final String communityId;
|
final String communityId;
|
||||||
|
|
||||||
const LoadScenes(this.spaceId, this.communityId);
|
const LoadScenes(this.unitId, this.communityId);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [spaceId, communityId];
|
List<Object> get props => [unitId, communityId];
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadAutomation extends RoutineEvent {
|
class LoadAutomation extends RoutineEvent {
|
||||||
final String spaceId;
|
final String unitId;
|
||||||
|
|
||||||
const LoadAutomation(this.spaceId);
|
const LoadAutomation(this.unitId);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [spaceId];
|
List<Object> get props => [unitId];
|
||||||
}
|
}
|
||||||
|
|
||||||
class AddFunctionToRoutine extends RoutineEvent {
|
class AddFunctionToRoutine extends RoutineEvent {
|
@ -1,7 +1,7 @@
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/setting_bloc/setting_event.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/setting_bloc/setting_event.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/setting_bloc/setting_state.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/setting_bloc/setting_state.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/icon_model.dart';
|
import 'package:syncrow_web/pages/routiens/models/icon_model.dart';
|
||||||
import 'package:syncrow_web/services/routines_api.dart';
|
import 'package:syncrow_web/services/routines_api.dart';
|
||||||
|
|
||||||
class SettingBloc extends Bloc<SettingEvent, SettingState> {
|
class SettingBloc extends Bloc<SettingEvent, SettingState> {
|
@ -1,5 +1,5 @@
|
|||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/icon_model.dart';
|
import 'package:syncrow_web/pages/routiens/models/icon_model.dart';
|
||||||
|
|
||||||
abstract class SettingState extends Equatable {
|
abstract class SettingState extends Equatable {
|
||||||
const SettingState();
|
const SettingState();
|
@ -0,0 +1,85 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc/routine_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/routiens/widgets/routine_dialogs/ac_dialog.dart';
|
||||||
|
import 'package:syncrow_web/pages/routiens/widgets/routine_dialogs/one_gang_switch_dialog.dart';
|
||||||
|
import 'package:syncrow_web/pages/routiens/widgets/routine_dialogs/three_gang_switch_dialog.dart';
|
||||||
|
import 'package:syncrow_web/pages/routiens/widgets/routine_dialogs/two_gang_switch_dialog.dart';
|
||||||
|
import 'package:syncrow_web/pages/routiens/models/device_functions.dart';
|
||||||
|
|
||||||
|
class DeviceDialogHelper {
|
||||||
|
static Future<Map<String, dynamic>?> showDeviceDialog(
|
||||||
|
BuildContext context,
|
||||||
|
Map<String, dynamic> data, {
|
||||||
|
required bool removeComparetors,
|
||||||
|
}) async {
|
||||||
|
final functions = data['functions'] as List<DeviceFunction>;
|
||||||
|
|
||||||
|
try {
|
||||||
|
final result = await _getDialogForDeviceType(
|
||||||
|
context,
|
||||||
|
data['productType'],
|
||||||
|
data,
|
||||||
|
functions,
|
||||||
|
removeComparetors: removeComparetors,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (result != null) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
debugPrint('Error: $e');
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<Map<String, dynamic>?> _getDialogForDeviceType(
|
||||||
|
BuildContext context,
|
||||||
|
String productType,
|
||||||
|
Map<String, dynamic> data,
|
||||||
|
List<DeviceFunction> functions,
|
||||||
|
{required bool removeComparetors}) async {
|
||||||
|
final routineBloc = context.read<RoutineBloc>();
|
||||||
|
final deviceSelectedFunctions =
|
||||||
|
routineBloc.state.selectedFunctions[data['uniqueCustomId']] ?? [];
|
||||||
|
|
||||||
|
switch (productType) {
|
||||||
|
case 'AC':
|
||||||
|
return ACHelper.showACFunctionsDialog(
|
||||||
|
context,
|
||||||
|
functions,
|
||||||
|
data['device'],
|
||||||
|
deviceSelectedFunctions,
|
||||||
|
data['uniqueCustomId'],
|
||||||
|
removeComparetors);
|
||||||
|
|
||||||
|
case '1G':
|
||||||
|
return OneGangSwitchHelper.showSwitchFunctionsDialog(
|
||||||
|
context,
|
||||||
|
functions,
|
||||||
|
data['device'],
|
||||||
|
deviceSelectedFunctions,
|
||||||
|
data['uniqueCustomId'],
|
||||||
|
removeComparetors);
|
||||||
|
case '2G':
|
||||||
|
return TwoGangSwitchHelper.showSwitchFunctionsDialog(
|
||||||
|
context,
|
||||||
|
functions,
|
||||||
|
data['device'],
|
||||||
|
deviceSelectedFunctions,
|
||||||
|
data['uniqueCustomId'],
|
||||||
|
removeComparetors);
|
||||||
|
case '3G':
|
||||||
|
return ThreeGangSwitchHelper.showSwitchFunctionsDialog(
|
||||||
|
context,
|
||||||
|
functions,
|
||||||
|
data['device'],
|
||||||
|
deviceSelectedFunctions,
|
||||||
|
data['uniqueCustomId'],
|
||||||
|
removeComparetors);
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,9 +3,9 @@ import 'dart:convert';
|
|||||||
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:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/dialog_header.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/dialog_header.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/dialog_footer.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/dialog_footer.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';
|
||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
@ -1,6 +1,6 @@
|
|||||||
import 'package:syncrow_web/pages/device_managment/ac/model/ac_model.dart';
|
import 'package:syncrow_web/pages/device_managment/ac/model/ac_model.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/ac/ac_operational_value.dart';
|
import 'package:syncrow_web/pages/routiens/models/ac/ac_operational_value.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
import 'package:syncrow_web/pages/routiens/models/device_functions.dart';
|
||||||
import 'package:syncrow_web/utils/constants/app_enum.dart';
|
import 'package:syncrow_web/utils/constants/app_enum.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
import 'package:syncrow_web/pages/routines/models/gang_switches/base_switch_function.dart';
|
import 'package:syncrow_web/pages/routiens/models/gang_switches/base_switch_function.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/gang_switches/switch_operational_value.dart';
|
import 'package:syncrow_web/pages/routiens/models/gang_switches/switch_operational_value.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
|
|
||||||
class DelayFunction extends BaseSwitchFunction {
|
class DelayFunction extends BaseSwitchFunction {
|
@ -1,5 +1,5 @@
|
|||||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
import 'package:syncrow_web/pages/routiens/models/device_functions.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/gang_switches/switch_operational_value.dart';
|
import 'package:syncrow_web/pages/routiens/models/gang_switches/switch_operational_value.dart';
|
||||||
|
|
||||||
abstract class BaseSwitchFunction extends DeviceFunction<bool> {
|
abstract class BaseSwitchFunction extends DeviceFunction<bool> {
|
||||||
BaseSwitchFunction({
|
BaseSwitchFunction({
|
@ -1,5 +1,5 @@
|
|||||||
import 'package:syncrow_web/pages/routines/models/gang_switches/base_switch_function.dart';
|
import 'package:syncrow_web/pages/routiens/models/gang_switches/base_switch_function.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/gang_switches/switch_operational_value.dart';
|
import 'package:syncrow_web/pages/routiens/models/gang_switches/switch_operational_value.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
|
|
||||||
class OneGangSwitchFunction extends BaseSwitchFunction {
|
class OneGangSwitchFunction extends BaseSwitchFunction {
|
@ -1,5 +1,5 @@
|
|||||||
import 'package:syncrow_web/pages/routines/models/gang_switches/base_switch_function.dart';
|
import 'package:syncrow_web/pages/routiens/models/gang_switches/base_switch_function.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/gang_switches/switch_operational_value.dart';
|
import 'package:syncrow_web/pages/routiens/models/gang_switches/switch_operational_value.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
|
|
||||||
class ThreeGangSwitch1Function extends BaseSwitchFunction {
|
class ThreeGangSwitch1Function extends BaseSwitchFunction {
|
||||||
@ -26,7 +26,8 @@ class ThreeGangSwitch1Function extends BaseSwitchFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ThreeGangCountdown1Function extends BaseSwitchFunction {
|
class ThreeGangCountdown1Function extends BaseSwitchFunction {
|
||||||
ThreeGangCountdown1Function({required super.deviceId, required super.deviceName})
|
ThreeGangCountdown1Function(
|
||||||
|
{required super.deviceId, required super.deviceName})
|
||||||
: super(
|
: super(
|
||||||
code: 'countdown_1',
|
code: 'countdown_1',
|
||||||
operationName: 'Light 1 Countdown',
|
operationName: 'Light 1 Countdown',
|
||||||
@ -70,7 +71,8 @@ class ThreeGangSwitch2Function extends BaseSwitchFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ThreeGangCountdown2Function extends BaseSwitchFunction {
|
class ThreeGangCountdown2Function extends BaseSwitchFunction {
|
||||||
ThreeGangCountdown2Function({required super.deviceId, required super.deviceName})
|
ThreeGangCountdown2Function(
|
||||||
|
{required super.deviceId, required super.deviceName})
|
||||||
: super(
|
: super(
|
||||||
code: 'countdown_2',
|
code: 'countdown_2',
|
||||||
operationName: 'Light 2 Countdown',
|
operationName: 'Light 2 Countdown',
|
||||||
@ -114,7 +116,8 @@ class ThreeGangSwitch3Function extends BaseSwitchFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ThreeGangCountdown3Function extends BaseSwitchFunction {
|
class ThreeGangCountdown3Function extends BaseSwitchFunction {
|
||||||
ThreeGangCountdown3Function({required super.deviceId, required super.deviceName})
|
ThreeGangCountdown3Function(
|
||||||
|
{required super.deviceId, required super.deviceName})
|
||||||
: super(
|
: super(
|
||||||
code: 'countdown_3',
|
code: 'countdown_3',
|
||||||
operationName: 'Light 3 Countdown',
|
operationName: 'Light 3 Countdown',
|
@ -1,5 +1,5 @@
|
|||||||
import 'package:syncrow_web/pages/routines/models/gang_switches/base_switch_function.dart';
|
import 'package:syncrow_web/pages/routiens/models/gang_switches/base_switch_function.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/gang_switches/switch_operational_value.dart';
|
import 'package:syncrow_web/pages/routiens/models/gang_switches/switch_operational_value.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
|
|
||||||
class TwoGangSwitch1Function extends BaseSwitchFunction {
|
class TwoGangSwitch1Function extends BaseSwitchFunction {
|
||||||
@ -49,7 +49,8 @@ class TwoGangSwitch2Function extends BaseSwitchFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class TwoGangCountdown1Function extends BaseSwitchFunction {
|
class TwoGangCountdown1Function extends BaseSwitchFunction {
|
||||||
TwoGangCountdown1Function({required super.deviceId, required super.deviceName})
|
TwoGangCountdown1Function(
|
||||||
|
{required super.deviceId, required super.deviceName})
|
||||||
: super(
|
: super(
|
||||||
code: 'countdown_1',
|
code: 'countdown_1',
|
||||||
operationName: 'Light 1 Countdown',
|
operationName: 'Light 1 Countdown',
|
||||||
@ -70,7 +71,8 @@ class TwoGangCountdown1Function extends BaseSwitchFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class TwoGangCountdown2Function extends BaseSwitchFunction {
|
class TwoGangCountdown2Function extends BaseSwitchFunction {
|
||||||
TwoGangCountdown2Function({required super.deviceId, required super.deviceName})
|
TwoGangCountdown2Function(
|
||||||
|
{required super.deviceId, required super.deviceName})
|
||||||
: super(
|
: super(
|
||||||
code: 'countdown_2',
|
code: 'countdown_2',
|
||||||
operationName: 'Light 2 Countdown',
|
operationName: 'Light 2 Countdown',
|
@ -1,7 +1,7 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:syncrow_web/pages/routines/models/create_scene_and_autoamtion/create_automation_model.dart';
|
import 'package:syncrow_web/pages/routiens/models/create_scene_and_autoamtion/create_automation_model.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/create_scene_and_autoamtion/create_scene_model.dart';
|
import 'package:syncrow_web/pages/routiens/models/create_scene_and_autoamtion/create_scene_model.dart';
|
||||||
|
|
||||||
class RoutineDetailsModel {
|
class RoutineDetailsModel {
|
||||||
final String spaceUuid;
|
final String spaceUuid;
|
@ -1,8 +1,8 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/conditions_routines_devices_view.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/conditions_routines_devices_view.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/if_container.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/if_container.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_search_and_buttons.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/routine_search_and_buttons.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/then_container.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/then_container.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
|
||||||
class CreateNewRoutineView extends StatelessWidget {
|
class CreateNewRoutineView extends StatelessWidget {
|
@ -1,7 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/effictive_period_dialog.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/routine_dialogs/effictive_period_dialog.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/period_option.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/period_option.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/repeat_days.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/repeat_days.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
|
||||||
class EffectivePeriodView extends StatelessWidget {
|
class EffectivePeriodView extends StatelessWidget {
|
69
lib/pages/routiens/view/routines_view.dart
Normal file
69
lib/pages/routiens/view/routines_view.dart
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc/routine_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/routiens/view/create_new_routine_view.dart';
|
||||||
|
import 'package:syncrow_web/pages/routiens/widgets/main_routine_view/fetch_routine_scenes_automation.dart';
|
||||||
|
import 'package:syncrow_web/pages/routiens/widgets/main_routine_view/routine_view_card.dart';
|
||||||
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
|
||||||
|
class RoutinesView extends StatefulWidget {
|
||||||
|
const RoutinesView({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<RoutinesView> createState() => _RoutinesViewState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _RoutinesViewState extends State<RoutinesView> {
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
context.read<RoutineBloc>().add(FetchDevicesInRoutine());
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return BlocBuilder<RoutineBloc, RoutineState>(
|
||||||
|
builder: (context, state) {
|
||||||
|
if (state.createRoutineView) {
|
||||||
|
return const CreateNewRoutineView();
|
||||||
|
}
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Create New Routines",
|
||||||
|
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||||
|
color: ColorsManager.grayColor,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
RoutineViewCard(
|
||||||
|
onTap: () {
|
||||||
|
context.read<RoutineBloc>().add(
|
||||||
|
(ResetRoutineState()),
|
||||||
|
);
|
||||||
|
BlocProvider.of<RoutineBloc>(context).add(
|
||||||
|
const CreateNewRoutineViewEvent(createRoutineView: true),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
icon: Icons.add,
|
||||||
|
textString: '',
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
const Expanded(child: FetchRoutineScenesAutomation()),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +1,11 @@
|
|||||||
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:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/dragable_card.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/dragable_card.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_devices.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/routine_devices.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routines_title_widget.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/routines_title_widget.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/scenes_and_automations.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/scenes_and_automations.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/search_bar_condition_title.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/search_bar_condition_title.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
|
|
||||||
class ConditionsRoutinesDevicesView extends StatelessWidget {
|
class ConditionsRoutinesDevicesView extends StatelessWidget {
|
@ -1,7 +1,7 @@
|
|||||||
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:syncrow_web/pages/common/custom_dialog.dart';
|
import 'package:syncrow_web/pages/common/custom_dialog.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
|
||||||
class DeleteSceneWidget extends StatelessWidget {
|
class DeleteSceneWidget extends StatelessWidget {
|
@ -3,8 +3,8 @@ import 'dart:convert';
|
|||||||
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:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
import 'package:syncrow_web/pages/routiens/models/device_functions.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
|
|
@ -1,8 +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:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/helper/dialog_helper/device_dialog_helper.dart';
|
import 'package:syncrow_web/pages/routiens/helper/dialog_helper/device_dialog_helper.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/dragable_card.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/dragable_card.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';
|
||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
@ -26,7 +26,9 @@ class IfContainer extends StatelessWidget {
|
|||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
const Text('IF', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
|
const Text('IF',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 18, fontWeight: FontWeight.bold)),
|
||||||
if (state.isAutomation && state.ifItems.isNotEmpty)
|
if (state.isAutomation && state.ifItems.isNotEmpty)
|
||||||
AutomationOperatorSelector(
|
AutomationOperatorSelector(
|
||||||
selectedOperator: state.selectedAutomationOperator),
|
selectedOperator: state.selectedAutomationOperator),
|
||||||
@ -53,34 +55,44 @@ class IfContainer extends StatelessWidget {
|
|||||||
(index) => GestureDetector(
|
(index) => GestureDetector(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
if (!state.isTabToRun) {
|
if (!state.isTabToRun) {
|
||||||
final result = await DeviceDialogHelper.showDeviceDialog(
|
final result = await DeviceDialogHelper
|
||||||
|
.showDeviceDialog(
|
||||||
context, state.ifItems[index],
|
context, state.ifItems[index],
|
||||||
removeComparetors: false);
|
removeComparetors: false);
|
||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
context
|
context.read<RoutineBloc>().add(
|
||||||
.read<RoutineBloc>()
|
AddToIfContainer(
|
||||||
.add(AddToIfContainer(state.ifItems[index], false));
|
state.ifItems[index], false));
|
||||||
} else if (!['AC', '1G', '2G', '3G']
|
} else if (![
|
||||||
.contains(state.ifItems[index]['productType'])) {
|
'AC',
|
||||||
context
|
'1G',
|
||||||
.read<RoutineBloc>()
|
'2G',
|
||||||
.add(AddToIfContainer(state.ifItems[index], false));
|
'3G'
|
||||||
|
].contains(
|
||||||
|
state.ifItems[index]['productType'])) {
|
||||||
|
context.read<RoutineBloc>().add(
|
||||||
|
AddToIfContainer(
|
||||||
|
state.ifItems[index], false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: DraggableCard(
|
child: DraggableCard(
|
||||||
imagePath: state.ifItems[index]['imagePath'] ?? '',
|
imagePath:
|
||||||
|
state.ifItems[index]['imagePath'] ?? '',
|
||||||
title: state.ifItems[index]['title'] ?? '',
|
title: state.ifItems[index]['title'] ?? '',
|
||||||
deviceData: state.ifItems[index],
|
deviceData: state.ifItems[index],
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 8),
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 4, vertical: 8),
|
||||||
isFromThen: false,
|
isFromThen: false,
|
||||||
isFromIf: true,
|
isFromIf: true,
|
||||||
onRemove: () {
|
onRemove: () {
|
||||||
context.read<RoutineBloc>().add(RemoveDragCard(
|
context.read<RoutineBloc>().add(
|
||||||
|
RemoveDragCard(
|
||||||
index: index,
|
index: index,
|
||||||
isFromThen: false,
|
isFromThen: false,
|
||||||
key: state.ifItems[index]['uniqueCustomId']));
|
key: state.ifItems[index]
|
||||||
|
['uniqueCustomId']));
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
@ -101,15 +113,23 @@ class IfContainer extends StatelessWidget {
|
|||||||
|
|
||||||
if (!state.isTabToRun) {
|
if (!state.isTabToRun) {
|
||||||
if (mutableData['deviceId'] == 'tab_to_run') {
|
if (mutableData['deviceId'] == 'tab_to_run') {
|
||||||
context.read<RoutineBloc>().add(AddToIfContainer(mutableData, true));
|
context
|
||||||
|
.read<RoutineBloc>()
|
||||||
|
.add(AddToIfContainer(mutableData, true));
|
||||||
} else {
|
} else {
|
||||||
final result = await DeviceDialogHelper.showDeviceDialog(context, mutableData,
|
final result = await DeviceDialogHelper.showDeviceDialog(
|
||||||
|
context, mutableData,
|
||||||
removeComparetors: false);
|
removeComparetors: false);
|
||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
context.read<RoutineBloc>().add(AddToIfContainer(mutableData, false));
|
context
|
||||||
} else if (!['AC', '1G', '2G', '3G'].contains(mutableData['productType'])) {
|
.read<RoutineBloc>()
|
||||||
context.read<RoutineBloc>().add(AddToIfContainer(mutableData, false));
|
.add(AddToIfContainer(mutableData, false));
|
||||||
|
} else if (!['AC', '1G', '2G', '3G']
|
||||||
|
.contains(mutableData['productType'])) {
|
||||||
|
context
|
||||||
|
.read<RoutineBloc>()
|
||||||
|
.add(AddToIfContainer(mutableData, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -155,7 +175,9 @@ class AutomationOperatorSelector extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
context.read<RoutineBloc>().add(const ChangeAutomationOperator(operator: 'or'));
|
context
|
||||||
|
.read<RoutineBloc>()
|
||||||
|
.add(const ChangeAutomationOperator(operator: 'or'));
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
@ -181,7 +203,9 @@ class AutomationOperatorSelector extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
context.read<RoutineBloc>().add(const ChangeAutomationOperator(operator: 'and'));
|
context
|
||||||
|
.read<RoutineBloc>()
|
||||||
|
.add(const ChangeAutomationOperator(operator: 'and'));
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
@ -0,0 +1,143 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc/routine_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/routiens/widgets/main_routine_view/routine_view_card.dart';
|
||||||
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
|
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
||||||
|
|
||||||
|
class FetchRoutineScenesAutomation extends StatefulWidget {
|
||||||
|
const FetchRoutineScenesAutomation({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<FetchRoutineScenesAutomation> createState() => _FetchRoutineScenesState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
|
||||||
|
with HelperResponsiveLayout {
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
context.read<RoutineBloc>()
|
||||||
|
..add(const LoadScenes(spaceId, communityId))
|
||||||
|
..add(const LoadAutomation(spaceId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return BlocBuilder<RoutineBloc, RoutineState>(
|
||||||
|
builder: (context, state) {
|
||||||
|
return state.isLoading
|
||||||
|
? const Center(
|
||||||
|
child: CircularProgressIndicator(),
|
||||||
|
)
|
||||||
|
: SingleChildScrollView(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Scenes (Tab to Run)",
|
||||||
|
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||||
|
color: ColorsManager.grayColor,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
if (state.scenes.isEmpty)
|
||||||
|
Text(
|
||||||
|
"No scenes found",
|
||||||
|
style: context.textTheme.bodyMedium?.copyWith(
|
||||||
|
color: ColorsManager.grayColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (state.scenes.isNotEmpty)
|
||||||
|
ConstrainedBox(
|
||||||
|
constraints: BoxConstraints(
|
||||||
|
maxHeight: isSmallScreenSize(context) ? 160 : 170,
|
||||||
|
),
|
||||||
|
child: ListView.builder(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
itemCount: state.scenes.length,
|
||||||
|
itemBuilder: (context, index) => Padding(
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
right: isSmallScreenSize(context) ? 4.0 : 8.0,
|
||||||
|
),
|
||||||
|
child: RoutineViewCard(
|
||||||
|
onTap: () {
|
||||||
|
BlocProvider.of<RoutineBloc>(context).add(
|
||||||
|
const CreateNewRoutineViewEvent(createRoutineView: true),
|
||||||
|
);
|
||||||
|
context.read<RoutineBloc>().add(
|
||||||
|
GetSceneDetails(
|
||||||
|
sceneId: state.scenes[index].id,
|
||||||
|
isTabToRun: true,
|
||||||
|
isUpdate: true,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
textString: state.scenes[index].name,
|
||||||
|
icon: state.scenes[index].icon ?? Assets.logoHorizontal,
|
||||||
|
isFromScenes: true,
|
||||||
|
iconInBytes: state.scenes[index].iconInBytes,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 15),
|
||||||
|
Text(
|
||||||
|
"Automations",
|
||||||
|
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||||
|
color: ColorsManager.grayColor,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
if (state.automations.isEmpty)
|
||||||
|
Text(
|
||||||
|
"No automations found",
|
||||||
|
style: context.textTheme.bodyMedium?.copyWith(
|
||||||
|
color: ColorsManager.grayColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (state.automations.isNotEmpty)
|
||||||
|
ConstrainedBox(
|
||||||
|
constraints: BoxConstraints(
|
||||||
|
maxHeight: isSmallScreenSize(context) ? 160 : 170,
|
||||||
|
),
|
||||||
|
child: ListView.builder(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
itemCount: state.automations.length,
|
||||||
|
itemBuilder: (context, index) => Padding(
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
right: isSmallScreenSize(context) ? 4.0 : 8.0,
|
||||||
|
),
|
||||||
|
child: RoutineViewCard(
|
||||||
|
onTap: () {
|
||||||
|
BlocProvider.of<RoutineBloc>(context).add(
|
||||||
|
const CreateNewRoutineViewEvent(createRoutineView: true),
|
||||||
|
);
|
||||||
|
context.read<RoutineBloc>().add(
|
||||||
|
GetAutomationDetails(
|
||||||
|
automationId: state.automations[index].id,
|
||||||
|
isAutomation: true,
|
||||||
|
isUpdate: true),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
textString: state.automations[index].name,
|
||||||
|
icon: state.automations[index].icon ?? Assets.automation,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -70,13 +70,15 @@ class RoutineViewCard extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
height: iconSize,
|
height: iconSize,
|
||||||
width: iconSize,
|
width: iconSize,
|
||||||
child: (isFromScenes ?? false)
|
child: (isFromScenes ?? false)
|
||||||
? (iconInBytes != null && iconInBytes?.isNotEmpty == true)
|
? (iconInBytes != null &&
|
||||||
|
iconInBytes?.isNotEmpty == true)
|
||||||
? Image.memory(
|
? Image.memory(
|
||||||
iconInBytes!,
|
iconInBytes!,
|
||||||
height: iconSize,
|
height: iconSize,
|
||||||
width: iconSize,
|
width: iconSize,
|
||||||
fit: BoxFit.contain,
|
fit: BoxFit.contain,
|
||||||
errorBuilder: (context, error, stackTrace) => Image.asset(
|
errorBuilder: (context, error, stackTrace) =>
|
||||||
|
Image.asset(
|
||||||
Assets.logo,
|
Assets.logo,
|
||||||
height: iconSize,
|
height: iconSize,
|
||||||
width: iconSize,
|
width: iconSize,
|
@ -1,9 +1,9 @@
|
|||||||
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:syncrow_web/pages/routines/bloc/effective_period/effect_period_bloc.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/effective_period/effect_period_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/effective_period/effect_period_event.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/effective_period/effect_period_event.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/effective_period/effect_period_state.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/effective_period/effect_period_state.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/effictive_period_dialog.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/routine_dialogs/effictive_period_dialog.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/constants/app_enum.dart';
|
import 'package:syncrow_web/utils/constants/app_enum.dart';
|
||||||
|
|
@ -1,8 +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:syncrow_web/pages/routines/bloc/effective_period/effect_period_bloc.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/effective_period/effect_period_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/effective_period/effect_period_event.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/effective_period/effect_period_event.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/effective_period/effect_period_state.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/effective_period/effect_period_state.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
|
||||||
class RepeatDays extends StatelessWidget {
|
class RepeatDays extends StatelessWidget {
|
@ -1,8 +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:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/dragable_card.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/dragable_card.dart';
|
||||||
|
|
||||||
class RoutineDevices extends StatelessWidget {
|
class RoutineDevices extends StatelessWidget {
|
||||||
const RoutineDevices({super.key});
|
const RoutineDevices({super.key});
|
||||||
@ -35,7 +35,9 @@ class RoutineDevices extends StatelessWidget {
|
|||||||
children: deviceList.asMap().entries.map((entry) {
|
children: deviceList.asMap().entries.map((entry) {
|
||||||
final device = entry.value;
|
final device = entry.value;
|
||||||
if (state.searchText != null && state.searchText!.isNotEmpty) {
|
if (state.searchText != null && state.searchText!.isNotEmpty) {
|
||||||
return device.name!.toLowerCase().contains(state.searchText!.toLowerCase())
|
return device.name!
|
||||||
|
.toLowerCase()
|
||||||
|
.contains(state.searchText!.toLowerCase())
|
||||||
? DraggableCard(
|
? DraggableCard(
|
||||||
imagePath: device.getDefaultIcon(device.productType),
|
imagePath: device.getDefaultIcon(device.productType),
|
||||||
title: device.name ?? '',
|
title: device.name ?? '',
|
@ -1,16 +1,16 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/ac/ac_function.dart';
|
import 'package:syncrow_web/pages/routiens/models/ac/ac_function.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/ac/ac_operational_value.dart';
|
import 'package:syncrow_web/pages/routiens/models/ac/ac_operational_value.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
import 'package:syncrow_web/pages/routiens/models/device_functions.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/dialog_footer.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/dialog_footer.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/dialog_header.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/dialog_header.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/functions_bloc/functions_bloc_bloc.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/functions_bloc/functions_bloc_bloc.dart';
|
||||||
|
|
||||||
class ACHelper {
|
class ACHelper {
|
||||||
static Future<Map<String, dynamic>?> showACFunctionsDialog(
|
static Future<Map<String, dynamic>?> showACFunctionsDialog(
|
||||||
@ -27,15 +27,16 @@ class ACHelper {
|
|||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (_) => FunctionBloc()..add(InitializeFunctions(deviceSelectedFunctions ?? [])),
|
create: (_) => FunctionBloc()
|
||||||
|
..add(InitializeFunctions(deviceSelectedFunctions ?? [])),
|
||||||
child: AlertDialog(
|
child: AlertDialog(
|
||||||
contentPadding: EdgeInsets.zero,
|
contentPadding: EdgeInsets.zero,
|
||||||
content: BlocBuilder<FunctionBloc, FunctionBlocState>(
|
content: BlocBuilder<FunctionBloc, FunctionBlocState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final selectedFunction = state.selectedFunction;
|
final selectedFunction = state.selectedFunction;
|
||||||
final selectedOperationName = state.selectedOperationName;
|
final selectedOperationName = state.selectedOperationName;
|
||||||
final selectedFunctionData =
|
final selectedFunctionData = state.addedFunctions
|
||||||
state.addedFunctions.firstWhere((f) => f.functionCode == selectedFunction,
|
.firstWhere((f) => f.functionCode == selectedFunction,
|
||||||
orElse: () => DeviceFunctionData(
|
orElse: () => DeviceFunctionData(
|
||||||
entityId: '',
|
entityId: '',
|
||||||
functionCode: selectedFunction ?? '',
|
functionCode: selectedFunction ?? '',
|
||||||
@ -65,8 +66,10 @@ class ACHelper {
|
|||||||
child: _buildFunctionsList(
|
child: _buildFunctionsList(
|
||||||
context: context,
|
context: context,
|
||||||
acFunctions: acFunctions,
|
acFunctions: acFunctions,
|
||||||
onFunctionSelected: (functionCode, operationName) =>
|
onFunctionSelected:
|
||||||
context.read<FunctionBloc>().add(SelectFunction(
|
(functionCode, operationName) => context
|
||||||
|
.read<FunctionBloc>()
|
||||||
|
.add(SelectFunction(
|
||||||
functionCode: functionCode,
|
functionCode: functionCode,
|
||||||
operationName: operationName,
|
operationName: operationName,
|
||||||
)),
|
)),
|
||||||
@ -181,7 +184,7 @@ class ACHelper {
|
|||||||
bool? removeComparators,
|
bool? removeComparators,
|
||||||
}) {
|
}) {
|
||||||
if (selectedFunction == 'temp_set' || selectedFunction == 'temp_current') {
|
if (selectedFunction == 'temp_set' || selectedFunction == 'temp_current') {
|
||||||
final initialValue = selectedFunctionData?.value ?? 250;
|
final initialValue = selectedFunctionData?.value ?? 200;
|
||||||
return _buildTemperatureSelector(
|
return _buildTemperatureSelector(
|
||||||
context: context,
|
context: context,
|
||||||
initialValue: initialValue,
|
initialValue: initialValue,
|
||||||
@ -194,7 +197,8 @@ class ACHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final selectedFn = acFunctions.firstWhere((f) => f.code == selectedFunction);
|
final selectedFn =
|
||||||
|
acFunctions.firstWhere((f) => f.code == selectedFunction);
|
||||||
final values = selectedFn.getOperationalValues();
|
final values = selectedFn.getOperationalValues();
|
||||||
|
|
||||||
return _buildOperationalValuesList(
|
return _buildOperationalValuesList(
|
||||||
@ -290,7 +294,8 @@ class ACHelper {
|
|||||||
minHeight: 40.0,
|
minHeight: 40.0,
|
||||||
minWidth: 40.0,
|
minWidth: 40.0,
|
||||||
),
|
),
|
||||||
isSelected: conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
isSelected:
|
||||||
|
conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
||||||
children: conditions.map((c) => Text(c)).toList(),
|
children: conditions.map((c) => Text(c)).toList(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -328,10 +333,10 @@ class ACHelper {
|
|||||||
String selectCode,
|
String selectCode,
|
||||||
) {
|
) {
|
||||||
return Slider(
|
return Slider(
|
||||||
value: initialValue is int ? initialValue.toDouble() : 200.0,
|
value: initialValue is int ? initialValue.toDouble() : 160.0,
|
||||||
min: 200,
|
min: 160,
|
||||||
max: 300,
|
max: 300,
|
||||||
divisions: 10,
|
divisions: 14,
|
||||||
label: '${((initialValue ?? 160) / 10).toInt()}°C',
|
label: '${((initialValue ?? 160) / 10).toInt()}°C',
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
context.read<FunctionBloc>().add(
|
context.read<FunctionBloc>().add(
|
||||||
@ -384,9 +389,13 @@ class ACHelper {
|
|||||||
style: context.textTheme.bodyMedium,
|
style: context.textTheme.bodyMedium,
|
||||||
),
|
),
|
||||||
trailing: Icon(
|
trailing: Icon(
|
||||||
isSelected ? Icons.radio_button_checked : Icons.radio_button_unchecked,
|
isSelected
|
||||||
|
? Icons.radio_button_checked
|
||||||
|
: Icons.radio_button_unchecked,
|
||||||
size: 24,
|
size: 24,
|
||||||
color: isSelected ? ColorsManager.primaryColorWithOpacity : ColorsManager.textGray,
|
color: isSelected
|
||||||
|
? ColorsManager.primaryColorWithOpacity
|
||||||
|
: ColorsManager.textGray,
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (!isSelected) {
|
if (!isSelected) {
|
||||||
@ -398,7 +407,8 @@ class ACHelper {
|
|||||||
operationName: operationName,
|
operationName: operationName,
|
||||||
value: value.value,
|
value: value.value,
|
||||||
condition: selectedFunctionData?.condition,
|
condition: selectedFunctionData?.condition,
|
||||||
valueDescription: selectedFunctionData?.valueDescription,
|
valueDescription:
|
||||||
|
selectedFunctionData?.valueDescription,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
@ -1,10 +1,10 @@
|
|||||||
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:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
import 'package:syncrow_web/pages/routiens/models/device_functions.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/dialog_header.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/dialog_header.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/dialog_footer.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/dialog_footer.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
|
|
||||||
class AutomationDialog extends StatefulWidget {
|
class AutomationDialog extends StatefulWidget {
|
||||||
@ -31,8 +31,10 @@ class _AutomationDialogState extends State<AutomationDialog> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
List<DeviceFunctionData>? functions =
|
List<DeviceFunctionData>? functions = context
|
||||||
context.read<RoutineBloc>().state.selectedFunctions[widget.uniqueCustomId];
|
.read<RoutineBloc>()
|
||||||
|
.state
|
||||||
|
.selectedFunctions[widget.uniqueCustomId];
|
||||||
for (DeviceFunctionData data in functions ?? []) {
|
for (DeviceFunctionData data in functions ?? []) {
|
||||||
if (data.entityId == widget.automationId) {
|
if (data.entityId == widget.automationId) {
|
||||||
selectedAutomationActionExecutor = data.value;
|
selectedAutomationActionExecutor = data.value;
|
||||||
@ -65,7 +67,8 @@ class _AutomationDialogState extends State<AutomationDialog> {
|
|||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: SvgPicture.asset(Assets.acPowerOff, width: 24, height: 24),
|
leading:
|
||||||
|
SvgPicture.asset(Assets.acPowerOff, width: 24, height: 24),
|
||||||
title: const Text('Disable'),
|
title: const Text('Disable'),
|
||||||
trailing: Radio<String?>(
|
trailing: Radio<String?>(
|
||||||
value: 'rule_disable',
|
value: 'rule_disable',
|
@ -1,10 +1,10 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.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:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
import 'package:syncrow_web/pages/routiens/models/device_functions.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/dialog_footer.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/dialog_footer.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/dialog_header.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/dialog_header.dart';
|
||||||
|
|
||||||
class DelayHelper {
|
class DelayHelper {
|
||||||
static Future<Map<String, dynamic>?> showDelayPickerDialog(
|
static Future<Map<String, dynamic>?> showDelayPickerDialog(
|
@ -1,6 +1,6 @@
|
|||||||
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:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
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:syncrow_web/pages/routines/bloc/effective_period/effect_period_bloc.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/effective_period/effect_period_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/effective_period/effect_period_event.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/effective_period/effect_period_event.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/constants/app_enum.dart';
|
import 'package:syncrow_web/utils/constants/app_enum.dart';
|
||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
@ -2,14 +2,14 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/functions_bloc/functions_bloc_bloc.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/functions_bloc/functions_bloc_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/helper/duration_format_helper.dart';
|
import 'package:syncrow_web/pages/routiens/helper/duration_format_helper.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
import 'package:syncrow_web/pages/routiens/models/device_functions.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/gang_switches/base_switch_function.dart';
|
import 'package:syncrow_web/pages/routiens/models/gang_switches/base_switch_function.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/gang_switches/switch_operational_value.dart';
|
import 'package:syncrow_web/pages/routiens/models/gang_switches/switch_operational_value.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/dialog_footer.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/dialog_footer.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/dialog_header.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/dialog_header.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
|
|
||||||
@ -22,21 +22,23 @@ class OneGangSwitchHelper {
|
|||||||
String uniqueCustomId,
|
String uniqueCustomId,
|
||||||
bool removeComparetors,
|
bool removeComparetors,
|
||||||
) async {
|
) async {
|
||||||
List<BaseSwitchFunction> acFunctions = functions.whereType<BaseSwitchFunction>().toList();
|
List<BaseSwitchFunction> acFunctions =
|
||||||
|
functions.whereType<BaseSwitchFunction>().toList();
|
||||||
|
|
||||||
return showDialog<Map<String, dynamic>?>(
|
return showDialog<Map<String, dynamic>?>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (_) => FunctionBloc()..add(InitializeFunctions(deviceSelectedFunctions ?? [])),
|
create: (_) => FunctionBloc()
|
||||||
|
..add(InitializeFunctions(deviceSelectedFunctions ?? [])),
|
||||||
child: AlertDialog(
|
child: AlertDialog(
|
||||||
contentPadding: EdgeInsets.zero,
|
contentPadding: EdgeInsets.zero,
|
||||||
content: BlocBuilder<FunctionBloc, FunctionBlocState>(
|
content: BlocBuilder<FunctionBloc, FunctionBlocState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final selectedFunction = state.selectedFunction;
|
final selectedFunction = state.selectedFunction;
|
||||||
final selectedOperationName = state.selectedOperationName;
|
final selectedOperationName = state.selectedOperationName;
|
||||||
final selectedFunctionData =
|
final selectedFunctionData = state.addedFunctions
|
||||||
state.addedFunctions.firstWhere((f) => f.functionCode == selectedFunction,
|
.firstWhere((f) => f.functionCode == selectedFunction,
|
||||||
orElse: () => DeviceFunctionData(
|
orElse: () => DeviceFunctionData(
|
||||||
entityId: '',
|
entityId: '',
|
||||||
functionCode: selectedFunction ?? '',
|
functionCode: selectedFunction ?? '',
|
||||||
@ -83,9 +85,12 @@ class OneGangSwitchHelper {
|
|||||||
color: ColorsManager.textGray,
|
color: ColorsManager.textGray,
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context.read<FunctionBloc>().add(SelectFunction(
|
context
|
||||||
|
.read<FunctionBloc>()
|
||||||
|
.add(SelectFunction(
|
||||||
functionCode: function.code,
|
functionCode: function.code,
|
||||||
operationName: function.operationName,
|
operationName:
|
||||||
|
function.operationName,
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -175,7 +180,8 @@ class OneGangSwitchHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final selectedFn = acFunctions.firstWhere((f) => f.code == selectedFunction);
|
final selectedFn =
|
||||||
|
acFunctions.firstWhere((f) => f.code == selectedFunction);
|
||||||
final values = selectedFn.getOperationalValues();
|
final values = selectedFn.getOperationalValues();
|
||||||
|
|
||||||
return _buildOperationalValuesList(
|
return _buildOperationalValuesList(
|
||||||
@ -212,11 +218,11 @@ class OneGangSwitchHelper {
|
|||||||
selectedFunctionData,
|
selectedFunctionData,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
_buildCountDownDisplay(
|
_buildCountDownDisplay(context, initialValue, device, operationName,
|
||||||
context, initialValue, device, operationName, selectedFunctionData, selectCode),
|
selectedFunctionData, selectCode),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
_buildCountDownSlider(
|
_buildCountDownSlider(context, initialValue, device, operationName,
|
||||||
context, initialValue, device, operationName, selectedFunctionData, selectCode),
|
selectedFunctionData, selectCode),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -257,7 +263,8 @@ class OneGangSwitchHelper {
|
|||||||
minHeight: 40.0,
|
minHeight: 40.0,
|
||||||
minWidth: 40.0,
|
minWidth: 40.0,
|
||||||
),
|
),
|
||||||
isSelected: conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
isSelected:
|
||||||
|
conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
||||||
children: conditions.map((c) => Text(c)).toList(),
|
children: conditions.map((c) => Text(c)).toList(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -305,7 +312,8 @@ class OneGangSwitchHelper {
|
|||||||
value: (initialValue ?? 0).toDouble(),
|
value: (initialValue ?? 0).toDouble(),
|
||||||
min: operationalValues.minValue?.toDouble() ?? 0.0,
|
min: operationalValues.minValue?.toDouble() ?? 0.0,
|
||||||
max: operationalValues.maxValue?.toDouble() ?? 0.0,
|
max: operationalValues.maxValue?.toDouble() ?? 0.0,
|
||||||
divisions: (((operationalValues.maxValue ?? 0) - (operationalValues.minValue ?? 0)) /
|
divisions: (((operationalValues.maxValue ?? 0) -
|
||||||
|
(operationalValues.minValue ?? 0)) /
|
||||||
(operationalValues.stepValue ?? 1))
|
(operationalValues.stepValue ?? 1))
|
||||||
.round(),
|
.round(),
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
@ -357,9 +365,13 @@ class OneGangSwitchHelper {
|
|||||||
style: context.textTheme.bodyMedium,
|
style: context.textTheme.bodyMedium,
|
||||||
),
|
),
|
||||||
trailing: Icon(
|
trailing: Icon(
|
||||||
isSelected ? Icons.radio_button_checked : Icons.radio_button_unchecked,
|
isSelected
|
||||||
|
? Icons.radio_button_checked
|
||||||
|
: Icons.radio_button_unchecked,
|
||||||
size: 24,
|
size: 24,
|
||||||
color: isSelected ? ColorsManager.primaryColorWithOpacity : ColorsManager.textGray,
|
color: isSelected
|
||||||
|
? ColorsManager.primaryColorWithOpacity
|
||||||
|
: ColorsManager.textGray,
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (!isSelected) {
|
if (!isSelected) {
|
||||||
@ -371,7 +383,8 @@ class OneGangSwitchHelper {
|
|||||||
operationName: operationName,
|
operationName: operationName,
|
||||||
value: value.value,
|
value: value.value,
|
||||||
condition: selectedFunctionData?.condition,
|
condition: selectedFunctionData?.condition,
|
||||||
valueDescription: selectedFunctionData?.valueDescription,
|
valueDescription:
|
||||||
|
selectedFunctionData?.valueDescription,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
@ -1,17 +1,17 @@
|
|||||||
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:syncrow_web/pages/routines/bloc/effective_period/effect_period_bloc.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/effective_period/effect_period_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/effective_period/effect_period_event.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/effective_period/effect_period_event.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/effective_period/effect_period_state.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/effective_period/effect_period_state.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/setting_bloc/setting_bloc.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/setting_bloc/setting_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/setting_bloc/setting_event.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/setting_bloc/setting_event.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/setting_bloc/setting_state.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/setting_bloc/setting_state.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/create_scene_and_autoamtion/create_automation_model.dart';
|
import 'package:syncrow_web/pages/routiens/models/create_scene_and_autoamtion/create_automation_model.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/icon_model.dart';
|
import 'package:syncrow_web/pages/routiens/models/icon_model.dart';
|
||||||
import 'package:syncrow_web/pages/routines/view/effective_period_view.dart';
|
import 'package:syncrow_web/pages/routiens/view/effective_period_view.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/delete_scene.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/delete_scene.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/dialog_header.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/dialog_header.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
|
|
@ -2,14 +2,14 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/functions_bloc/functions_bloc_bloc.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/functions_bloc/functions_bloc_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/helper/duration_format_helper.dart';
|
import 'package:syncrow_web/pages/routiens/helper/duration_format_helper.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
import 'package:syncrow_web/pages/routiens/models/device_functions.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/gang_switches/base_switch_function.dart';
|
import 'package:syncrow_web/pages/routiens/models/gang_switches/base_switch_function.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/gang_switches/switch_operational_value.dart';
|
import 'package:syncrow_web/pages/routiens/models/gang_switches/switch_operational_value.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/dialog_footer.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/dialog_footer.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/dialog_header.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/dialog_header.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
|
|
||||||
@ -22,21 +22,23 @@ class ThreeGangSwitchHelper {
|
|||||||
String uniqueCustomId,
|
String uniqueCustomId,
|
||||||
bool removeComparetors,
|
bool removeComparetors,
|
||||||
) async {
|
) async {
|
||||||
List<BaseSwitchFunction> switchFunctions = functions.whereType<BaseSwitchFunction>().toList();
|
List<BaseSwitchFunction> switchFunctions =
|
||||||
|
functions.whereType<BaseSwitchFunction>().toList();
|
||||||
|
|
||||||
return showDialog<Map<String, dynamic>?>(
|
return showDialog<Map<String, dynamic>?>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (_) => FunctionBloc()..add(InitializeFunctions(deviceSelectedFunctions ?? [])),
|
create: (_) => FunctionBloc()
|
||||||
|
..add(InitializeFunctions(deviceSelectedFunctions ?? [])),
|
||||||
child: AlertDialog(
|
child: AlertDialog(
|
||||||
contentPadding: EdgeInsets.zero,
|
contentPadding: EdgeInsets.zero,
|
||||||
content: BlocBuilder<FunctionBloc, FunctionBlocState>(
|
content: BlocBuilder<FunctionBloc, FunctionBlocState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final selectedFunction = state.selectedFunction;
|
final selectedFunction = state.selectedFunction;
|
||||||
final selectedOperationName = state.selectedOperationName;
|
final selectedOperationName = state.selectedOperationName;
|
||||||
final selectedFunctionData =
|
final selectedFunctionData = state.addedFunctions
|
||||||
state.addedFunctions.firstWhere((f) => f.functionCode == selectedFunction,
|
.firstWhere((f) => f.functionCode == selectedFunction,
|
||||||
orElse: () => DeviceFunctionData(
|
orElse: () => DeviceFunctionData(
|
||||||
entityId: '',
|
entityId: '',
|
||||||
functionCode: selectedFunction ?? '',
|
functionCode: selectedFunction ?? '',
|
||||||
@ -83,9 +85,12 @@ class ThreeGangSwitchHelper {
|
|||||||
color: ColorsManager.textGray,
|
color: ColorsManager.textGray,
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context.read<FunctionBloc>().add(SelectFunction(
|
context
|
||||||
|
.read<FunctionBloc>()
|
||||||
|
.add(SelectFunction(
|
||||||
functionCode: function.code,
|
functionCode: function.code,
|
||||||
operationName: function.operationName,
|
operationName:
|
||||||
|
function.operationName,
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -177,7 +182,8 @@ class ThreeGangSwitchHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final selectedFn = switchFunctions.firstWhere((f) => f.code == selectedFunction);
|
final selectedFn =
|
||||||
|
switchFunctions.firstWhere((f) => f.code == selectedFunction);
|
||||||
final values = selectedFn.getOperationalValues();
|
final values = selectedFn.getOperationalValues();
|
||||||
|
|
||||||
return _buildOperationalValuesList(
|
return _buildOperationalValuesList(
|
||||||
@ -214,11 +220,11 @@ class ThreeGangSwitchHelper {
|
|||||||
selectedFunctionData,
|
selectedFunctionData,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
_buildCountDownDisplay(
|
_buildCountDownDisplay(context, initialValue, device, operationName,
|
||||||
context, initialValue, device, operationName, selectedFunctionData, selectCode),
|
selectedFunctionData, selectCode),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
_buildCountDownSlider(
|
_buildCountDownSlider(context, initialValue, device, operationName,
|
||||||
context, initialValue, device, operationName, selectedFunctionData, selectCode),
|
selectedFunctionData, selectCode),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -259,7 +265,8 @@ class ThreeGangSwitchHelper {
|
|||||||
minHeight: 40.0,
|
minHeight: 40.0,
|
||||||
minWidth: 40.0,
|
minWidth: 40.0,
|
||||||
),
|
),
|
||||||
isSelected: conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
isSelected:
|
||||||
|
conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
||||||
children: conditions.map((c) => Text(c)).toList(),
|
children: conditions.map((c) => Text(c)).toList(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -307,7 +314,8 @@ class ThreeGangSwitchHelper {
|
|||||||
value: (initialValue ?? 0).toDouble(),
|
value: (initialValue ?? 0).toDouble(),
|
||||||
min: operationalValues.minValue?.toDouble() ?? 0.0,
|
min: operationalValues.minValue?.toDouble() ?? 0.0,
|
||||||
max: operationalValues.maxValue?.toDouble() ?? 0.0,
|
max: operationalValues.maxValue?.toDouble() ?? 0.0,
|
||||||
divisions: (((operationalValues.maxValue ?? 0) - (operationalValues.minValue ?? 0)) /
|
divisions: (((operationalValues.maxValue ?? 0) -
|
||||||
|
(operationalValues.minValue ?? 0)) /
|
||||||
(operationalValues.stepValue ?? 1))
|
(operationalValues.stepValue ?? 1))
|
||||||
.round(),
|
.round(),
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
@ -359,9 +367,13 @@ class ThreeGangSwitchHelper {
|
|||||||
style: context.textTheme.bodyMedium,
|
style: context.textTheme.bodyMedium,
|
||||||
),
|
),
|
||||||
trailing: Icon(
|
trailing: Icon(
|
||||||
isSelected ? Icons.radio_button_checked : Icons.radio_button_unchecked,
|
isSelected
|
||||||
|
? Icons.radio_button_checked
|
||||||
|
: Icons.radio_button_unchecked,
|
||||||
size: 24,
|
size: 24,
|
||||||
color: isSelected ? ColorsManager.primaryColorWithOpacity : ColorsManager.textGray,
|
color: isSelected
|
||||||
|
? ColorsManager.primaryColorWithOpacity
|
||||||
|
: ColorsManager.textGray,
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (!isSelected) {
|
if (!isSelected) {
|
||||||
@ -373,7 +385,8 @@ class ThreeGangSwitchHelper {
|
|||||||
operationName: operationName,
|
operationName: operationName,
|
||||||
value: value.value,
|
value: value.value,
|
||||||
condition: selectedFunctionData?.condition,
|
condition: selectedFunctionData?.condition,
|
||||||
valueDescription: selectedFunctionData?.valueDescription,
|
valueDescription:
|
||||||
|
selectedFunctionData?.valueDescription,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
@ -2,14 +2,14 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/functions_bloc/functions_bloc_bloc.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/functions_bloc/functions_bloc_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/helper/duration_format_helper.dart';
|
import 'package:syncrow_web/pages/routiens/helper/duration_format_helper.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
import 'package:syncrow_web/pages/routiens/models/device_functions.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/gang_switches/base_switch_function.dart';
|
import 'package:syncrow_web/pages/routiens/models/gang_switches/base_switch_function.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/gang_switches/switch_operational_value.dart';
|
import 'package:syncrow_web/pages/routiens/models/gang_switches/switch_operational_value.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/dialog_footer.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/dialog_footer.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/dialog_header.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/dialog_header.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
|
|
||||||
@ -22,21 +22,23 @@ class TwoGangSwitchHelper {
|
|||||||
String uniqueCustomId,
|
String uniqueCustomId,
|
||||||
bool removeComparetors,
|
bool removeComparetors,
|
||||||
) async {
|
) async {
|
||||||
List<BaseSwitchFunction> switchFunctions = functions.whereType<BaseSwitchFunction>().toList();
|
List<BaseSwitchFunction> switchFunctions =
|
||||||
|
functions.whereType<BaseSwitchFunction>().toList();
|
||||||
|
|
||||||
return showDialog<Map<String, dynamic>?>(
|
return showDialog<Map<String, dynamic>?>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (_) => FunctionBloc()..add(InitializeFunctions(deviceSelectedFunctions ?? [])),
|
create: (_) => FunctionBloc()
|
||||||
|
..add(InitializeFunctions(deviceSelectedFunctions ?? [])),
|
||||||
child: AlertDialog(
|
child: AlertDialog(
|
||||||
contentPadding: EdgeInsets.zero,
|
contentPadding: EdgeInsets.zero,
|
||||||
content: BlocBuilder<FunctionBloc, FunctionBlocState>(
|
content: BlocBuilder<FunctionBloc, FunctionBlocState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final selectedFunction = state.selectedFunction;
|
final selectedFunction = state.selectedFunction;
|
||||||
final selectedOperationName = state.selectedOperationName;
|
final selectedOperationName = state.selectedOperationName;
|
||||||
final selectedFunctionData =
|
final selectedFunctionData = state.addedFunctions
|
||||||
state.addedFunctions.firstWhere((f) => f.functionCode == selectedFunction,
|
.firstWhere((f) => f.functionCode == selectedFunction,
|
||||||
orElse: () => DeviceFunctionData(
|
orElse: () => DeviceFunctionData(
|
||||||
entityId: '',
|
entityId: '',
|
||||||
functionCode: selectedFunction ?? '',
|
functionCode: selectedFunction ?? '',
|
||||||
@ -83,9 +85,12 @@ class TwoGangSwitchHelper {
|
|||||||
color: ColorsManager.textGray,
|
color: ColorsManager.textGray,
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context.read<FunctionBloc>().add(SelectFunction(
|
context
|
||||||
|
.read<FunctionBloc>()
|
||||||
|
.add(SelectFunction(
|
||||||
functionCode: function.code,
|
functionCode: function.code,
|
||||||
operationName: function.operationName,
|
operationName:
|
||||||
|
function.operationName,
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -161,7 +166,8 @@ class TwoGangSwitchHelper {
|
|||||||
required String operationName,
|
required String operationName,
|
||||||
required bool removeComparetors,
|
required bool removeComparetors,
|
||||||
}) {
|
}) {
|
||||||
if (selectedFunction == 'countdown_1' || selectedFunction == 'countdown_2') {
|
if (selectedFunction == 'countdown_1' ||
|
||||||
|
selectedFunction == 'countdown_2') {
|
||||||
final initialValue = selectedFunctionData?.value ?? 200;
|
final initialValue = selectedFunctionData?.value ?? 200;
|
||||||
return _buildTemperatureSelector(
|
return _buildTemperatureSelector(
|
||||||
context: context,
|
context: context,
|
||||||
@ -175,7 +181,8 @@ class TwoGangSwitchHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final selectedFn = switchFunctions.firstWhere((f) => f.code == selectedFunction);
|
final selectedFn =
|
||||||
|
switchFunctions.firstWhere((f) => f.code == selectedFunction);
|
||||||
final values = selectedFn.getOperationalValues();
|
final values = selectedFn.getOperationalValues();
|
||||||
|
|
||||||
return _buildOperationalValuesList(
|
return _buildOperationalValuesList(
|
||||||
@ -212,11 +219,11 @@ class TwoGangSwitchHelper {
|
|||||||
selectedFunctionData,
|
selectedFunctionData,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
_buildCountDownDisplay(
|
_buildCountDownDisplay(context, initialValue, device, operationName,
|
||||||
context, initialValue, device, operationName, selectedFunctionData, selectCode),
|
selectedFunctionData, selectCode),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
_buildCountDownSlider(
|
_buildCountDownSlider(context, initialValue, device, operationName,
|
||||||
context, initialValue, device, operationName, selectedFunctionData, selectCode),
|
selectedFunctionData, selectCode),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -257,7 +264,8 @@ class TwoGangSwitchHelper {
|
|||||||
minHeight: 40.0,
|
minHeight: 40.0,
|
||||||
minWidth: 40.0,
|
minWidth: 40.0,
|
||||||
),
|
),
|
||||||
isSelected: conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
isSelected:
|
||||||
|
conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
||||||
children: conditions.map((c) => Text(c)).toList(),
|
children: conditions.map((c) => Text(c)).toList(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -305,7 +313,8 @@ class TwoGangSwitchHelper {
|
|||||||
value: (initialValue ?? 0).toDouble(),
|
value: (initialValue ?? 0).toDouble(),
|
||||||
min: operationalValues.minValue?.toDouble() ?? 0.0,
|
min: operationalValues.minValue?.toDouble() ?? 0.0,
|
||||||
max: operationalValues.maxValue?.toDouble() ?? 0.0,
|
max: operationalValues.maxValue?.toDouble() ?? 0.0,
|
||||||
divisions: (((operationalValues.maxValue ?? 0) - (operationalValues.minValue ?? 0)) /
|
divisions: (((operationalValues.maxValue ?? 0) -
|
||||||
|
(operationalValues.minValue ?? 0)) /
|
||||||
(operationalValues.stepValue ?? 1))
|
(operationalValues.stepValue ?? 1))
|
||||||
.round(),
|
.round(),
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
@ -357,9 +366,13 @@ class TwoGangSwitchHelper {
|
|||||||
style: context.textTheme.bodyMedium,
|
style: context.textTheme.bodyMedium,
|
||||||
),
|
),
|
||||||
trailing: Icon(
|
trailing: Icon(
|
||||||
isSelected ? Icons.radio_button_checked : Icons.radio_button_unchecked,
|
isSelected
|
||||||
|
? Icons.radio_button_checked
|
||||||
|
: Icons.radio_button_unchecked,
|
||||||
size: 24,
|
size: 24,
|
||||||
color: isSelected ? ColorsManager.primaryColorWithOpacity : ColorsManager.textGray,
|
color: isSelected
|
||||||
|
? ColorsManager.primaryColorWithOpacity
|
||||||
|
: ColorsManager.textGray,
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (!isSelected) {
|
if (!isSelected) {
|
||||||
@ -371,7 +384,8 @@ class TwoGangSwitchHelper {
|
|||||||
operationName: operationName,
|
operationName: operationName,
|
||||||
value: value.value,
|
value: value.value,
|
||||||
condition: selectedFunctionData?.condition,
|
condition: selectedFunctionData?.condition,
|
||||||
valueDescription: selectedFunctionData?.valueDescription,
|
valueDescription:
|
||||||
|
selectedFunctionData?.valueDescription,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
@ -1,10 +1,10 @@
|
|||||||
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:syncrow_web/pages/common/buttons/default_button.dart';
|
import 'package:syncrow_web/pages/common/buttons/default_button.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/helper/save_routine_helper.dart';
|
import 'package:syncrow_web/pages/routiens/helper/save_routine_helper.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/discard_dialog.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/routine_dialogs/discard_dialog.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/setting_dialog.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/routine_dialogs/setting_dialog.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
import 'package:syncrow_web/utils/style.dart';
|
import 'package:syncrow_web/utils/style.dart';
|
@ -1,8 +1,7 @@
|
|||||||
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:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/dragable_card.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/dragable_card.dart';
|
||||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
|
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
|
|
||||||
class ScenesAndAutomations extends StatefulWidget {
|
class ScenesAndAutomations extends StatefulWidget {
|
||||||
@ -19,9 +18,8 @@ class _ScenesAndAutomationsState extends State<ScenesAndAutomations> {
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
context.read<RoutineBloc>()
|
context.read<RoutineBloc>()
|
||||||
..add(LoadScenes(context.read<SpaceTreeBloc>().selectedSpaceId,
|
..add(const LoadScenes(spaceId, communityId))
|
||||||
context.read<SpaceTreeBloc>().selectedCommunityId))
|
..add(const LoadAutomation(spaceId));
|
||||||
..add(LoadAutomation(context.read<SpaceTreeBloc>().selectedSpaceId));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -36,7 +34,9 @@ class _ScenesAndAutomationsState extends State<ScenesAndAutomations> {
|
|||||||
children: scenes.asMap().entries.map((entry) {
|
children: scenes.asMap().entries.map((entry) {
|
||||||
final scene = entry.value;
|
final scene = entry.value;
|
||||||
if (state.searchText != null && state.searchText!.isNotEmpty) {
|
if (state.searchText != null && state.searchText!.isNotEmpty) {
|
||||||
return scene.name.toLowerCase().contains(state.searchText!.toLowerCase())
|
return scene.name
|
||||||
|
.toLowerCase()
|
||||||
|
.contains(state.searchText!.toLowerCase())
|
||||||
? DraggableCard(
|
? DraggableCard(
|
||||||
imagePath: scene.icon ?? Assets.loginLogo,
|
imagePath: scene.icon ?? Assets.loginLogo,
|
||||||
title: scene.name,
|
title: scene.name,
|
@ -1,8 +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:syncrow_web/pages/common/text_field/custom_text_field.dart';
|
import 'package:syncrow_web/pages/common/text_field/custom_text_field.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routines_title_widget.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/routines_title_widget.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
||||||
|
|
@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
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:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/automation_dialog.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/routine_dialogs/automation_dialog.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/delay_dialog.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/routine_dialogs/delay_dialog.dart';
|
||||||
import 'package:syncrow_web/pages/routines/helper/dialog_helper/device_dialog_helper.dart';
|
import 'package:syncrow_web/pages/routiens/helper/dialog_helper/device_dialog_helper.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/dragable_card.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/dragable_card.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
import 'package:uuid/uuid.dart';
|
import 'package:uuid/uuid.dart';
|
||||||
|
|
@ -1,62 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/ac_dialog.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/one_gang_switch_dialog.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/three_gang_switch_dialog.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/two_gang_switch_dialog.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
|
||||||
|
|
||||||
class DeviceDialogHelper {
|
|
||||||
static Future<Map<String, dynamic>?> showDeviceDialog(
|
|
||||||
BuildContext context,
|
|
||||||
Map<String, dynamic> data, {
|
|
||||||
required bool removeComparetors,
|
|
||||||
}) async {
|
|
||||||
final functions = data['functions'] as List<DeviceFunction>;
|
|
||||||
|
|
||||||
try {
|
|
||||||
final result = await _getDialogForDeviceType(
|
|
||||||
context,
|
|
||||||
data['productType'],
|
|
||||||
data,
|
|
||||||
functions,
|
|
||||||
removeComparetors: removeComparetors,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (result != null) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
debugPrint('Error: $e');
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Future<Map<String, dynamic>?> _getDialogForDeviceType(BuildContext context,
|
|
||||||
String productType, Map<String, dynamic> data, List<DeviceFunction> functions,
|
|
||||||
{required bool removeComparetors}) async {
|
|
||||||
final routineBloc = context.read<RoutineBloc>();
|
|
||||||
final deviceSelectedFunctions =
|
|
||||||
routineBloc.state.selectedFunctions[data['uniqueCustomId']] ?? [];
|
|
||||||
|
|
||||||
switch (productType) {
|
|
||||||
case 'AC':
|
|
||||||
return ACHelper.showACFunctionsDialog(context, functions, data['device'],
|
|
||||||
deviceSelectedFunctions, data['uniqueCustomId'], removeComparetors);
|
|
||||||
|
|
||||||
case '1G':
|
|
||||||
return OneGangSwitchHelper.showSwitchFunctionsDialog(context, functions, data['device'],
|
|
||||||
deviceSelectedFunctions, data['uniqueCustomId'], removeComparetors);
|
|
||||||
case '2G':
|
|
||||||
return TwoGangSwitchHelper.showSwitchFunctionsDialog(context, functions, data['device'],
|
|
||||||
deviceSelectedFunctions, data['uniqueCustomId'], removeComparetors);
|
|
||||||
case '3G':
|
|
||||||
return ThreeGangSwitchHelper.showSwitchFunctionsDialog(context, functions, data['device'],
|
|
||||||
deviceSelectedFunctions, data['uniqueCustomId'], removeComparetors);
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,98 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/view/create_new_routine_view.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/widgets/main_routine_view/fetch_routine_scenes_automation.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/widgets/main_routine_view/routine_view_card.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_tree/view/space_tree_view.dart';
|
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
|
||||||
import 'package:syncrow_web/utils/snack_bar.dart';
|
|
||||||
|
|
||||||
class RoutinesView extends StatefulWidget {
|
|
||||||
const RoutinesView({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<RoutinesView> createState() => _RoutinesViewState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _RoutinesViewState extends State<RoutinesView> {
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
context.read<RoutineBloc>().add(FetchDevicesInRoutine());
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return BlocBuilder<RoutineBloc, RoutineState>(
|
|
||||||
builder: (context, state) {
|
|
||||||
if (state.createRoutineView) {
|
|
||||||
return const CreateNewRoutineView();
|
|
||||||
}
|
|
||||||
return Row(
|
|
||||||
children: [
|
|
||||||
const Expanded(
|
|
||||||
child:
|
|
||||||
// SideSpacesView(
|
|
||||||
// onSelectAction: (String communityId, String spaceId) {
|
|
||||||
// // context.read<RoutineBloc>()
|
|
||||||
// // ..add(LoadScenes(spaceId, communityId))
|
|
||||||
// // ..add(LoadAutomation(spaceId));
|
|
||||||
// },
|
|
||||||
// )
|
|
||||||
SpaceTreeView()),
|
|
||||||
Expanded(
|
|
||||||
flex: 3,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(16),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
"Create New Routines",
|
|
||||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
|
||||||
color: ColorsManager.grayColor,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 10,
|
|
||||||
),
|
|
||||||
RoutineViewCard(
|
|
||||||
onTap: () {
|
|
||||||
if (context.read<SpaceTreeBloc>().selectedCommunityId.isNotEmpty &&
|
|
||||||
context.read<SpaceTreeBloc>().selectedSpaceId.isNotEmpty) {
|
|
||||||
context.read<RoutineBloc>().add(
|
|
||||||
(ResetRoutineState()),
|
|
||||||
);
|
|
||||||
BlocProvider.of<RoutineBloc>(context).add(
|
|
||||||
const CreateNewRoutineViewEvent(createRoutineView: true),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
CustomSnackBar.redSnackBar('Please select a space');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
icon: Icons.add,
|
|
||||||
textString: '',
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 15,
|
|
||||||
),
|
|
||||||
const Expanded(child: FetchRoutineScenesAutomation()),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,143 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/widgets/main_routine_view/routine_view_card.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
|
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
|
||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
|
||||||
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
|
||||||
|
|
||||||
class FetchRoutineScenesAutomation extends StatefulWidget {
|
|
||||||
const FetchRoutineScenesAutomation({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<FetchRoutineScenesAutomation> createState() => _FetchRoutineScenesState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
|
|
||||||
with HelperResponsiveLayout {
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
context.read<RoutineBloc>()
|
|
||||||
..add(LoadScenes(context.read<SpaceTreeBloc>().selectedSpaceId,
|
|
||||||
context.read<SpaceTreeBloc>().selectedCommunityId))
|
|
||||||
..add(LoadAutomation(context.read<SpaceTreeBloc>().selectedSpaceId));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return BlocBuilder<RoutineBloc, RoutineState>(
|
|
||||||
builder: (context, state) {
|
|
||||||
return state.isLoading
|
|
||||||
? const Center(
|
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
)
|
|
||||||
: Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
"Scenes (Tab to Run)",
|
|
||||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
|
||||||
color: ColorsManager.grayColor,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
if (state.scenes.isEmpty)
|
|
||||||
Text(
|
|
||||||
"No scenes found",
|
|
||||||
style: context.textTheme.bodyMedium?.copyWith(
|
|
||||||
color: ColorsManager.grayColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (state.scenes.isNotEmpty)
|
|
||||||
ConstrainedBox(
|
|
||||||
constraints: BoxConstraints(
|
|
||||||
maxHeight: isSmallScreenSize(context) ? 160 : 170,
|
|
||||||
maxWidth: MediaQuery.sizeOf(context).width * 0.7),
|
|
||||||
child: ListView.builder(
|
|
||||||
scrollDirection: Axis.horizontal,
|
|
||||||
itemCount: state.scenes.length,
|
|
||||||
itemBuilder: (context, index) => Padding(
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
right: isSmallScreenSize(context) ? 4.0 : 8.0,
|
|
||||||
),
|
|
||||||
child: RoutineViewCard(
|
|
||||||
onTap: () {
|
|
||||||
BlocProvider.of<RoutineBloc>(context).add(
|
|
||||||
const CreateNewRoutineViewEvent(createRoutineView: true),
|
|
||||||
);
|
|
||||||
context.read<RoutineBloc>().add(
|
|
||||||
GetSceneDetails(
|
|
||||||
sceneId: state.scenes[index].id,
|
|
||||||
isTabToRun: true,
|
|
||||||
isUpdate: true,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
textString: state.scenes[index].name,
|
|
||||||
icon: state.scenes[index].icon ?? Assets.logoHorizontal,
|
|
||||||
isFromScenes: true,
|
|
||||||
iconInBytes: state.scenes[index].iconInBytes,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 15),
|
|
||||||
Text(
|
|
||||||
"Automations",
|
|
||||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
|
||||||
color: ColorsManager.grayColor,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
if (state.automations.isEmpty)
|
|
||||||
Text(
|
|
||||||
"No automations found",
|
|
||||||
style: context.textTheme.bodyMedium?.copyWith(
|
|
||||||
color: ColorsManager.grayColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (state.automations.isNotEmpty)
|
|
||||||
ConstrainedBox(
|
|
||||||
constraints: BoxConstraints(
|
|
||||||
maxHeight: isSmallScreenSize(context) ? 160 : 170,
|
|
||||||
maxWidth: MediaQuery.sizeOf(context).width * 0.7),
|
|
||||||
child: ListView.builder(
|
|
||||||
scrollDirection: Axis.horizontal,
|
|
||||||
itemCount: state.automations.length,
|
|
||||||
itemBuilder: (context, index) => Padding(
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
right: isSmallScreenSize(context) ? 4.0 : 8.0,
|
|
||||||
),
|
|
||||||
child: RoutineViewCard(
|
|
||||||
onTap: () {
|
|
||||||
BlocProvider.of<RoutineBloc>(context).add(
|
|
||||||
const CreateNewRoutineViewEvent(createRoutineView: true),
|
|
||||||
);
|
|
||||||
context.read<RoutineBloc>().add(
|
|
||||||
GetAutomationDetails(
|
|
||||||
automationId: state.automations[index].id,
|
|
||||||
isAutomation: true,
|
|
||||||
isUpdate: true),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
textString: state.automations[index].name,
|
|
||||||
icon: state.automations[index].icon ?? Assets.automation,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,283 +0,0 @@
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_event.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_state.dart';
|
|
||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
|
|
||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
|
|
||||||
import 'package:syncrow_web/services/space_mana_api.dart';
|
|
||||||
|
|
||||||
class SpaceTreeBloc extends Bloc<SpaceTreeEvent, SpaceTreeState> {
|
|
||||||
String selectedCommunityId = '';
|
|
||||||
String selectedSpaceId = '';
|
|
||||||
|
|
||||||
SpaceTreeBloc() : super(const SpaceTreeState()) {
|
|
||||||
on<InitialEvent>(_fetchSpaces);
|
|
||||||
on<OnCommunityExpanded>(_onCommunityExpanded);
|
|
||||||
on<OnSpaceExpanded>(_onSpaceExpanded);
|
|
||||||
on<OnCommunitySelected>(_onCommunitySelected);
|
|
||||||
on<OnSpaceSelected>(_onSpaceSelected);
|
|
||||||
on<SearchQueryEvent>(_onSearch);
|
|
||||||
}
|
|
||||||
|
|
||||||
_fetchSpaces(InitialEvent event, Emitter<SpaceTreeState> emit) async {
|
|
||||||
emit(SpaceTreeLoadingState());
|
|
||||||
try {
|
|
||||||
List<CommunityModel> communities = await CommunitySpaceManagementApi().fetchCommunities();
|
|
||||||
|
|
||||||
List<CommunityModel> updatedCommunities = await Future.wait(
|
|
||||||
communities.map((community) async {
|
|
||||||
List<SpaceModel> spaces =
|
|
||||||
await CommunitySpaceManagementApi().getSpaceHierarchy(community.uuid);
|
|
||||||
|
|
||||||
return CommunityModel(
|
|
||||||
uuid: community.uuid,
|
|
||||||
createdAt: community.createdAt,
|
|
||||||
updatedAt: community.updatedAt,
|
|
||||||
name: community.name,
|
|
||||||
description: community.description,
|
|
||||||
spaces: spaces,
|
|
||||||
region: community.region,
|
|
||||||
);
|
|
||||||
}).toList(),
|
|
||||||
);
|
|
||||||
|
|
||||||
emit(state.copyWith(
|
|
||||||
communitiesList: updatedCommunities, expandedCommunity: [], expandedSpaces: []));
|
|
||||||
} catch (e) {
|
|
||||||
emit(SpaceTreeErrorState('Error loading communities and spaces: $e'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_onCommunityExpanded(OnCommunityExpanded event, Emitter<SpaceTreeState> emit) async {
|
|
||||||
try {
|
|
||||||
List<String> updatedExpandedCommunityList = List.from(state.expandedCommunities);
|
|
||||||
|
|
||||||
if (updatedExpandedCommunityList.contains(event.communityId)) {
|
|
||||||
updatedExpandedCommunityList.remove(event.communityId);
|
|
||||||
} else {
|
|
||||||
updatedExpandedCommunityList.add(event.communityId);
|
|
||||||
}
|
|
||||||
|
|
||||||
emit(state.copyWith(
|
|
||||||
expandedCommunity: updatedExpandedCommunityList,
|
|
||||||
));
|
|
||||||
} catch (e) {
|
|
||||||
emit(const SpaceTreeErrorState('Something went wrong'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_onSpaceExpanded(OnSpaceExpanded event, Emitter<SpaceTreeState> emit) async {
|
|
||||||
try {
|
|
||||||
List<String> updatedExpandedSpacesList = List.from(state.expandedSpaces);
|
|
||||||
|
|
||||||
if (updatedExpandedSpacesList.contains(event.spaceId)) {
|
|
||||||
updatedExpandedSpacesList.remove(event.spaceId);
|
|
||||||
} else {
|
|
||||||
updatedExpandedSpacesList.add(event.spaceId);
|
|
||||||
}
|
|
||||||
|
|
||||||
emit(state.copyWith(expandedSpaces: updatedExpandedSpacesList));
|
|
||||||
} catch (e) {
|
|
||||||
emit(const SpaceTreeErrorState('Something went wrong'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_onCommunitySelected(OnCommunitySelected event, Emitter<SpaceTreeState> emit) async {
|
|
||||||
try {
|
|
||||||
List<String> updatedSelectedCommunities =
|
|
||||||
List.from(state.selectedCommunities.toSet().toList());
|
|
||||||
List<String> updatedSelectedSpaces = List.from(state.selectedSpaces.toSet().toList());
|
|
||||||
List<String> updatedSoldChecks = List.from(state.soldCheck.toSet().toList());
|
|
||||||
|
|
||||||
List<String> childrenIds = _getAllChildIds(event.children);
|
|
||||||
|
|
||||||
if (!updatedSelectedCommunities.contains(event.communityId)) {
|
|
||||||
// Select the community and all its children
|
|
||||||
updatedSelectedCommunities.add(event.communityId);
|
|
||||||
updatedSelectedSpaces.addAll(childrenIds);
|
|
||||||
} else {
|
|
||||||
// Unselect the community and all its children
|
|
||||||
updatedSelectedCommunities.remove(event.communityId);
|
|
||||||
updatedSelectedSpaces.removeWhere(childrenIds.contains);
|
|
||||||
updatedSoldChecks.removeWhere(childrenIds.contains);
|
|
||||||
}
|
|
||||||
|
|
||||||
emit(state.copyWith(
|
|
||||||
selectedCommunities: updatedSelectedCommunities,
|
|
||||||
selectedSpaces: updatedSelectedSpaces,
|
|
||||||
soldCheck: updatedSoldChecks));
|
|
||||||
} catch (e) {
|
|
||||||
emit(const SpaceTreeErrorState('Something went wrong'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_onSpaceSelected(OnSpaceSelected event, Emitter<SpaceTreeState> emit) async {
|
|
||||||
try {
|
|
||||||
List<String> updatedSelectedCommunities =
|
|
||||||
List.from(state.selectedCommunities.toSet().toList());
|
|
||||||
List<String> updatedSelectedSpaces = List.from(state.selectedSpaces.toSet().toList());
|
|
||||||
List<String> updatedSoldChecks = List.from(state.soldCheck.toSet().toList());
|
|
||||||
|
|
||||||
List<String> childrenIds = _getAllChildIds(event.children);
|
|
||||||
bool isChildSelected = false;
|
|
||||||
|
|
||||||
for (String id in childrenIds) {
|
|
||||||
if (updatedSelectedSpaces.contains(id)) {
|
|
||||||
isChildSelected = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!updatedSelectedSpaces.contains(event.spaceId) &&
|
|
||||||
!updatedSoldChecks.contains(event.spaceId)) {
|
|
||||||
// First click: Select the space and all its children
|
|
||||||
updatedSelectedSpaces.add(event.spaceId);
|
|
||||||
updatedSelectedCommunities.add(event.communityId);
|
|
||||||
if (childrenIds.isNotEmpty) {
|
|
||||||
updatedSelectedSpaces.addAll(childrenIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> spaces = _getThePathToChild(event.communityId, event.spaceId);
|
|
||||||
for (String space in spaces) {
|
|
||||||
if (!updatedSelectedSpaces.contains(space) && !updatedSoldChecks.contains(space)) {
|
|
||||||
updatedSoldChecks.add(space);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (!updatedSoldChecks.contains(event.spaceId) &&
|
|
||||||
childrenIds.isNotEmpty &&
|
|
||||||
isChildSelected) {
|
|
||||||
// Second click: Unselect space but keep children
|
|
||||||
updatedSelectedSpaces.remove(event.spaceId);
|
|
||||||
updatedSoldChecks.add(event.spaceId);
|
|
||||||
} else {
|
|
||||||
// Third click: Unselect space and all its children
|
|
||||||
updatedSelectedSpaces.remove(event.spaceId);
|
|
||||||
if (childrenIds.isNotEmpty) {
|
|
||||||
updatedSelectedSpaces.removeWhere(childrenIds.contains);
|
|
||||||
updatedSoldChecks.removeWhere(childrenIds.contains);
|
|
||||||
}
|
|
||||||
updatedSoldChecks.remove(event.spaceId);
|
|
||||||
|
|
||||||
List<String> parents = _getThePathToChild(event.communityId, event.spaceId);
|
|
||||||
if (!_parentSelected(parents, updatedSelectedSpaces)) {
|
|
||||||
updatedSoldChecks.removeWhere(parents.contains);
|
|
||||||
}
|
|
||||||
if (!_anySpacesSelectedInCommunity(
|
|
||||||
event.communityId, updatedSelectedSpaces, updatedSoldChecks)) {
|
|
||||||
updatedSelectedCommunities.remove(event.communityId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
emit(state.copyWith(
|
|
||||||
selectedCommunities: updatedSelectedCommunities,
|
|
||||||
selectedSpaces: updatedSelectedSpaces,
|
|
||||||
soldCheck: updatedSoldChecks));
|
|
||||||
emit(state.copyWith(selectedSpaces: updatedSelectedSpaces));
|
|
||||||
} catch (e) {
|
|
||||||
emit(const SpaceTreeErrorState('Something went wrong'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_parentSelected(List<String> parents, List<String> selectedSpaces) {
|
|
||||||
for (String space in parents) {
|
|
||||||
if (selectedSpaces.contains(space)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
_onSearch(SearchQueryEvent event, Emitter<SpaceTreeState> emit) async {
|
|
||||||
try {
|
|
||||||
List<CommunityModel> communities = List.from(state.communityList);
|
|
||||||
List<CommunityModel> filteredCommunity = [];
|
|
||||||
|
|
||||||
// Filter communities and expand only those that match the query
|
|
||||||
filteredCommunity = communities.where((community) {
|
|
||||||
final containsQueryInCommunity =
|
|
||||||
community.name.toLowerCase().contains(event.searchQuery.toLowerCase());
|
|
||||||
final containsQueryInSpaces =
|
|
||||||
community.spaces.any((space) => _containsQuery(space, event.searchQuery.toLowerCase()));
|
|
||||||
|
|
||||||
return containsQueryInCommunity || containsQueryInSpaces;
|
|
||||||
}).toList();
|
|
||||||
|
|
||||||
emit(state.copyWith(
|
|
||||||
filteredCommunity: filteredCommunity, isSearching: event.searchQuery.isNotEmpty));
|
|
||||||
} catch (e) {
|
|
||||||
emit(const SpaceTreeErrorState('Something went wrong'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Helper function to determine if any space or its children match the search query
|
|
||||||
bool _containsQuery(SpaceModel space, String query) {
|
|
||||||
final matchesSpace = space.name.toLowerCase().contains(query);
|
|
||||||
final matchesChildren =
|
|
||||||
space.children.any((child) => _containsQuery(child, query)); // Recursive check for children
|
|
||||||
|
|
||||||
return matchesSpace || matchesChildren;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> _getAllChildIds(List<SpaceModel> spaces) {
|
|
||||||
List<String> ids = [];
|
|
||||||
for (var child in spaces) {
|
|
||||||
ids.add(child.uuid!);
|
|
||||||
ids.addAll(_getAllChildIds(child.children));
|
|
||||||
}
|
|
||||||
return ids;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool _anySpacesSelectedInCommunity(
|
|
||||||
String communityId, List<String> selectedSpaces, List<String> partialCheckedList) {
|
|
||||||
bool result = false;
|
|
||||||
for (var community in state.communityList) {
|
|
||||||
if (community.uuid == communityId) {
|
|
||||||
List<String> ids = _getAllChildIds(community.spaces);
|
|
||||||
for (var id in ids) {
|
|
||||||
result = selectedSpaces.contains(id) || partialCheckedList.contains(id);
|
|
||||||
if (result) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> _getThePathToChild(String communityId, String selectedSpaceId) {
|
|
||||||
List<String> ids = [];
|
|
||||||
for (var community in state.communityList) {
|
|
||||||
if (community.uuid == communityId) {
|
|
||||||
for (var space in community.spaces) {
|
|
||||||
List<String> list = [];
|
|
||||||
list.add(space.uuid!);
|
|
||||||
ids = _getAllParentsIds(space, selectedSpaceId, List.from(list));
|
|
||||||
if (ids.isNotEmpty) {
|
|
||||||
return ids;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ids;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> _getAllParentsIds(SpaceModel child, String spaceId, List<String> listIds) {
|
|
||||||
List<String> ids = listIds;
|
|
||||||
|
|
||||||
ids.add(child.uuid ?? '');
|
|
||||||
|
|
||||||
if (child.uuid == spaceId) {
|
|
||||||
return ids;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (child.children.isNotEmpty) {
|
|
||||||
for (var space in child.children) {
|
|
||||||
var result = _getAllParentsIds(space, spaceId, List.from(ids));
|
|
||||||
if (result.isNotEmpty) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ids.removeLast();
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,69 +0,0 @@
|
|||||||
import 'package:equatable/equatable.dart';
|
|
||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
|
|
||||||
|
|
||||||
class SpaceTreeEvent extends Equatable {
|
|
||||||
const SpaceTreeEvent();
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object> get props => [];
|
|
||||||
}
|
|
||||||
|
|
||||||
class InitialEvent extends SpaceTreeEvent {}
|
|
||||||
|
|
||||||
class SearchForSpace extends SpaceTreeEvent {
|
|
||||||
final String searchQuery;
|
|
||||||
|
|
||||||
const SearchForSpace(this.searchQuery);
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object> get props => [searchQuery];
|
|
||||||
}
|
|
||||||
|
|
||||||
class OnCommunityExpanded extends SpaceTreeEvent {
|
|
||||||
final String communityId;
|
|
||||||
|
|
||||||
const OnCommunityExpanded(this.communityId);
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object> get props => [communityId];
|
|
||||||
}
|
|
||||||
|
|
||||||
class OnCommunitySelected extends SpaceTreeEvent {
|
|
||||||
final String communityId;
|
|
||||||
final List<SpaceModel> children;
|
|
||||||
|
|
||||||
const OnCommunitySelected(this.communityId, this.children);
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object> get props => [communityId, children];
|
|
||||||
}
|
|
||||||
|
|
||||||
class OnSpaceExpanded extends SpaceTreeEvent {
|
|
||||||
final String communityId;
|
|
||||||
final String spaceId;
|
|
||||||
|
|
||||||
const OnSpaceExpanded(this.communityId, this.spaceId);
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object> get props => [communityId, spaceId];
|
|
||||||
}
|
|
||||||
|
|
||||||
class OnSpaceSelected extends SpaceTreeEvent {
|
|
||||||
final String communityId;
|
|
||||||
final String spaceId;
|
|
||||||
final List<SpaceModel> children;
|
|
||||||
|
|
||||||
const OnSpaceSelected(this.communityId, this.spaceId, this.children);
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object> get props => [communityId, spaceId, children];
|
|
||||||
}
|
|
||||||
|
|
||||||
class SearchQueryEvent extends SpaceTreeEvent {
|
|
||||||
final String searchQuery;
|
|
||||||
|
|
||||||
const SearchQueryEvent(this.searchQuery);
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object> get props => [searchQuery];
|
|
||||||
}
|
|
@ -1,65 +0,0 @@
|
|||||||
import 'package:equatable/equatable.dart';
|
|
||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
|
|
||||||
|
|
||||||
class SpaceTreeState extends Equatable {
|
|
||||||
final List<CommunityModel> communityList;
|
|
||||||
final List<CommunityModel> filteredCommunity;
|
|
||||||
final List<String> expandedCommunities;
|
|
||||||
final List<String> expandedSpaces;
|
|
||||||
final List<String> selectedCommunities;
|
|
||||||
final List<String> selectedSpaces;
|
|
||||||
final List<String> soldCheck;
|
|
||||||
final bool isSearching;
|
|
||||||
|
|
||||||
const SpaceTreeState(
|
|
||||||
{this.communityList = const [],
|
|
||||||
this.filteredCommunity = const [],
|
|
||||||
this.expandedCommunities = const [],
|
|
||||||
this.expandedSpaces = const [],
|
|
||||||
this.selectedCommunities = const [],
|
|
||||||
this.selectedSpaces = const [],
|
|
||||||
this.soldCheck = const [],
|
|
||||||
this.isSearching = false});
|
|
||||||
|
|
||||||
SpaceTreeState copyWith(
|
|
||||||
{List<CommunityModel>? communitiesList,
|
|
||||||
List<CommunityModel>? filteredCommunity,
|
|
||||||
List<String>? expandedSpaces,
|
|
||||||
List<String>? expandedCommunity,
|
|
||||||
List<String>? selectedCommunities,
|
|
||||||
List<String>? selectedSpaces,
|
|
||||||
List<String>? soldCheck,
|
|
||||||
bool? isSearching}) {
|
|
||||||
return SpaceTreeState(
|
|
||||||
communityList: communitiesList ?? this.communityList,
|
|
||||||
filteredCommunity: filteredCommunity ?? this.filteredCommunity,
|
|
||||||
expandedSpaces: expandedSpaces ?? this.expandedSpaces,
|
|
||||||
expandedCommunities: expandedCommunity ?? this.expandedCommunities,
|
|
||||||
selectedCommunities: selectedCommunities ?? this.selectedCommunities,
|
|
||||||
selectedSpaces: selectedSpaces ?? this.selectedSpaces,
|
|
||||||
soldCheck: soldCheck ?? this.soldCheck,
|
|
||||||
isSearching: isSearching ?? this.isSearching);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object?> get props => [
|
|
||||||
communityList,
|
|
||||||
filteredCommunity,
|
|
||||||
expandedSpaces,
|
|
||||||
expandedCommunities,
|
|
||||||
selectedCommunities,
|
|
||||||
selectedSpaces,
|
|
||||||
soldCheck,
|
|
||||||
isSearching
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
class SpaceTreeLoadingState extends SpaceTreeState {}
|
|
||||||
|
|
||||||
class SpaceTreeErrorState extends SpaceTreeState {
|
|
||||||
final String message;
|
|
||||||
const SpaceTreeErrorState(this.message);
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object?> get props => [message];
|
|
||||||
}
|
|
@ -1,99 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
|
||||||
|
|
||||||
class CustomExpansionTileSpaceTree extends StatelessWidget {
|
|
||||||
final String? spaceId;
|
|
||||||
final String title;
|
|
||||||
final List<Widget>? children;
|
|
||||||
final bool isSelected;
|
|
||||||
final bool isSoldCheck;
|
|
||||||
final bool isExpanded;
|
|
||||||
final Function? onExpansionChanged;
|
|
||||||
final Function? onItemSelected;
|
|
||||||
|
|
||||||
const CustomExpansionTileSpaceTree(
|
|
||||||
{super.key,
|
|
||||||
this.spaceId,
|
|
||||||
required this.title,
|
|
||||||
this.children,
|
|
||||||
this.isExpanded = false,
|
|
||||||
this.onExpansionChanged,
|
|
||||||
this.onItemSelected,
|
|
||||||
required this.isSelected,
|
|
||||||
this.isSoldCheck = false});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Column(
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Checkbox(
|
|
||||||
value: isSoldCheck ? null : isSelected,
|
|
||||||
onChanged: (bool? value) {
|
|
||||||
if (onItemSelected != null) {
|
|
||||||
onItemSelected!();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
tristate: true,
|
|
||||||
side: WidgetStateBorderSide.resolveWith((states) {
|
|
||||||
return const BorderSide(color: ColorsManager.grayBorder);
|
|
||||||
}),
|
|
||||||
fillColor: WidgetStateProperty.resolveWith((states) {
|
|
||||||
if (states.contains(WidgetState.selected)) {
|
|
||||||
return ColorsManager.blue1;
|
|
||||||
} else {
|
|
||||||
return ColorsManager.checkBoxFillColor;
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
checkColor: ColorsManager.whiteColors,
|
|
||||||
),
|
|
||||||
if (children != null && children!.isNotEmpty)
|
|
||||||
InkWell(
|
|
||||||
onTap: () {
|
|
||||||
if (onExpansionChanged != null) {
|
|
||||||
onExpansionChanged!();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: Icon(
|
|
||||||
isExpanded ? Icons.keyboard_arrow_down : Icons.keyboard_arrow_right,
|
|
||||||
color: ColorsManager.lightGrayColor,
|
|
||||||
size: 16.0,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: GestureDetector(
|
|
||||||
onTap: () {
|
|
||||||
if (onItemSelected != null) {
|
|
||||||
onItemSelected!();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: Text(
|
|
||||||
_capitalizeFirstLetter(title),
|
|
||||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
|
||||||
color: isSelected
|
|
||||||
? ColorsManager.blackColor // Change color to black when selected
|
|
||||||
: ColorsManager.lightGrayColor, // Gray when not selected
|
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
if (isExpanded && children != null && children!.isNotEmpty)
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 48.0),
|
|
||||||
child: Column(
|
|
||||||
children: children ?? [],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
String _capitalizeFirstLetter(String text) {
|
|
||||||
if (text.isEmpty) return text;
|
|
||||||
return text[0].toUpperCase() + text.substring(1);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
import 'package:syncrow_web/common/widgets/search_bar.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_event.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_state.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_tree/view/custom_expansion.dart';
|
|
||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
|
|
||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
|
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
|
||||||
import 'package:syncrow_web/utils/style.dart';
|
|
||||||
|
|
||||||
class SpaceTreeView extends StatelessWidget {
|
|
||||||
const SpaceTreeView({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return BlocBuilder<SpaceTreeBloc, SpaceTreeState>(builder: (context, state) {
|
|
||||||
List<CommunityModel> list = state.isSearching ? state.filteredCommunity : state.communityList;
|
|
||||||
return Container(
|
|
||||||
height: MediaQuery.sizeOf(context).height,
|
|
||||||
decoration: subSectionContainerDecoration,
|
|
||||||
// padding: const EdgeInsets.all(16.0),
|
|
||||||
child: state is SpaceTreeLoadingState
|
|
||||||
? const Center(child: CircularProgressIndicator())
|
|
||||||
: Column(
|
|
||||||
children: [
|
|
||||||
CustomSearchBar(
|
|
||||||
onSearchChanged: (query) {
|
|
||||||
context.read<SpaceTreeBloc>().add(SearchQueryEvent(query));
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
Expanded(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: list.isEmpty
|
|
||||||
? Center(
|
|
||||||
child: Text(
|
|
||||||
'No results found',
|
|
||||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
|
||||||
color: ColorsManager.lightGrayColor, // Gray when not selected
|
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: ListView(
|
|
||||||
shrinkWrap: true,
|
|
||||||
children: list
|
|
||||||
.map(
|
|
||||||
(community) => CustomExpansionTileSpaceTree(
|
|
||||||
title: community.name,
|
|
||||||
isSelected:
|
|
||||||
state.selectedCommunities.contains(community.uuid),
|
|
||||||
isSoldCheck:
|
|
||||||
state.selectedCommunities.contains(community.uuid),
|
|
||||||
onExpansionChanged: () {
|
|
||||||
context
|
|
||||||
.read<SpaceTreeBloc>()
|
|
||||||
.add(OnCommunityExpanded(community.uuid));
|
|
||||||
},
|
|
||||||
isExpanded:
|
|
||||||
state.expandedCommunities.contains(community.uuid),
|
|
||||||
onItemSelected: () {
|
|
||||||
context.read<SpaceTreeBloc>().add(
|
|
||||||
OnCommunitySelected(community.uuid, community.spaces));
|
|
||||||
},
|
|
||||||
children: community.spaces.map((space) {
|
|
||||||
return CustomExpansionTileSpaceTree(
|
|
||||||
title: space.name,
|
|
||||||
isExpanded: state.expandedSpaces.contains(space.uuid),
|
|
||||||
onItemSelected: () {
|
|
||||||
context.read<SpaceTreeBloc>().add(OnSpaceSelected(
|
|
||||||
community.uuid, space.uuid ?? '', space.children));
|
|
||||||
},
|
|
||||||
onExpansionChanged: () {
|
|
||||||
context.read<SpaceTreeBloc>().add(
|
|
||||||
OnSpaceExpanded(community.uuid, space.uuid ?? ''));
|
|
||||||
},
|
|
||||||
isSelected: state.selectedSpaces.contains(space.uuid) ||
|
|
||||||
state.soldCheck.contains(space.uuid),
|
|
||||||
isSoldCheck: state.soldCheck.contains(space.uuid),
|
|
||||||
children: _buildNestedSpaces(
|
|
||||||
context, state, space, community.uuid),
|
|
||||||
);
|
|
||||||
}).toList(),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.toList(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Widget> _buildNestedSpaces(
|
|
||||||
BuildContext context, SpaceTreeState state, SpaceModel space, String communityId) {
|
|
||||||
return space.children.map((child) {
|
|
||||||
return CustomExpansionTileSpaceTree(
|
|
||||||
isSelected:
|
|
||||||
state.selectedSpaces.contains(child.uuid) || state.soldCheck.contains(child.uuid),
|
|
||||||
isSoldCheck: state.soldCheck.contains(child.uuid),
|
|
||||||
title: child.name,
|
|
||||||
isExpanded: state.expandedSpaces.contains(child.uuid),
|
|
||||||
onItemSelected: () {
|
|
||||||
context
|
|
||||||
.read<SpaceTreeBloc>()
|
|
||||||
.add(OnSpaceSelected(communityId, child.uuid ?? '', child.children));
|
|
||||||
},
|
|
||||||
onExpansionChanged: () {
|
|
||||||
context.read<SpaceTreeBloc>().add(OnSpaceExpanded(communityId, child.uuid ?? ''));
|
|
||||||
},
|
|
||||||
children: _buildNestedSpaces(context, state, child, communityId),
|
|
||||||
);
|
|
||||||
}).toList();
|
|
||||||
}
|
|
||||||
}
|
|
@ -179,6 +179,7 @@ class SpaceManagementBloc
|
|||||||
final updatedCommunities =
|
final updatedCommunities =
|
||||||
await Future.wait(communities.map((community) async {
|
await Future.wait(communities.map((community) async {
|
||||||
final spaces = await _fetchSpacesForCommunity(community.uuid);
|
final spaces = await _fetchSpacesForCommunity(community.uuid);
|
||||||
|
|
||||||
return CommunityModel(
|
return CommunityModel(
|
||||||
uuid: community.uuid,
|
uuid: community.uuid,
|
||||||
createdAt: community.createdAt,
|
createdAt: community.createdAt,
|
||||||
@ -313,6 +314,7 @@ class SpaceManagementBloc
|
|||||||
SelectSpaceEvent event,
|
SelectSpaceEvent event,
|
||||||
Emitter<SpaceManagementState> emit,
|
Emitter<SpaceManagementState> emit,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
_handleCommunitySpaceStateUpdate(
|
_handleCommunitySpaceStateUpdate(
|
||||||
emit: emit,
|
emit: emit,
|
||||||
selectedCommunity: event.selectedCommunity,
|
selectedCommunity: event.selectedCommunity,
|
||||||
|
@ -95,6 +95,9 @@ class SpaceModel {
|
|||||||
icon: json['icon'] ?? Assets.location,
|
icon: json['icon'] ?? Assets.location,
|
||||||
position: Offset(json['x'] ?? 0, json['y'] ?? 0),
|
position: Offset(json['x'] ?? 0, json['y'] ?? 0),
|
||||||
isHovered: false,
|
isHovered: false,
|
||||||
|
spaceModel: json['spaceModel'] != null
|
||||||
|
? SpaceTemplateModel.fromJson(json['spaceModel'])
|
||||||
|
: null,
|
||||||
tags: (json['tags'] as List<dynamic>?)
|
tags: (json['tags'] as List<dynamic>?)
|
||||||
?.where((item) => item is Map<String, dynamic>) // Validate type
|
?.where((item) => item is Map<String, dynamic>) // Validate type
|
||||||
.map((item) => Tag.fromJson(item as Map<String, dynamic>))
|
.map((item) => Tag.fromJson(item as Map<String, dynamic>))
|
||||||
|
@ -22,6 +22,7 @@ import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/curved_li
|
|||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/dialogs/duplicate_process_dialog.dart';
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/dialogs/duplicate_process_dialog.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/space_card_widget.dart';
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/space_card_widget.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/space_container_widget.dart';
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/space_container_widget.dart';
|
||||||
|
import 'package:syncrow_web/pages/spaces_management/helper/space_helper.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
|
||||||
@ -195,7 +196,6 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
|||||||
screenSize,
|
screenSize,
|
||||||
position:
|
position:
|
||||||
spaces[index].position + newPosition,
|
spaces[index].position + newPosition,
|
||||||
|
|
||||||
parentIndex: index,
|
parentIndex: index,
|
||||||
direction: direction,
|
direction: direction,
|
||||||
);
|
);
|
||||||
@ -351,7 +351,10 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
|||||||
spaceModels: widget.spaceModels,
|
spaceModels: widget.spaceModels,
|
||||||
name: widget.selectedSpace!.name,
|
name: widget.selectedSpace!.name,
|
||||||
icon: widget.selectedSpace!.icon,
|
icon: widget.selectedSpace!.icon,
|
||||||
|
parentSpace: SpaceHelper.findSpaceByInternalId(
|
||||||
|
widget.selectedSpace?.parent?.internalId, spaces),
|
||||||
editSpace: widget.selectedSpace,
|
editSpace: widget.selectedSpace,
|
||||||
|
currentSpaceModel: widget.selectedSpace?.spaceModel,
|
||||||
tags: widget.selectedSpace?.tags,
|
tags: widget.selectedSpace?.tags,
|
||||||
subspaces: widget.selectedSpace?.subspaces,
|
subspaces: widget.selectedSpace?.subspaces,
|
||||||
isEdit: true,
|
isEdit: true,
|
||||||
@ -374,6 +377,15 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
|||||||
widget.selectedSpace!.status =
|
widget.selectedSpace!.status =
|
||||||
SpaceStatus.modified; // Mark as modified
|
SpaceStatus.modified; // Mark as modified
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (var space in spaces) {
|
||||||
|
if (space.internalId == widget.selectedSpace?.internalId) {
|
||||||
|
space.status = SpaceStatus.modified;
|
||||||
|
space.subspaces = subspaces;
|
||||||
|
space.tags = tags;
|
||||||
|
space.name = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
key: Key(widget.selectedSpace!.name),
|
key: Key(widget.selectedSpace!.name),
|
||||||
@ -452,7 +464,6 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
|||||||
}).toList();
|
}).toList();
|
||||||
|
|
||||||
if (spacesToSave.isEmpty) {
|
if (spacesToSave.isEmpty) {
|
||||||
debugPrint("No new or modified spaces to save.");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -643,12 +654,6 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
|||||||
|
|
||||||
final Map<String, int> nameCounters = {};
|
final Map<String, int> nameCounters = {};
|
||||||
|
|
||||||
String _generateCopyName(String originalName) {
|
|
||||||
final baseName = originalName.replaceAll(RegExp(r'\(\d+\)$'), '').trim();
|
|
||||||
nameCounters[baseName] = (nameCounters[baseName] ?? 0) + 1;
|
|
||||||
return "$baseName(${nameCounters[baseName]})";
|
|
||||||
}
|
|
||||||
|
|
||||||
SpaceModel duplicateRecursive(SpaceModel original, Offset parentPosition,
|
SpaceModel duplicateRecursive(SpaceModel original, Offset parentPosition,
|
||||||
SpaceModel? duplicatedParent) {
|
SpaceModel? duplicatedParent) {
|
||||||
Offset newPosition = parentPosition + Offset(horizontalGap, 0);
|
Offset newPosition = parentPosition + Offset(horizontalGap, 0);
|
||||||
@ -659,7 +664,8 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
|||||||
newPosition += Offset(horizontalGap, 0);
|
newPosition += Offset(horizontalGap, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
final duplicatedName = _generateCopyName(original.name);
|
final duplicatedName =
|
||||||
|
SpaceHelper.generateUniqueSpaceName(original.name, spaces);
|
||||||
|
|
||||||
final duplicated = SpaceModel(
|
final duplicated = SpaceModel(
|
||||||
name: duplicatedName,
|
name: duplicatedName,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:syncrow_web/common/widgets/custom_expansion_tile.dart';
|
import 'package:syncrow_web/common/custom_expansion_tile.dart';
|
||||||
|
|
||||||
class CommunityTile extends StatelessWidget {
|
class CommunityTile extends StatelessWidget {
|
||||||
final String title;
|
final String title;
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user