mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-15 09:45:25 +00:00
Compare commits
1 Commits
SP-1713-Im
...
SP-1620-FE
Author | SHA1 | Date | |
---|---|---|---|
a1826b43ac |
10
.github/.github/dependabot.yaml
vendored
10
.github/.github/dependabot.yaml
vendored
@ -1,10 +0,0 @@
|
|||||||
version: 2
|
|
||||||
updates:
|
|
||||||
- package-ecosystem: "github-actions"
|
|
||||||
directory: "/"
|
|
||||||
schedule:
|
|
||||||
interval: "daily"
|
|
||||||
- package-ecosystem: "pub"
|
|
||||||
directory: "/"
|
|
||||||
schedule:
|
|
||||||
interval: "daily"
|
|
Binary file not shown.
Before Width: | Height: | Size: 290 KiB |
@ -1,10 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
class AppLoadingIndicator extends StatelessWidget {
|
|
||||||
const AppLoadingIndicator({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return const Center(child: CircularProgressIndicator());
|
|
||||||
}
|
|
||||||
}
|
|
@ -11,6 +11,7 @@ import 'package:syncrow_web/pages/home/bloc/home_event.dart';
|
|||||||
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_bloc.dart';
|
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
|
import 'package:syncrow_web/pages/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';
|
||||||
@ -20,10 +21,8 @@ import 'package:syncrow_web/utils/theme/theme.dart';
|
|||||||
|
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
try {
|
try {
|
||||||
const environment = String.fromEnvironment(
|
const environment =
|
||||||
'FLAVOR',
|
String.fromEnvironment('FLAVOR', defaultValue: 'production');
|
||||||
defaultValue: 'production',
|
|
||||||
);
|
|
||||||
await dotenv.load(fileName: '.env.$environment');
|
await dotenv.load(fileName: '.env.$environment');
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
await Firebase.initializeApp(
|
await Firebase.initializeApp(
|
||||||
@ -41,7 +40,7 @@ class MyApp extends StatelessWidget {
|
|||||||
initialLocation: RoutesConst.auth,
|
initialLocation: RoutesConst.auth,
|
||||||
routes: AppRoutes.getRoutes(),
|
routes: AppRoutes.getRoutes(),
|
||||||
redirect: (context, state) async {
|
redirect: (context, state) async {
|
||||||
final checkToken = await AuthBloc.getTokenAndValidate();
|
String checkToken = await AuthBloc.getTokenAndValidate();
|
||||||
final loggedIn = checkToken == 'Success';
|
final loggedIn = checkToken == 'Success';
|
||||||
final goingToLogin = state.uri.toString() == RoutesConst.auth;
|
final goingToLogin = state.uri.toString() == RoutesConst.auth;
|
||||||
|
|
||||||
@ -59,7 +58,8 @@ class MyApp extends StatelessWidget {
|
|||||||
BlocProvider<CreateRoutineBloc>(
|
BlocProvider<CreateRoutineBloc>(
|
||||||
create: (context) => CreateRoutineBloc(),
|
create: (context) => CreateRoutineBloc(),
|
||||||
),
|
),
|
||||||
BlocProvider(create: (context) => HomeBloc()..add(FetchUserInfo())),
|
BlocProvider(
|
||||||
|
create: (context) => HomeBloc()..add(const FetchUserInfo())),
|
||||||
BlocProvider<VisitorPasswordBloc>(
|
BlocProvider<VisitorPasswordBloc>(
|
||||||
create: (context) => VisitorPasswordBloc(),
|
create: (context) => VisitorPasswordBloc(),
|
||||||
),
|
),
|
||||||
@ -67,7 +67,7 @@ class MyApp extends StatelessWidget {
|
|||||||
create: (context) => RoutineBloc(),
|
create: (context) => RoutineBloc(),
|
||||||
),
|
),
|
||||||
BlocProvider<SpaceTreeBloc>(
|
BlocProvider<SpaceTreeBloc>(
|
||||||
create: (context) => SpaceTreeBloc(),
|
create: (context) => SpaceTreeBloc()..add(InitialEvent()),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
child: MaterialApp.router(
|
child: MaterialApp.router(
|
||||||
|
@ -11,6 +11,7 @@ import 'package:syncrow_web/pages/home/bloc/home_event.dart';
|
|||||||
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_bloc.dart';
|
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
|
import 'package:syncrow_web/pages/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';
|
||||||
@ -20,10 +21,7 @@ import 'package:syncrow_web/utils/theme/theme.dart';
|
|||||||
|
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
try {
|
try {
|
||||||
const environment = String.fromEnvironment(
|
const environment = String.fromEnvironment('FLAVOR', defaultValue: 'development');
|
||||||
'FLAVOR',
|
|
||||||
defaultValue: 'development',
|
|
||||||
);
|
|
||||||
await dotenv.load(fileName: '.env.$environment');
|
await dotenv.load(fileName: '.env.$environment');
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
await Firebase.initializeApp(
|
await Firebase.initializeApp(
|
||||||
@ -41,7 +39,7 @@ class MyApp extends StatelessWidget {
|
|||||||
initialLocation: RoutesConst.auth,
|
initialLocation: RoutesConst.auth,
|
||||||
routes: AppRoutes.getRoutes(),
|
routes: AppRoutes.getRoutes(),
|
||||||
redirect: (context, state) async {
|
redirect: (context, state) async {
|
||||||
final checkToken = await AuthBloc.getTokenAndValidate();
|
String checkToken = await AuthBloc.getTokenAndValidate();
|
||||||
final loggedIn = checkToken == 'Success';
|
final loggedIn = checkToken == 'Success';
|
||||||
final goingToLogin = state.uri.toString() == RoutesConst.auth;
|
final goingToLogin = state.uri.toString() == RoutesConst.auth;
|
||||||
|
|
||||||
@ -59,7 +57,7 @@ class MyApp extends StatelessWidget {
|
|||||||
BlocProvider<CreateRoutineBloc>(
|
BlocProvider<CreateRoutineBloc>(
|
||||||
create: (context) => CreateRoutineBloc(),
|
create: (context) => CreateRoutineBloc(),
|
||||||
),
|
),
|
||||||
BlocProvider(create: (context) => HomeBloc()..add(FetchUserInfo())),
|
BlocProvider(create: (context) => HomeBloc()..add(const FetchUserInfo())),
|
||||||
BlocProvider<VisitorPasswordBloc>(
|
BlocProvider<VisitorPasswordBloc>(
|
||||||
create: (context) => VisitorPasswordBloc(),
|
create: (context) => VisitorPasswordBloc(),
|
||||||
),
|
),
|
||||||
@ -67,7 +65,7 @@ class MyApp extends StatelessWidget {
|
|||||||
create: (context) => RoutineBloc(),
|
create: (context) => RoutineBloc(),
|
||||||
),
|
),
|
||||||
BlocProvider<SpaceTreeBloc>(
|
BlocProvider<SpaceTreeBloc>(
|
||||||
create: (context) => SpaceTreeBloc(),
|
create: (context) => SpaceTreeBloc()..add(InitialEvent()),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
child: MaterialApp.router(
|
child: MaterialApp.router(
|
||||||
|
@ -11,6 +11,7 @@ import 'package:syncrow_web/pages/home/bloc/home_event.dart';
|
|||||||
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_bloc.dart';
|
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
|
import 'package:syncrow_web/pages/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';
|
||||||
@ -38,7 +39,7 @@ class MyApp extends StatelessWidget {
|
|||||||
initialLocation: RoutesConst.auth,
|
initialLocation: RoutesConst.auth,
|
||||||
routes: AppRoutes.getRoutes(),
|
routes: AppRoutes.getRoutes(),
|
||||||
redirect: (context, state) async {
|
redirect: (context, state) async {
|
||||||
final checkToken = await AuthBloc.getTokenAndValidate();
|
String checkToken = await AuthBloc.getTokenAndValidate();
|
||||||
final loggedIn = checkToken == 'Success';
|
final loggedIn = checkToken == 'Success';
|
||||||
final goingToLogin = state.uri.toString() == RoutesConst.auth;
|
final goingToLogin = state.uri.toString() == RoutesConst.auth;
|
||||||
|
|
||||||
@ -56,7 +57,7 @@ class MyApp extends StatelessWidget {
|
|||||||
BlocProvider<CreateRoutineBloc>(
|
BlocProvider<CreateRoutineBloc>(
|
||||||
create: (context) => CreateRoutineBloc(),
|
create: (context) => CreateRoutineBloc(),
|
||||||
),
|
),
|
||||||
BlocProvider(create: (context) => HomeBloc()..add(FetchUserInfo())),
|
BlocProvider(create: (context) => HomeBloc()..add(const FetchUserInfo())),
|
||||||
BlocProvider<VisitorPasswordBloc>(
|
BlocProvider<VisitorPasswordBloc>(
|
||||||
create: (context) => VisitorPasswordBloc(),
|
create: (context) => VisitorPasswordBloc(),
|
||||||
),
|
),
|
||||||
@ -64,7 +65,7 @@ class MyApp extends StatelessWidget {
|
|||||||
create: (context) => RoutineBloc(),
|
create: (context) => RoutineBloc(),
|
||||||
),
|
),
|
||||||
BlocProvider<SpaceTreeBloc>(
|
BlocProvider<SpaceTreeBloc>(
|
||||||
create: (context) => SpaceTreeBloc(),
|
create: (context) => SpaceTreeBloc()..add(InitialEvent()),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
child: MaterialApp.router(
|
child: MaterialApp.router(
|
||||||
|
@ -15,9 +15,7 @@ class AirQualityDataModel extends Equatable {
|
|||||||
return AirQualityDataModel(
|
return AirQualityDataModel(
|
||||||
date: DateTime.parse(json['date'] as String),
|
date: DateTime.parse(json['date'] as String),
|
||||||
data: (json['data'] as List<dynamic>)
|
data: (json['data'] as List<dynamic>)
|
||||||
.map(
|
.map((e) => AirQualityPercentageData.fromJson(e as Map<String, dynamic>))
|
||||||
(e) => AirQualityPercentageData.fromJson(e as Map<String, dynamic>),
|
|
||||||
)
|
|
||||||
.toList(),
|
.toList(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -25,9 +23,9 @@ class AirQualityDataModel extends Equatable {
|
|||||||
static final Map<String, Color> metricColors = {
|
static final Map<String, Color> metricColors = {
|
||||||
'good': ColorsManager.goodGreen.withValues(alpha: 0.7),
|
'good': ColorsManager.goodGreen.withValues(alpha: 0.7),
|
||||||
'moderate': ColorsManager.moderateYellow.withValues(alpha: 0.7),
|
'moderate': ColorsManager.moderateYellow.withValues(alpha: 0.7),
|
||||||
'unhealthy_sensitive': ColorsManager.poorOrange.withValues(alpha: 0.7),
|
'poor': ColorsManager.poorOrange.withValues(alpha: 0.7),
|
||||||
'unhealthy': ColorsManager.unhealthyRed.withValues(alpha: 0.7),
|
'unhealthy': ColorsManager.unhealthyRed.withValues(alpha: 0.7),
|
||||||
'very_unhealthy': ColorsManager.severePink.withValues(alpha: 0.7),
|
'severe': ColorsManager.severePink.withValues(alpha: 0.7),
|
||||||
'hazardous': ColorsManager.hazardousPurple.withValues(alpha: 0.7),
|
'hazardous': ColorsManager.hazardousPurple.withValues(alpha: 0.7),
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -38,19 +36,22 @@ class AirQualityDataModel extends Equatable {
|
|||||||
class AirQualityPercentageData extends Equatable {
|
class AirQualityPercentageData extends Equatable {
|
||||||
const AirQualityPercentageData({
|
const AirQualityPercentageData({
|
||||||
required this.type,
|
required this.type,
|
||||||
|
required this.name,
|
||||||
required this.percentage,
|
required this.percentage,
|
||||||
});
|
});
|
||||||
|
|
||||||
final String type;
|
final String type;
|
||||||
|
final String name;
|
||||||
final double percentage;
|
final double percentage;
|
||||||
|
|
||||||
factory AirQualityPercentageData.fromJson(Map<String, dynamic> json) {
|
factory AirQualityPercentageData.fromJson(Map<String, dynamic> json) {
|
||||||
return AirQualityPercentageData(
|
return AirQualityPercentageData(
|
||||||
type: json['type'] as String? ?? '',
|
type: json['type'] as String? ?? '',
|
||||||
|
name: json['name'] as String? ?? '',
|
||||||
percentage: (json['percentage'] as num?)?.toDouble() ?? 0,
|
percentage: (json['percentage'] as num?)?.toDouble() ?? 0,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object?> get props => [type, percentage];
|
List<Object?> get props => [type, name, percentage];
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ class AirQualityDistributionBloc
|
|||||||
state.copyWith(
|
state.copyWith(
|
||||||
status: AirQualityDistributionStatus.success,
|
status: AirQualityDistributionStatus.success,
|
||||||
chartData: result,
|
chartData: result,
|
||||||
|
filteredChartData: _arrangeChartDataByType(result, state.selectedAqiType),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -57,6 +58,24 @@ class AirQualityDistributionBloc
|
|||||||
UpdateAqiTypeEvent event,
|
UpdateAqiTypeEvent event,
|
||||||
Emitter<AirQualityDistributionState> emit,
|
Emitter<AirQualityDistributionState> emit,
|
||||||
) {
|
) {
|
||||||
emit(state.copyWith(selectedAqiType: event.aqiType));
|
emit(
|
||||||
|
state.copyWith(
|
||||||
|
selectedAqiType: event.aqiType,
|
||||||
|
filteredChartData: _arrangeChartDataByType(state.chartData, event.aqiType),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<AirQualityDataModel> _arrangeChartDataByType(
|
||||||
|
List<AirQualityDataModel> data,
|
||||||
|
AqiType aqiType,
|
||||||
|
) {
|
||||||
|
final filteredData = data.map(
|
||||||
|
(data) => AirQualityDataModel(
|
||||||
|
date: data.date,
|
||||||
|
data: data.data.where((value) => value.type == aqiType.code).toList(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return filteredData.toList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,24 +11,28 @@ class AirQualityDistributionState extends Equatable {
|
|||||||
const AirQualityDistributionState({
|
const AirQualityDistributionState({
|
||||||
this.status = AirQualityDistributionStatus.initial,
|
this.status = AirQualityDistributionStatus.initial,
|
||||||
this.chartData = const [],
|
this.chartData = const [],
|
||||||
|
this.filteredChartData = const [],
|
||||||
this.errorMessage,
|
this.errorMessage,
|
||||||
this.selectedAqiType = AqiType.aqi,
|
this.selectedAqiType = AqiType.aqi,
|
||||||
});
|
});
|
||||||
|
|
||||||
final AirQualityDistributionStatus status;
|
final AirQualityDistributionStatus status;
|
||||||
final List<AirQualityDataModel> chartData;
|
final List<AirQualityDataModel> chartData;
|
||||||
|
final List<AirQualityDataModel> filteredChartData;
|
||||||
final String? errorMessage;
|
final String? errorMessage;
|
||||||
final AqiType selectedAqiType;
|
final AqiType selectedAqiType;
|
||||||
|
|
||||||
AirQualityDistributionState copyWith({
|
AirQualityDistributionState copyWith({
|
||||||
AirQualityDistributionStatus? status,
|
AirQualityDistributionStatus? status,
|
||||||
List<AirQualityDataModel>? chartData,
|
List<AirQualityDataModel>? chartData,
|
||||||
|
List<AirQualityDataModel>? filteredChartData,
|
||||||
String? errorMessage,
|
String? errorMessage,
|
||||||
AqiType? selectedAqiType,
|
AqiType? selectedAqiType,
|
||||||
}) {
|
}) {
|
||||||
return AirQualityDistributionState(
|
return AirQualityDistributionState(
|
||||||
status: status ?? this.status,
|
status: status ?? this.status,
|
||||||
chartData: chartData ?? this.chartData,
|
chartData: chartData ?? this.chartData,
|
||||||
|
filteredChartData: filteredChartData ?? this.filteredChartData,
|
||||||
errorMessage: errorMessage ?? this.errorMessage,
|
errorMessage: errorMessage ?? this.errorMessage,
|
||||||
selectedAqiType: selectedAqiType ?? this.selectedAqiType,
|
selectedAqiType: selectedAqiType ?? this.selectedAqiType,
|
||||||
);
|
);
|
||||||
|
@ -3,7 +3,6 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||||||
import 'package:syncrow_web/pages/analytics/modules/air_quality/blocs/air_quality_distribution/air_quality_distribution_bloc.dart';
|
import 'package:syncrow_web/pages/analytics/modules/air_quality/blocs/air_quality_distribution/air_quality_distribution_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/modules/air_quality/blocs/device_location/device_location_bloc.dart';
|
import 'package:syncrow_web/pages/analytics/modules/air_quality/blocs/device_location/device_location_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/modules/air_quality/blocs/range_of_aqi/range_of_aqi_bloc.dart';
|
import 'package:syncrow_web/pages/analytics/modules/air_quality/blocs/range_of_aqi/range_of_aqi_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/modules/air_quality/widgets/aqi_type_dropdown.dart';
|
|
||||||
import 'package:syncrow_web/pages/analytics/modules/analytics/blocs/analytics_date_picker_bloc/analytics_date_picker_bloc.dart';
|
import 'package:syncrow_web/pages/analytics/modules/analytics/blocs/analytics_date_picker_bloc/analytics_date_picker_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/modules/analytics/blocs/analytics_devices/analytics_devices_bloc.dart';
|
import 'package:syncrow_web/pages/analytics/modules/analytics/blocs/analytics_devices/analytics_devices_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/modules/energy_management/blocs/realtime_device_changes/realtime_device_changes_bloc.dart';
|
import 'package:syncrow_web/pages/analytics/modules/energy_management/blocs/realtime_device_changes/realtime_device_changes_bloc.dart';
|
||||||
@ -23,7 +22,6 @@ abstract final class FetchAirQualityDataHelper {
|
|||||||
bool shouldFetchAnalyticsDevices = true,
|
bool shouldFetchAnalyticsDevices = true,
|
||||||
}) {
|
}) {
|
||||||
final date = context.read<AnalyticsDatePickerBloc>().state.monthlyDate;
|
final date = context.read<AnalyticsDatePickerBloc>().state.monthlyDate;
|
||||||
final aqiType = context.read<AirQualityDistributionBloc>().state.selectedAqiType;
|
|
||||||
loadAnalyticsDevices(
|
loadAnalyticsDevices(
|
||||||
context,
|
context,
|
||||||
communityUuid: communityUuid,
|
communityUuid: communityUuid,
|
||||||
@ -38,7 +36,6 @@ abstract final class FetchAirQualityDataHelper {
|
|||||||
context,
|
context,
|
||||||
spaceUuid: spaceUuid,
|
spaceUuid: spaceUuid,
|
||||||
date: date,
|
date: date,
|
||||||
aqiType: aqiType,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,15 +104,10 @@ abstract final class FetchAirQualityDataHelper {
|
|||||||
BuildContext context, {
|
BuildContext context, {
|
||||||
required String spaceUuid,
|
required String spaceUuid,
|
||||||
required DateTime date,
|
required DateTime date,
|
||||||
required AqiType aqiType,
|
|
||||||
}) {
|
}) {
|
||||||
context.read<AirQualityDistributionBloc>().add(
|
context.read<AirQualityDistributionBloc>().add(
|
||||||
LoadAirQualityDistribution(
|
LoadAirQualityDistribution(
|
||||||
GetAirQualityDistributionParam(
|
GetAirQualityDistributionParam(spaceUuid: spaceUuid, date: date),
|
||||||
spaceUuid: spaceUuid,
|
|
||||||
date: date,
|
|
||||||
aqiType: aqiType,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,11 @@ class AqiDistributionChart extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final sortedData = List<AirQualityDataModel>.from(chartData)
|
||||||
|
..sort(
|
||||||
|
(a, b) => a.date.compareTo(b.date),
|
||||||
|
);
|
||||||
|
|
||||||
return BarChart(
|
return BarChart(
|
||||||
BarChartData(
|
BarChartData(
|
||||||
maxY: 100.1,
|
maxY: 100.1,
|
||||||
@ -25,25 +30,29 @@ class AqiDistributionChart extends StatelessWidget {
|
|||||||
borderData: EnergyManagementChartsHelper.borderData(),
|
borderData: EnergyManagementChartsHelper.borderData(),
|
||||||
barTouchData: _barTouchData(context),
|
barTouchData: _barTouchData(context),
|
||||||
titlesData: _titlesData(context),
|
titlesData: _titlesData(context),
|
||||||
barGroups: _buildBarGroups(),
|
barGroups: _buildBarGroups(sortedData),
|
||||||
),
|
),
|
||||||
duration: Duration.zero,
|
duration: Duration.zero,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<BarChartGroupData> _buildBarGroups() {
|
List<BarChartGroupData> _buildBarGroups(List<AirQualityDataModel> sortedData) {
|
||||||
return List.generate(chartData.length, (index) {
|
return List.generate(sortedData.length, (index) {
|
||||||
final data = chartData[index];
|
final data = sortedData[index];
|
||||||
final stackItems = <BarChartRodData>[];
|
final stackItems = <BarChartRodData>[];
|
||||||
double currentY = 0;
|
double currentY = 0;
|
||||||
var isFirstElement = true;
|
bool isFirstElement = true;
|
||||||
|
|
||||||
for (final percentageData in data.data) {
|
// Sort data by type to ensure consistent order
|
||||||
|
final sortedPercentageData = List<AirQualityPercentageData>.from(data.data)
|
||||||
|
..sort((a, b) => a.type.compareTo(b.type));
|
||||||
|
|
||||||
|
for (final percentageData in sortedPercentageData) {
|
||||||
stackItems.add(
|
stackItems.add(
|
||||||
BarChartRodData(
|
BarChartRodData(
|
||||||
fromY: currentY,
|
fromY: currentY,
|
||||||
toY: currentY + percentageData.percentage,
|
toY: currentY + percentageData.percentage ,
|
||||||
color: AirQualityDataModel.metricColors[percentageData.type],
|
color: AirQualityDataModel.metricColors[percentageData.name]!,
|
||||||
borderRadius: isFirstElement
|
borderRadius: isFirstElement
|
||||||
? const BorderRadius.only(
|
? const BorderRadius.only(
|
||||||
topLeft: Radius.circular(22),
|
topLeft: Radius.circular(22),
|
||||||
@ -75,21 +84,23 @@ class AqiDistributionChart extends StatelessWidget {
|
|||||||
tooltipRoundedRadius: 16,
|
tooltipRoundedRadius: 16,
|
||||||
tooltipPadding: const EdgeInsets.all(8),
|
tooltipPadding: const EdgeInsets.all(8),
|
||||||
getTooltipItem: (group, groupIndex, rod, rodIndex) {
|
getTooltipItem: (group, groupIndex, rod, rodIndex) {
|
||||||
final data = chartData[group.x];
|
final data = chartData[group.x.toInt()];
|
||||||
|
|
||||||
final children = <TextSpan>[];
|
final List<TextSpan> children = [];
|
||||||
|
|
||||||
final textStyle = context.textTheme.bodySmall?.copyWith(
|
final textStyle = context.textTheme.bodySmall?.copyWith(
|
||||||
color: ColorsManager.blackColor,
|
color: ColorsManager.blackColor,
|
||||||
fontSize: 8,
|
fontSize: 12,
|
||||||
);
|
);
|
||||||
|
|
||||||
for (final percentageData in data.data) {
|
// Sort data by type to ensure consistent order
|
||||||
final percentage = percentageData.percentage.toStringAsFixed(1);
|
final sortedPercentageData = List<AirQualityPercentageData>.from(data.data)
|
||||||
final type = percentageData.type[0].toUpperCase() +
|
..sort((a, b) => a.type.compareTo(b.type));
|
||||||
percentageData.type.substring(1).replaceAll('_', ' ');
|
|
||||||
|
for (final percentageData in sortedPercentageData) {
|
||||||
children.add(TextSpan(
|
children.add(TextSpan(
|
||||||
text: '\n$type: $percentage%',
|
text:
|
||||||
|
'\n${percentageData.type.toUpperCase()}: ${percentageData.percentage.toStringAsFixed(1)}%',
|
||||||
style: textStyle,
|
style: textStyle,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -98,10 +109,9 @@ class AqiDistributionChart extends StatelessWidget {
|
|||||||
DateFormat('dd/MM/yyyy').format(data.date),
|
DateFormat('dd/MM/yyyy').format(data.date),
|
||||||
context.textTheme.bodyMedium!.copyWith(
|
context.textTheme.bodyMedium!.copyWith(
|
||||||
color: ColorsManager.blackColor,
|
color: ColorsManager.blackColor,
|
||||||
fontSize: 9,
|
fontSize: 16,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
),
|
),
|
||||||
textAlign: TextAlign.start,
|
|
||||||
children: children,
|
children: children,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -33,7 +33,7 @@ class AqiDistributionChartBox extends StatelessWidget {
|
|||||||
const Divider(),
|
const Divider(),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: AqiDistributionChart(chartData: state.chartData),
|
child: AqiDistributionChart(chartData: state.filteredChartData),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -2,11 +2,8 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/modules/air_quality/blocs/air_quality_distribution/air_quality_distribution_bloc.dart';
|
import 'package:syncrow_web/pages/analytics/modules/air_quality/blocs/air_quality_distribution/air_quality_distribution_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/modules/air_quality/widgets/aqi_type_dropdown.dart';
|
import 'package:syncrow_web/pages/analytics/modules/air_quality/widgets/aqi_type_dropdown.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/modules/analytics/blocs/analytics_date_picker_bloc/analytics_date_picker_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/analytics/modules/energy_management/widgets/chart_title.dart';
|
import 'package:syncrow_web/pages/analytics/modules/energy_management/widgets/chart_title.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/params/get_air_quality_distribution_param.dart';
|
|
||||||
import 'package:syncrow_web/pages/analytics/widgets/charts_loading_widget.dart';
|
import 'package:syncrow_web/pages/analytics/widgets/charts_loading_widget.dart';
|
||||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
|
|
||||||
|
|
||||||
class AqiDistributionChartTitle extends StatelessWidget {
|
class AqiDistributionChartTitle extends StatelessWidget {
|
||||||
const AqiDistributionChartTitle({required this.isLoading, super.key});
|
const AqiDistributionChartTitle({required this.isLoading, super.key});
|
||||||
@ -34,15 +31,9 @@ class AqiDistributionChartTitle extends StatelessWidget {
|
|||||||
child: AqiTypeDropdown(
|
child: AqiTypeDropdown(
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
final bloc = context.read<AirQualityDistributionBloc>();
|
context
|
||||||
try {
|
.read<AirQualityDistributionBloc>()
|
||||||
final param = _makeLoadAqiDistributionParam(context, value);
|
.add(UpdateAqiTypeEvent(value));
|
||||||
bloc.add(LoadAirQualityDistribution(param));
|
|
||||||
} catch (_) {
|
|
||||||
return;
|
|
||||||
} finally {
|
|
||||||
bloc.add(UpdateAqiTypeEvent(value));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -50,19 +41,4 @@ class AqiDistributionChartTitle extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
GetAirQualityDistributionParam _makeLoadAqiDistributionParam(
|
|
||||||
BuildContext context,
|
|
||||||
AqiType aqiType,
|
|
||||||
) {
|
|
||||||
final date = context.read<AnalyticsDatePickerBloc>().state.monthlyDate;
|
|
||||||
final spaceUuid =
|
|
||||||
context.read<SpaceTreeBloc>().state.selectedSpaces.firstOrNull ?? '';
|
|
||||||
if (spaceUuid.isEmpty) throw Exception('Space UUID is empty');
|
|
||||||
return GetAirQualityDistributionParam(
|
|
||||||
date: date,
|
|
||||||
spaceUuid: spaceUuid,
|
|
||||||
aqiType: aqiType,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,8 @@ enum AqiType {
|
|||||||
aqi('AQI', '', 'aqi'),
|
aqi('AQI', '', 'aqi'),
|
||||||
pm25('PM2.5', 'µg/m³', 'pm25'),
|
pm25('PM2.5', 'µg/m³', 'pm25'),
|
||||||
pm10('PM10', 'µg/m³', 'pm10'),
|
pm10('PM10', 'µg/m³', 'pm10'),
|
||||||
hcho('HCHO', 'mg/m³', 'cho2'),
|
hcho('HCHO', 'mg/m³', 'hcho'),
|
||||||
tvoc('TVOC', 'µg/m³', 'voc'),
|
tvoc('TVOC', 'µg/m³', 'tvoc'),
|
||||||
co2('CO2', 'ppm', 'co2');
|
co2('CO2', 'ppm', 'co2');
|
||||||
|
|
||||||
const AqiType(this.value, this.unit, this.code);
|
const AqiType(this.value, this.unit, this.code);
|
||||||
|
@ -63,7 +63,7 @@ class RangeOfAqiChart extends StatelessWidget {
|
|||||||
gradient: LinearGradient(
|
gradient: LinearGradient(
|
||||||
begin: Alignment.bottomCenter,
|
begin: Alignment.bottomCenter,
|
||||||
end: Alignment.topCenter,
|
end: Alignment.topCenter,
|
||||||
stops: const [0.0, 0.2, 0.4, 0.6, 0.8, 1.0],
|
stops: [0.0, 0.2, 0.4, 0.6, 0.8, 1.0],
|
||||||
colors: RangeOfAqiChartsHelper.gradientData.map((e) {
|
colors: RangeOfAqiChartsHelper.gradientData.map((e) {
|
||||||
final (color, _) = e;
|
final (color, _) = e;
|
||||||
return color.withValues(alpha: 0.6);
|
return color.withValues(alpha: 0.6);
|
||||||
|
@ -16,7 +16,7 @@ import 'package:syncrow_web/pages/analytics/modules/energy_management/blocs/real
|
|||||||
import 'package:syncrow_web/pages/analytics/modules/energy_management/blocs/total_energy_consumption/total_energy_consumption_bloc.dart';
|
import 'package:syncrow_web/pages/analytics/modules/energy_management/blocs/total_energy_consumption/total_energy_consumption_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/modules/occupancy/blocs/occupancy/occupancy_bloc.dart';
|
import 'package:syncrow_web/pages/analytics/modules/occupancy/blocs/occupancy/occupancy_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/modules/occupancy/blocs/occupancy_heat_map/occupancy_heat_map_bloc.dart';
|
import 'package:syncrow_web/pages/analytics/modules/occupancy/blocs/occupancy_heat_map/occupancy_heat_map_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/services/air_quality_distribution/remote_air_quality_distribution_service.dart';
|
import 'package:syncrow_web/pages/analytics/services/air_quality_distribution/fake_air_quality_distribution_service.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/services/analytics_devices/analytics_devices_service_delagate.dart';
|
import 'package:syncrow_web/pages/analytics/services/analytics_devices/analytics_devices_service_delagate.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/services/analytics_devices/remote_energy_management_analytics_devices_service.dart';
|
import 'package:syncrow_web/pages/analytics/services/analytics_devices/remote_energy_management_analytics_devices_service.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/services/analytics_devices/remote_occupancy_analytics_devices_service.dart';
|
import 'package:syncrow_web/pages/analytics/services/analytics_devices/remote_occupancy_analytics_devices_service.dart';
|
||||||
@ -27,12 +27,10 @@ import 'package:syncrow_web/pages/analytics/services/energy_consumption_per_devi
|
|||||||
import 'package:syncrow_web/pages/analytics/services/occupacy/remote_occupancy_service.dart';
|
import 'package:syncrow_web/pages/analytics/services/occupacy/remote_occupancy_service.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/services/occupancy_heat_map/remote_occupancy_heat_map_service.dart';
|
import 'package:syncrow_web/pages/analytics/services/occupancy_heat_map/remote_occupancy_heat_map_service.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/services/power_clamp_info/remote_power_clamp_info_service.dart';
|
import 'package:syncrow_web/pages/analytics/services/power_clamp_info/remote_power_clamp_info_service.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/services/range_of_aqi/remote_range_of_aqi_service.dart';
|
import 'package:syncrow_web/pages/analytics/services/range_of_aqi/fake_range_of_aqi_service.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/services/realtime_device_service/firebase_realtime_device_service.dart';
|
import 'package:syncrow_web/pages/analytics/services/realtime_device_service/firebase_realtime_device_service.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/services/total_energy_consumption/remote_total_energy_consumption_service.dart';
|
import 'package:syncrow_web/pages/analytics/services/total_energy_consumption/remote_total_energy_consumption_service.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/space_tree/bloc/space_tree_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_event.dart';
|
|
||||||
import 'package:syncrow_web/services/api/http_service.dart';
|
import 'package:syncrow_web/services/api/http_service.dart';
|
||||||
import 'package:syncrow_web/utils/theme/responsive_text_theme.dart';
|
import 'package:syncrow_web/utils/theme/responsive_text_theme.dart';
|
||||||
import 'package:syncrow_web/web_layout/web_scaffold.dart';
|
import 'package:syncrow_web/web_layout/web_scaffold.dart';
|
||||||
@ -106,12 +104,12 @@ class _AnalyticsPageState extends State<AnalyticsPage> {
|
|||||||
),
|
),
|
||||||
BlocProvider(
|
BlocProvider(
|
||||||
create: (context) => RangeOfAqiBloc(
|
create: (context) => RangeOfAqiBloc(
|
||||||
RemoteRangeOfAqiService(_httpService),
|
FakeRangeOfAqiService(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
BlocProvider(
|
BlocProvider(
|
||||||
create: (context) => AirQualityDistributionBloc(
|
create: (context) => AirQualityDistributionBloc(
|
||||||
RemoteAirQualityDistributionService(_httpService),
|
FakeAirQualityDistributionService(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
BlocProvider(
|
BlocProvider(
|
||||||
@ -132,19 +130,9 @@ class _AnalyticsPageState extends State<AnalyticsPage> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AnalyticsPageForm extends StatefulWidget {
|
class AnalyticsPageForm extends StatelessWidget {
|
||||||
const AnalyticsPageForm({super.key});
|
const AnalyticsPageForm({super.key});
|
||||||
|
|
||||||
@override
|
|
||||||
State<AnalyticsPageForm> createState() => _AnalyticsPageFormState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _AnalyticsPageFormState extends State<AnalyticsPageForm> {
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
context.read<SpaceTreeBloc>().add(InitialEvent());
|
|
||||||
super.initState();
|
|
||||||
}
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return WebScaffold(
|
return WebScaffold(
|
||||||
|
@ -20,7 +20,7 @@ class AnalyticsDateFilterButton extends StatefulWidget {
|
|||||||
final void Function(DateTime)? onDateSelected;
|
final void Function(DateTime)? onDateSelected;
|
||||||
final DatePickerType datePickerType;
|
final DatePickerType datePickerType;
|
||||||
|
|
||||||
static final Color _color = ColorsManager.blackColor.withValues(alpha: 0.8);
|
static final _color = ColorsManager.blackColor.withValues(alpha: 0.8);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<AnalyticsDateFilterButton> createState() =>
|
State<AnalyticsDateFilterButton> createState() =>
|
||||||
@ -60,9 +60,10 @@ class _AnalyticsDateFilterButtonState extends State<AnalyticsDateFilterButton> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
showDialog<void>(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (_) => switch (widget.datePickerType) {
|
builder: (_) {
|
||||||
|
return switch (widget.datePickerType) {
|
||||||
DatePickerType.month => MonthPickerWidget(
|
DatePickerType.month => MonthPickerWidget(
|
||||||
selectedDate: widget.selectedDate,
|
selectedDate: widget.selectedDate,
|
||||||
onDateSelected: (value) {
|
onDateSelected: (value) {
|
||||||
@ -75,6 +76,7 @@ class _AnalyticsDateFilterButtonState extends State<AnalyticsDateFilterButton> {
|
|||||||
widget.onDateSelected?.call(value);
|
widget.onDateSelected?.call(value);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
};
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -118,7 +118,7 @@ class AnalyticsPageTabsAndChildren extends StatelessWidget {
|
|||||||
communityUuid: communities.firstOrNull ?? '',
|
communityUuid: communities.firstOrNull ?? '',
|
||||||
spaceUuid: spaces.firstOrNull ?? '',
|
spaceUuid: spaces.firstOrNull ?? '',
|
||||||
);
|
);
|
||||||
return;
|
break;
|
||||||
case AnalyticsPageTab.airQuality:
|
case AnalyticsPageTab.airQuality:
|
||||||
_onAirQualityDateChanged(
|
_onAirQualityDateChanged(
|
||||||
context,
|
context,
|
||||||
@ -126,9 +126,8 @@ class AnalyticsPageTabsAndChildren extends StatelessWidget {
|
|||||||
communityUuid: communities.firstOrNull ?? '',
|
communityUuid: communities.firstOrNull ?? '',
|
||||||
spaceUuid: spaces.firstOrNull ?? '',
|
spaceUuid: spaces.firstOrNull ?? '',
|
||||||
);
|
);
|
||||||
return;
|
|
||||||
default:
|
default:
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -158,7 +157,6 @@ class AnalyticsPageTabsAndChildren extends StatelessWidget {
|
|||||||
required String communityUuid,
|
required String communityUuid,
|
||||||
required String spaceUuid,
|
required String spaceUuid,
|
||||||
}) {
|
}) {
|
||||||
if (spaceUuid.isEmpty) return;
|
|
||||||
FetchAirQualityDataHelper.loadAirQualityData(
|
FetchAirQualityDataHelper.loadAirQualityData(
|
||||||
context,
|
context,
|
||||||
date: date,
|
date: date,
|
||||||
|
@ -38,7 +38,7 @@ abstract final class EnergyManagementChartsHelper {
|
|||||||
sideTitles: SideTitles(
|
sideTitles: SideTitles(
|
||||||
showTitles: true,
|
showTitles: true,
|
||||||
maxIncluded: false,
|
maxIncluded: false,
|
||||||
minIncluded: false,
|
minIncluded: true,
|
||||||
interval: leftTitlesInterval,
|
interval: leftTitlesInterval,
|
||||||
reservedSize: 110,
|
reservedSize: 110,
|
||||||
getTitlesWidget: (value, meta) => Padding(
|
getTitlesWidget: (value, meta) => Padding(
|
||||||
|
@ -46,7 +46,7 @@ class AnalyticsEnergyManagementView extends StatelessWidget {
|
|||||||
spacing: 32,
|
spacing: 32,
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 7,
|
flex: 2,
|
||||||
child: Column(
|
child: Column(
|
||||||
spacing: 20,
|
spacing: 20,
|
||||||
children: [
|
children: [
|
||||||
@ -55,7 +55,7 @@ class AnalyticsEnergyManagementView extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(flex: 4, child: PowerClampEnergyDataWidget()),
|
Expanded(child: PowerClampEnergyDataWidget()),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -31,12 +31,12 @@ class AnalyticsOccupancyView extends StatelessWidget {
|
|||||||
return SingleChildScrollView(
|
return SingleChildScrollView(
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: _padding,
|
padding: _padding,
|
||||||
height: height * 1,
|
height: height * 0.9,
|
||||||
child: const Row(
|
child: const Row(
|
||||||
spacing: 32,
|
spacing: 32,
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 7,
|
flex: 5,
|
||||||
child: Column(
|
child: Column(
|
||||||
spacing: 20,
|
spacing: 20,
|
||||||
children: [
|
children: [
|
||||||
@ -45,7 +45,7 @@ class AnalyticsOccupancyView extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(flex: 4, child: OccupancyEndSideBar()),
|
Expanded(flex: 2, child: OccupancyEndSideBar()),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -24,9 +24,8 @@ class OccupancyEndSideBar extends StatelessWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
const AnalyticsSidebarHeader(title: 'Presnce Sensor'),
|
const AnalyticsSidebarHeader(title: 'Presnce Sensor'),
|
||||||
Expanded(
|
SizedBox(
|
||||||
child: SizedBox(
|
height: MediaQuery.sizeOf(context).height * 0.2,
|
||||||
// height: MediaQuery.sizeOf(context).height * 0.2,
|
|
||||||
child: PowerClampEnergyStatusWidget(
|
child: PowerClampEnergyStatusWidget(
|
||||||
status: [
|
status: [
|
||||||
PowerClampEnergyStatus(
|
PowerClampEnergyStatus(
|
||||||
@ -55,14 +54,7 @@ class OccupancyEndSideBar extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
Expanded(
|
|
||||||
flex: 2,
|
|
||||||
child: FittedBox(
|
|
||||||
child: Image.asset(Assets.autocadOccupancyImage),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -34,8 +34,8 @@ class OccupancyHeatMapGradient extends StatelessWidget {
|
|||||||
width: 1,
|
width: 1,
|
||||||
),
|
),
|
||||||
gradient: LinearGradient(
|
gradient: LinearGradient(
|
||||||
begin: AlignmentDirectional.centerStart,
|
begin: AlignmentDirectional.centerEnd,
|
||||||
end: AlignmentDirectional.centerEnd,
|
end: AlignmentDirectional.centerStart,
|
||||||
colors: _heatMapColors(),
|
colors: _heatMapColors(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -28,11 +28,11 @@ class OccupancyPainter extends CustomPainter {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void paint(Canvas canvas, Size size) {
|
void paint(Canvas canvas, Size size) {
|
||||||
final fillPaint = Paint();
|
final Paint fillPaint = Paint();
|
||||||
final borderPaint = Paint()
|
final Paint borderPaint = Paint()
|
||||||
..color = ColorsManager.grayBorder.withValues(alpha: 0.4)
|
..color = ColorsManager.grayBorder.withValues(alpha: 0.4)
|
||||||
..style = PaintingStyle.stroke;
|
..style = PaintingStyle.stroke;
|
||||||
final hoveredBorderPaint = Paint()
|
final Paint hoveredBorderPaint = Paint()
|
||||||
..color = Colors.black
|
..color = Colors.black
|
||||||
..style = PaintingStyle.stroke
|
..style = PaintingStyle.stroke
|
||||||
..strokeWidth = 1.5;
|
..strokeWidth = 1.5;
|
||||||
@ -48,6 +48,7 @@ class OccupancyPainter extends CustomPainter {
|
|||||||
final rect = Rect.fromLTWH(x, y, cellSize, cellSize);
|
final rect = Rect.fromLTWH(x, y, cellSize, cellSize);
|
||||||
canvas.drawRect(rect, fillPaint);
|
canvas.drawRect(rect, fillPaint);
|
||||||
|
|
||||||
|
// Highlight the hovered item
|
||||||
if (hoveredItem != null && hoveredItem!.index == item.index) {
|
if (hoveredItem != null && hoveredItem!.index == item.index) {
|
||||||
canvas.drawRect(rect, hoveredBorderPaint);
|
canvas.drawRect(rect, hoveredBorderPaint);
|
||||||
} else {
|
} else {
|
||||||
@ -72,16 +73,16 @@ class OccupancyPainter extends CustomPainter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _drawDashedLine(Canvas canvas, Offset start, Offset end, Paint paint) {
|
void _drawDashedLine(Canvas canvas, Offset start, Offset end, Paint paint) {
|
||||||
const dashWidth = 2.0;
|
const double dashWidth = 2.0;
|
||||||
const dashSpace = 4.0;
|
const double dashSpace = 4.0;
|
||||||
final totalLength = (end - start).distance;
|
final double totalLength = (end - start).distance;
|
||||||
final direction = (end - start) / (end - start).distance;
|
final Offset direction = (end - start) / (end - start).distance;
|
||||||
|
|
||||||
var currentLength = 0.0;
|
double currentLength = 0.0;
|
||||||
while (currentLength < totalLength) {
|
while (currentLength < totalLength) {
|
||||||
final dashStart = start + direction * currentLength;
|
final Offset dashStart = start + direction * currentLength;
|
||||||
final nextLength = currentLength + dashWidth;
|
final double nextLength = currentLength + dashWidth;
|
||||||
final dashEnd =
|
final Offset dashEnd =
|
||||||
start + direction * (nextLength < totalLength ? nextLength : totalLength);
|
start + direction * (nextLength < totalLength ? nextLength : totalLength);
|
||||||
canvas.drawLine(dashStart, dashEnd, paint);
|
canvas.drawLine(dashStart, dashEnd, paint);
|
||||||
currentLength = nextLength + dashSpace;
|
currentLength = nextLength + dashSpace;
|
||||||
@ -90,9 +91,8 @@ class OccupancyPainter extends CustomPainter {
|
|||||||
|
|
||||||
Color _getColor(int value) {
|
Color _getColor(int value) {
|
||||||
if (maxValue == 0) return ColorsManager.vividBlue.withValues(alpha: 0);
|
if (maxValue == 0) return ColorsManager.vividBlue.withValues(alpha: 0);
|
||||||
final clampedValue = 0.075 + (1 * value.clamp(0, maxValue) / maxValue);
|
final opacity = value.clamp(0, maxValue) / maxValue;
|
||||||
final opacity = value == 0 ? 0 : clampedValue;
|
return ColorsManager.vividBlue.withValues(alpha: opacity);
|
||||||
return ColorsManager.vividBlue.withValues(alpha: opacity.toDouble());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -1,14 +1,9 @@
|
|||||||
import 'package:syncrow_web/pages/analytics/modules/air_quality/widgets/aqi_type_dropdown.dart';
|
|
||||||
|
|
||||||
class GetAirQualityDistributionParam {
|
class GetAirQualityDistributionParam {
|
||||||
final DateTime date;
|
final DateTime date;
|
||||||
final String spaceUuid;
|
final String spaceUuid;
|
||||||
final AqiType aqiType;
|
|
||||||
|
|
||||||
const GetAirQualityDistributionParam(
|
const GetAirQualityDistributionParam({
|
||||||
{
|
|
||||||
required this.date,
|
required this.date,
|
||||||
required this.spaceUuid,
|
required this.spaceUuid,
|
||||||
required this.aqiType,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,95 @@
|
|||||||
|
import 'dart:math';
|
||||||
|
|
||||||
|
import 'package:syncrow_web/pages/analytics/models/air_quality_data_model.dart';
|
||||||
|
import 'package:syncrow_web/pages/analytics/modules/air_quality/widgets/aqi_type_dropdown.dart';
|
||||||
|
import 'package:syncrow_web/pages/analytics/params/get_air_quality_distribution_param.dart';
|
||||||
|
import 'package:syncrow_web/pages/analytics/services/air_quality_distribution/air_quality_distribution_service.dart';
|
||||||
|
|
||||||
|
class FakeAirQualityDistributionService implements AirQualityDistributionService {
|
||||||
|
final _random = Random();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<List<AirQualityDataModel>> getAirQualityDistribution(
|
||||||
|
GetAirQualityDistributionParam param,
|
||||||
|
) async {
|
||||||
|
return Future.delayed(
|
||||||
|
const Duration(milliseconds: 400),
|
||||||
|
() => List.generate(30, (index) {
|
||||||
|
final date = DateTime(2025, 5, 1).add(Duration(days: index));
|
||||||
|
|
||||||
|
final values = _generateRandomPercentages();
|
||||||
|
final nullMask = List.generate(6, (_) => _shouldBeNull());
|
||||||
|
|
||||||
|
if (nullMask.every((isNull) => isNull)) {
|
||||||
|
nullMask[_random.nextInt(6)] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
final nonNullValues = _redistributePercentages(values, nullMask);
|
||||||
|
|
||||||
|
return AirQualityDataModel(
|
||||||
|
date: date,
|
||||||
|
data: [
|
||||||
|
AirQualityPercentageData(
|
||||||
|
type: AqiType.aqi.code,
|
||||||
|
percentage: nonNullValues[0],
|
||||||
|
name: 'good',
|
||||||
|
),
|
||||||
|
AirQualityPercentageData(
|
||||||
|
name: 'moderate',
|
||||||
|
type: AqiType.co2.code,
|
||||||
|
percentage: nonNullValues[1],
|
||||||
|
),
|
||||||
|
AirQualityPercentageData(
|
||||||
|
name: 'poor',
|
||||||
|
percentage: nonNullValues[2],
|
||||||
|
type: AqiType.hcho.code,
|
||||||
|
|
||||||
|
),
|
||||||
|
AirQualityPercentageData(
|
||||||
|
name: 'unhealthy',
|
||||||
|
percentage: nonNullValues[3],
|
||||||
|
type: AqiType.pm10.code,
|
||||||
|
),
|
||||||
|
AirQualityPercentageData(
|
||||||
|
name: 'severe',
|
||||||
|
type: AqiType.pm25.code,
|
||||||
|
percentage: nonNullValues[4],
|
||||||
|
),
|
||||||
|
AirQualityPercentageData(
|
||||||
|
name: 'hazardous',
|
||||||
|
percentage: nonNullValues[5],
|
||||||
|
type: AqiType.co2.code,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<double> _redistributePercentages(
|
||||||
|
List<double> originalValues,
|
||||||
|
List<bool> nullMask,
|
||||||
|
) {
|
||||||
|
double nonNullSum = 0;
|
||||||
|
for (int i = 0; i < originalValues.length; i++) {
|
||||||
|
if (!nullMask[i]) {
|
||||||
|
nonNullSum += originalValues[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return List.generate(originalValues.length, (i) {
|
||||||
|
if (nullMask[i]) return 0;
|
||||||
|
return (originalValues[i] / nonNullSum * 100).roundToDouble();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
bool _shouldBeNull() => _random.nextDouble() < 0.6;
|
||||||
|
|
||||||
|
List<double> _generateRandomPercentages() {
|
||||||
|
final values = List.generate(6, (_) => _random.nextDouble());
|
||||||
|
|
||||||
|
final sum = values.reduce((a, b) => a + b);
|
||||||
|
|
||||||
|
return values.map((value) => (value / sum * 100).roundToDouble()).toList();
|
||||||
|
}
|
||||||
|
}
|
@ -3,8 +3,7 @@ import 'package:syncrow_web/pages/analytics/params/get_air_quality_distribution_
|
|||||||
import 'package:syncrow_web/pages/analytics/services/air_quality_distribution/air_quality_distribution_service.dart';
|
import 'package:syncrow_web/pages/analytics/services/air_quality_distribution/air_quality_distribution_service.dart';
|
||||||
import 'package:syncrow_web/services/api/http_service.dart';
|
import 'package:syncrow_web/services/api/http_service.dart';
|
||||||
|
|
||||||
final class RemoteAirQualityDistributionService
|
class RemoteAirQualityDistributionService implements AirQualityDistributionService {
|
||||||
implements AirQualityDistributionService {
|
|
||||||
RemoteAirQualityDistributionService(this._httpService);
|
RemoteAirQualityDistributionService(this._httpService);
|
||||||
|
|
||||||
final HTTPService _httpService;
|
final HTTPService _httpService;
|
||||||
@ -15,10 +14,10 @@ final class RemoteAirQualityDistributionService
|
|||||||
) async {
|
) async {
|
||||||
try {
|
try {
|
||||||
final response = await _httpService.get(
|
final response = await _httpService.get(
|
||||||
path: '/aqi/distribution/space/${param.spaceUuid}',
|
path: 'endpoint',
|
||||||
queryParameters: {
|
queryParameters: {
|
||||||
'monthDate': _formatDate(param.date),
|
'spaceUuid': param.spaceUuid,
|
||||||
'pollutantType': param.aqiType.code,
|
'date': param.date.toIso8601String(),
|
||||||
},
|
},
|
||||||
expectedResponseModel: (data) {
|
expectedResponseModel: (data) {
|
||||||
final json = data as Map<String, dynamic>? ?? {};
|
final json = data as Map<String, dynamic>? ?? {};
|
||||||
@ -34,8 +33,4 @@ final class RemoteAirQualityDistributionService
|
|||||||
throw Exception('Failed to load energy consumption per phase: $e');
|
throw Exception('Failed to load energy consumption per phase: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static String _formatDate(DateTime date) {
|
|
||||||
return '${date.year}-${date.month.toString().padLeft(2, '0')}';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -26,15 +26,15 @@ class DeviceLocationDetailsServiceDecorator implements DeviceLocationService {
|
|||||||
if (data != null) {
|
if (data != null) {
|
||||||
final addressData = data['address'] as Map<String, dynamic>;
|
final addressData = data['address'] as Map<String, dynamic>;
|
||||||
return deviceLocationInfo.copyWith(
|
return deviceLocationInfo.copyWith(
|
||||||
city: addressData['city'] as String?,
|
city: addressData['city'],
|
||||||
country: addressData['country_code']?.toString().toUpperCase(),
|
country: addressData['country_code'].toString().toUpperCase(),
|
||||||
address: addressData['state'] as String?,
|
address: addressData['state'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return deviceLocationInfo;
|
return deviceLocationInfo;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw Exception('Failed to load device location info: $e');
|
throw Exception('Failed to load device location info: ${e.toString()}');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
import 'package:syncrow_web/pages/analytics/models/range_of_aqi.dart';
|
||||||
|
import 'package:syncrow_web/pages/analytics/modules/air_quality/widgets/aqi_type_dropdown.dart';
|
||||||
|
import 'package:syncrow_web/pages/analytics/params/get_range_of_aqi_param.dart';
|
||||||
|
import 'package:syncrow_web/pages/analytics/services/range_of_aqi/range_of_aqi_service.dart';
|
||||||
|
|
||||||
|
class FakeRangeOfAqiService implements RangeOfAqiService {
|
||||||
|
@override
|
||||||
|
Future<List<RangeOfAqi>> load(GetRangeOfAqiParam param) async {
|
||||||
|
return await Future.delayed(const Duration(milliseconds: 800), () {
|
||||||
|
final random = DateTime.now().millisecondsSinceEpoch;
|
||||||
|
|
||||||
|
return List.generate(30, (index) {
|
||||||
|
final date = DateTime(2025, 5, 1).add(Duration(days: index));
|
||||||
|
|
||||||
|
final min = ((random + index * 17) % 200).toDouble();
|
||||||
|
final avgDelta = ((random + index * 23) % 50).toDouble() + 20;
|
||||||
|
final maxDelta = ((random + index * 31) % 50).toDouble() + 30;
|
||||||
|
|
||||||
|
final avg = (min + avgDelta).clamp(0.0, 301.0);
|
||||||
|
final max = (avg + maxDelta).clamp(0.0, 301.0);
|
||||||
|
|
||||||
|
return RangeOfAqi(
|
||||||
|
data: [
|
||||||
|
RangeOfAqiValue(type: AqiType.aqi.code, min: min, average: avg, max: max),
|
||||||
|
RangeOfAqiValue(type: AqiType.pm25.code, min: min, average: avg, max: max),
|
||||||
|
RangeOfAqiValue(type: AqiType.pm10.code, min: min, average: avg, max: max),
|
||||||
|
RangeOfAqiValue(type: AqiType.hcho.code, min: min, average: avg, max: max),
|
||||||
|
RangeOfAqiValue(type: AqiType.tvoc.code, min: min, average: avg, max: max),
|
||||||
|
RangeOfAqiValue(type: AqiType.co2.code, min: min, average: avg, max: max),
|
||||||
|
],
|
||||||
|
date: date,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -12,8 +12,11 @@ final class RemoteRangeOfAqiService implements RangeOfAqiService {
|
|||||||
Future<List<RangeOfAqi>> load(GetRangeOfAqiParam param) async {
|
Future<List<RangeOfAqi>> load(GetRangeOfAqiParam param) async {
|
||||||
try {
|
try {
|
||||||
final response = await _httpService.get(
|
final response = await _httpService.get(
|
||||||
path: '/aqi/range/space/${param.spaceUuid}',
|
path: 'endpoint',
|
||||||
queryParameters: {'monthDate': _formatDate(param.date)},
|
queryParameters: {
|
||||||
|
'spaceUuid': param.spaceUuid,
|
||||||
|
'date': param.date.toIso8601String(),
|
||||||
|
},
|
||||||
expectedResponseModel: (data) {
|
expectedResponseModel: (data) {
|
||||||
final json = data as Map<String, dynamic>? ?? {};
|
final json = data as Map<String, dynamic>? ?? {};
|
||||||
final mappedData = json['data'] as List<dynamic>? ?? [];
|
final mappedData = json['data'] as List<dynamic>? ?? [];
|
||||||
@ -25,11 +28,7 @@ final class RemoteRangeOfAqiService implements RangeOfAqiService {
|
|||||||
);
|
);
|
||||||
return response;
|
return response;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw Exception('Failed to load range of aqi: $e');
|
throw Exception('Failed to load energy consumption per phase: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static String _formatDate(DateTime date) {
|
|
||||||
return '${date.year}-${date.month.toString().padLeft(2, '0')}';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -50,11 +50,20 @@ class _DynamicTableState extends State<DynamicTable> {
|
|||||||
bool _selectAll = false;
|
bool _selectAll = false;
|
||||||
final ScrollController _verticalScrollController = ScrollController();
|
final ScrollController _verticalScrollController = ScrollController();
|
||||||
final ScrollController _horizontalScrollController = ScrollController();
|
final ScrollController _horizontalScrollController = ScrollController();
|
||||||
|
late ScrollController _horizontalHeaderScrollController;
|
||||||
|
late ScrollController _horizontalBodyScrollController;
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_initializeSelection();
|
_initializeSelection();
|
||||||
|
_horizontalHeaderScrollController = ScrollController();
|
||||||
|
_horizontalBodyScrollController = ScrollController();
|
||||||
|
|
||||||
|
// Synchronize horizontal scrolling
|
||||||
|
_horizontalBodyScrollController.addListener(() {
|
||||||
|
_horizontalHeaderScrollController
|
||||||
|
.jumpTo(_horizontalBodyScrollController.offset);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -104,58 +113,70 @@ class _DynamicTableState extends State<DynamicTable> {
|
|||||||
context.read<DeviceManagementBloc>().add(UpdateSelection(_selectedRows));
|
context.read<DeviceManagementBloc>().add(UpdateSelection(_selectedRows));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_horizontalHeaderScrollController.dispose();
|
||||||
|
_horizontalBodyScrollController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
decoration: widget.cellDecoration,
|
decoration: widget.cellDecoration,
|
||||||
child: Scrollbar(
|
|
||||||
controller: _verticalScrollController,
|
|
||||||
thumbVisibility: true,
|
|
||||||
trackVisibility: true,
|
|
||||||
child: Scrollbar(
|
|
||||||
//fixed the horizontal scrollbar issue
|
|
||||||
controller: _horizontalScrollController,
|
|
||||||
thumbVisibility: true,
|
|
||||||
trackVisibility: true,
|
|
||||||
notificationPredicate: (notif) => notif.depth == 1,
|
|
||||||
child: SingleChildScrollView(
|
|
||||||
controller: _verticalScrollController,
|
|
||||||
child: SingleChildScrollView(
|
|
||||||
controller: _horizontalScrollController,
|
|
||||||
scrollDirection: Axis.horizontal,
|
|
||||||
child: SizedBox(
|
|
||||||
width: widget.size.width,
|
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
decoration: widget.headerDecoration ??
|
decoration: widget.headerDecoration ??
|
||||||
const BoxDecoration(
|
const BoxDecoration(color: ColorsManager.boxColor),
|
||||||
color: ColorsManager.boxColor,
|
child: SingleChildScrollView(
|
||||||
),
|
scrollDirection: Axis.horizontal,
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
controller: _horizontalHeaderScrollController,
|
||||||
|
child: SizedBox(
|
||||||
|
width: widget.size.width,
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
if (widget.withCheckBox) _buildSelectAllCheckbox(),
|
if (widget.withCheckBox) _buildSelectAllCheckbox(),
|
||||||
...List.generate(widget.headers.length, (index) {
|
...List.generate(widget.headers.length, (index) {
|
||||||
return _buildTableHeaderCell(
|
return _buildTableHeaderCell(
|
||||||
widget.headers[index], index);
|
widget.headers[index], index);
|
||||||
})
|
}),
|
||||||
//...widget.headers.map((header) => _buildTableHeaderCell(header)),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Scrollbar(
|
||||||
|
controller: _verticalScrollController,
|
||||||
|
thumbVisibility: true,
|
||||||
|
trackVisibility: true,
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
controller: _verticalScrollController,
|
||||||
|
child: Scrollbar(
|
||||||
|
controller: _horizontalBodyScrollController,
|
||||||
|
thumbVisibility: false,
|
||||||
|
trackVisibility: false,
|
||||||
|
notificationPredicate: (notif) => notif.depth == 1,
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
controller: _horizontalBodyScrollController,
|
||||||
|
child: Container(
|
||||||
|
color: ColorsManager.whiteColors,
|
||||||
|
child: SizedBox(
|
||||||
width: widget.size.width,
|
width: widget.size.width,
|
||||||
child: widget.isEmpty
|
child: widget.isEmpty
|
||||||
? _buildEmptyState()
|
? _buildEmptyState()
|
||||||
: Column(
|
: Column(
|
||||||
children:
|
children: List.generate(widget.data.length,
|
||||||
List.generate(widget.data.length, (rowIndex) {
|
(rowIndex) {
|
||||||
final row = widget.data[rowIndex];
|
final row = widget.data[rowIndex];
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
if (widget.withCheckBox)
|
if (widget.withCheckBox)
|
||||||
_buildRowCheckbox(
|
_buildRowCheckbox(rowIndex,
|
||||||
rowIndex, widget.size.height * 0.08),
|
widget.size.height * 0.08),
|
||||||
...row.asMap().entries.map((entry) {
|
...row.asMap().entries.map((entry) {
|
||||||
return _buildTableCell(
|
return _buildTableCell(
|
||||||
entry.value.toString(),
|
entry.value.toString(),
|
||||||
@ -169,12 +190,30 @@ class _DynamicTableState extends State<DynamicTable> {
|
|||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildSelectAllCheckbox() {
|
||||||
|
return Container(
|
||||||
|
width: 50,
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
border: Border.symmetric(
|
||||||
|
vertical: BorderSide(color: ColorsManager.boxDivider),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
child: Checkbox(
|
||||||
),
|
value: _selectAll,
|
||||||
|
onChanged: widget.withSelectAll && widget.data.isNotEmpty
|
||||||
|
? _toggleSelectAll
|
||||||
|
: null,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -205,23 +244,6 @@ class _DynamicTableState extends State<DynamicTable> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
Widget _buildSelectAllCheckbox() {
|
|
||||||
return Container(
|
|
||||||
width: 50,
|
|
||||||
decoration: const BoxDecoration(
|
|
||||||
border: Border.symmetric(
|
|
||||||
vertical: BorderSide(color: ColorsManager.boxDivider),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Checkbox(
|
|
||||||
value: _selectAll,
|
|
||||||
onChanged: widget.withSelectAll && widget.data.isNotEmpty
|
|
||||||
? _toggleSelectAll
|
|
||||||
: null,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildRowCheckbox(int index, double size) {
|
Widget _buildRowCheckbox(int index, double size) {
|
||||||
return Container(
|
return Container(
|
||||||
width: 50,
|
width: 50,
|
||||||
@ -276,8 +298,12 @@ class _DynamicTableState extends State<DynamicTable> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildTableCell(String content, double size,
|
Widget _buildTableCell(
|
||||||
{required int rowIndex, required int columnIndex}) {
|
String content,
|
||||||
|
double size, {
|
||||||
|
required int rowIndex,
|
||||||
|
required int columnIndex,
|
||||||
|
}) {
|
||||||
bool isBatteryLevel = content.endsWith('%');
|
bool isBatteryLevel = content.endsWith('%');
|
||||||
double? batteryLevel;
|
double? batteryLevel;
|
||||||
|
|
||||||
@ -285,6 +311,7 @@ class _DynamicTableState extends State<DynamicTable> {
|
|||||||
batteryLevel = double.tryParse(content.replaceAll('%', '').trim());
|
batteryLevel = double.tryParse(content.replaceAll('%', '').trim());
|
||||||
}
|
}
|
||||||
bool isSettingsColumn = widget.headers[columnIndex] == 'Settings';
|
bool isSettingsColumn = widget.headers[columnIndex] == 'Settings';
|
||||||
|
|
||||||
if (isSettingsColumn) {
|
if (isSettingsColumn) {
|
||||||
return buildSettingsIcon(
|
return buildSettingsIcon(
|
||||||
width: 120,
|
width: 120,
|
||||||
@ -389,10 +416,11 @@ class _DynamicTableState extends State<DynamicTable> {
|
|||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: SvgPicture.asset(
|
child: SvgPicture.asset(
|
||||||
Assets.settings,
|
Assets.settings, // ضع المسار الصحيح هنا
|
||||||
width: 40,
|
width: 40,
|
||||||
height: 22,
|
height: 22,
|
||||||
color: ColorsManager.primaryColor,
|
color: ColorsManager
|
||||||
|
.primaryColor, // نفس لون الأيقونة في الصورة
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -43,15 +43,14 @@ class DeviceManagementBloc
|
|||||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||||
|
|
||||||
if (spaceBloc.state.selectedCommunities.isEmpty) {
|
if (spaceBloc.state.selectedCommunities.isEmpty) {
|
||||||
devices =
|
devices = await DevicesManagementApi().fetchDevices('', '', projectUuid);
|
||||||
await DevicesManagementApi().fetchDevices('', '', projectUuid);
|
|
||||||
} else {
|
} else {
|
||||||
for (var community in spaceBloc.state.selectedCommunities) {
|
for (var community in spaceBloc.state.selectedCommunities) {
|
||||||
List<String> spacesList =
|
List<String> spacesList =
|
||||||
spaceBloc.state.selectedCommunityAndSpaces[community] ?? [];
|
spaceBloc.state.selectedCommunityAndSpaces[community] ?? [];
|
||||||
for (var space in spacesList) {
|
for (var space in spacesList) {
|
||||||
devices.addAll(await DevicesManagementApi()
|
devices.addAll(await DevicesManagementApi().fetchDevices(
|
||||||
.fetchDevices(community, space, projectUuid));
|
community, space, projectUuid));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,7 +100,7 @@ class DeviceManagementBloc
|
|||||||
));
|
));
|
||||||
|
|
||||||
if (currentProductName.isNotEmpty) {
|
if (currentProductName.isNotEmpty) {
|
||||||
add(SearchDevices(deviceNameOrProductName: currentProductName));
|
add(SearchDevices(productName: currentProductName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -270,41 +269,34 @@ class DeviceManagementBloc
|
|||||||
return 'All';
|
return 'All';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onSearchDevices(
|
void _onSearchDevices(
|
||||||
SearchDevices event, Emitter<DeviceManagementState> emit) {
|
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.deviceNameOrProductName == null ||
|
(event.productName == null || event.productName!.isEmpty)) {
|
||||||
event.deviceNameOrProductName!.isEmpty)) {
|
|
||||||
currentProductName = '';
|
currentProductName = '';
|
||||||
_filteredDevices = List.from(_devices);
|
if (state is DeviceManagementFiltered) {
|
||||||
emit(DeviceManagementLoaded(
|
add(FilterDevices(_getFilterFromIndex(_selectedIndex)));
|
||||||
devices: _devices,
|
} else {
|
||||||
selectedIndex: _selectedIndex,
|
|
||||||
onlineCount: _onlineCount,
|
|
||||||
offlineCount: _offlineCount,
|
|
||||||
lowBatteryCount: _lowBatteryCount,
|
|
||||||
selectedDevice: null,
|
|
||||||
isControlButtonEnabled: false,
|
|
||||||
));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.deviceNameOrProductName == currentProductName &&
|
}
|
||||||
|
|
||||||
|
if (event.productName == currentProductName &&
|
||||||
event.community == currentCommunity &&
|
event.community == currentCommunity &&
|
||||||
event.unitName == currentUnitName &&
|
event.unitName == currentUnitName &&
|
||||||
event.searchField) {
|
event.searchField) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentProductName = event.deviceNameOrProductName ?? '';
|
currentProductName = event.productName ?? '';
|
||||||
currentCommunity = event.community;
|
currentCommunity = event.community;
|
||||||
currentUnitName = event.unitName;
|
currentUnitName = event.unitName;
|
||||||
|
|
||||||
List<AllDevicesModel> devicesToSearch = _devices;
|
List<AllDevicesModel> devicesToSearch = _filteredDevices;
|
||||||
|
|
||||||
if (devicesToSearch.isNotEmpty) {
|
if (devicesToSearch.isNotEmpty) {
|
||||||
final searchText = event.deviceNameOrProductName?.toLowerCase() ?? '';
|
|
||||||
|
|
||||||
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 ||
|
||||||
@ -312,25 +304,31 @@ class DeviceManagementBloc
|
|||||||
?.toLowerCase()
|
?.toLowerCase()
|
||||||
.contains(event.community!.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!.any((space) =>
|
device.spaces!.isNotEmpty &&
|
||||||
space.spaceName != null &&
|
device.spaces![0].spaceName!
|
||||||
space.spaceName!
|
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.contains(event.unitName!.toLowerCase())));
|
.contains(event.unitName!.toLowerCase()));
|
||||||
|
final matchesProductName = event.productName == null ||
|
||||||
|
event.productName!.isEmpty ||
|
||||||
|
(device.name
|
||||||
|
?.toLowerCase()
|
||||||
|
.contains(event.productName!.toLowerCase()) ??
|
||||||
|
false);
|
||||||
|
final matchesDeviceName = event.productName == null ||
|
||||||
|
event.productName!.isEmpty ||
|
||||||
|
(device.categoryName
|
||||||
|
?.toLowerCase()
|
||||||
|
.contains(event.productName!.toLowerCase()) ??
|
||||||
|
false);
|
||||||
|
|
||||||
final matchesSearchText = searchText.isEmpty ||
|
return matchesCommunity &&
|
||||||
(device.name?.toLowerCase().contains(searchText) ?? false) ||
|
matchesUnit &&
|
||||||
(device.productName?.toLowerCase().contains(searchText) ?? false);
|
(matchesProductName || matchesDeviceName);
|
||||||
|
|
||||||
return matchesCommunity && matchesUnit && matchesSearchText;
|
|
||||||
}).toList();
|
}).toList();
|
||||||
|
|
||||||
_filteredDevices = filteredDevices;
|
|
||||||
|
|
||||||
emit(DeviceManagementFiltered(
|
emit(DeviceManagementFiltered(
|
||||||
filteredDevices: filteredDevices,
|
filteredDevices: filteredDevices,
|
||||||
selectedIndex: _selectedIndex,
|
selectedIndex: _selectedIndex,
|
||||||
|
@ -38,18 +38,18 @@ class SelectedFilterChanged extends DeviceManagementEvent {
|
|||||||
class SearchDevices extends DeviceManagementEvent {
|
class SearchDevices extends DeviceManagementEvent {
|
||||||
final String? community;
|
final String? community;
|
||||||
final String? unitName;
|
final String? unitName;
|
||||||
final String? deviceNameOrProductName;
|
final String? productName;
|
||||||
final bool searchField;
|
final bool searchField;
|
||||||
|
|
||||||
const SearchDevices({
|
const SearchDevices({
|
||||||
this.community,
|
this.community,
|
||||||
this.unitName,
|
this.unitName,
|
||||||
this.deviceNameOrProductName,
|
this.productName,
|
||||||
this.searchField = false,
|
this.searchField = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object?> get props => [community, unitName, deviceNameOrProductName];
|
List<Object?> get props => [community, unitName, productName];
|
||||||
}
|
}
|
||||||
|
|
||||||
class SelectDevice extends DeviceManagementEvent {
|
class SelectDevice extends DeviceManagementEvent {
|
||||||
|
@ -6,7 +6,6 @@ import 'package:syncrow_web/pages/device_managment/all_devices/models/device_tag
|
|||||||
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/routines/models/ac/ac_function.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/curtain/curtain_function.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/flush/flush_functions.dart';
|
import 'package:syncrow_web/pages/routines/models/flush/flush_functions.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/gang_switches/one_gang_switch/one_gang_switch.dart';
|
import 'package:syncrow_web/pages/routines/models/gang_switches/one_gang_switch/one_gang_switch.dart';
|
||||||
@ -360,14 +359,6 @@ SOS
|
|||||||
uuid: uuid ?? '',
|
uuid: uuid ?? '',
|
||||||
name: name ?? '',
|
name: name ?? '',
|
||||||
);
|
);
|
||||||
case 'CUR':
|
|
||||||
return [
|
|
||||||
ControlCurtainFunction(
|
|
||||||
deviceId: uuid ?? '',
|
|
||||||
deviceName: name ?? '',
|
|
||||||
type: 'BOTH',
|
|
||||||
)
|
|
||||||
];
|
|
||||||
case 'NCPS':
|
case 'NCPS':
|
||||||
return [
|
return [
|
||||||
FlushPresenceDelayFunction(
|
FlushPresenceDelayFunction(
|
||||||
@ -450,10 +441,15 @@ SOS
|
|||||||
VoltageCStatusFunction(
|
VoltageCStatusFunction(
|
||||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||||
CurrentCStatusFunction(
|
CurrentCStatusFunction(
|
||||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
deviceId: uuid ?? '',
|
||||||
|
deviceName: name ?? '',
|
||||||
|
type: 'IF'),
|
||||||
PowerFactorCStatusFunction(
|
PowerFactorCStatusFunction(
|
||||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
deviceId: uuid ?? '',
|
||||||
|
deviceName: name ?? '',
|
||||||
|
type: 'IF'),
|
||||||
];
|
];
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
@ -8,28 +8,15 @@ import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routi
|
|||||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_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/view/create_new_routine_view.dart';
|
||||||
import 'package:syncrow_web/pages/routines/view/routines_view.dart';
|
import 'package:syncrow_web/pages/routines/view/routines_view.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/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';
|
||||||
import 'package:syncrow_web/utils/theme/responsive_text_theme.dart';
|
import 'package:syncrow_web/utils/theme/responsive_text_theme.dart';
|
||||||
import 'package:syncrow_web/web_layout/web_scaffold.dart';
|
import 'package:syncrow_web/web_layout/web_scaffold.dart';
|
||||||
|
|
||||||
class DeviceManagementPage extends StatefulWidget with HelperResponsiveLayout {
|
class DeviceManagementPage extends StatelessWidget with HelperResponsiveLayout {
|
||||||
const DeviceManagementPage({super.key});
|
const DeviceManagementPage({super.key});
|
||||||
|
|
||||||
@override
|
|
||||||
State<DeviceManagementPage> createState() => _DeviceManagementPageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _DeviceManagementPageState extends State<DeviceManagementPage> {
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
context.read<SpaceTreeBloc>().add(InitialEvent());
|
|
||||||
super.initState();
|
|
||||||
}
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MultiBlocProvider(
|
return MultiBlocProvider(
|
||||||
|
@ -53,7 +53,7 @@ class _DeviceSearchFiltersState extends State<DeviceSearchFilters>
|
|||||||
controller: controller,
|
controller: controller,
|
||||||
onSubmitted: () {
|
onSubmitted: () {
|
||||||
final searchDevicesEvent = SearchDevices(
|
final searchDevicesEvent = SearchDevices(
|
||||||
deviceNameOrProductName: _productNameController.text,
|
productName: _productNameController.text,
|
||||||
unitName: _unitNameController.text,
|
unitName: _unitNameController.text,
|
||||||
searchField: true,
|
searchField: true,
|
||||||
);
|
);
|
||||||
@ -68,7 +68,7 @@ class _DeviceSearchFiltersState extends State<DeviceSearchFilters>
|
|||||||
onSearch: () => context.read<DeviceManagementBloc>().add(
|
onSearch: () => context.read<DeviceManagementBloc>().add(
|
||||||
SearchDevices(
|
SearchDevices(
|
||||||
unitName: _unitNameController.text,
|
unitName: _unitNameController.text,
|
||||||
deviceNameOrProductName: _productNameController.text,
|
productName: _productNameController.text,
|
||||||
searchField: true,
|
searchField: true,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.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/device_managment/all_devices/bloc/device_mgmt_bloc/device_managment_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/device_managment/device_setting/bloc/setting_bloc_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/device_managment/device_setting/settings_model/device_info_model.dart';
|
import 'package:syncrow_web/pages/device_managment/device_setting/settings_model/device_info_model.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/device_setting/settings_model/sub_space_model.dart';
|
import 'package:syncrow_web/pages/device_managment/device_setting/settings_model/sub_space_model.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/device_setting/sub_space_dialog.dart';
|
import 'package:syncrow_web/pages/device_managment/device_setting/sub_space_dialog.dart';
|
||||||
@ -69,25 +66,14 @@ class DeviceManagementContent extends StatelessWidget {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(10.0),
|
padding: const EdgeInsets.all(10.0),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () async {
|
onTap: () {
|
||||||
final selectedSubSpace = await showSubSpaceDialog(
|
showSubSpaceDialog(
|
||||||
context,
|
context,
|
||||||
communityUuid: device.community!.uuid!,
|
communityUuid: device.community!.uuid!,
|
||||||
spaceUuid: device.spaces!.first.uuid!,
|
spaceUuid: device.spaces!.first.uuid!,
|
||||||
subSpaces: subSpaces,
|
subSpaces: subSpaces,
|
||||||
selected: deviceInfo.subspace.uuid,
|
selected: device.subspace!.uuid,
|
||||||
);
|
);
|
||||||
if (selectedSubSpace != null) {
|
|
||||||
Future.delayed(const Duration(milliseconds: 500), () {
|
|
||||||
context.read<SettingDeviceBloc>().add(
|
|
||||||
SettingBlocAssignRoom(
|
|
||||||
communityUuid: device.community!.uuid!,
|
|
||||||
spaceUuid: device.spaces!.first.uuid!,
|
|
||||||
subSpaceUuid: selectedSubSpace.id ?? '',
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
child: infoRow(
|
child: infoRow(
|
||||||
label: 'Sub-Space:',
|
label: 'Sub-Space:',
|
||||||
|
@ -9,11 +9,13 @@ import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
|||||||
class SubSpaceDialog extends StatefulWidget {
|
class SubSpaceDialog extends StatefulWidget {
|
||||||
final List<SubSpaceModel> subSpaces;
|
final List<SubSpaceModel> subSpaces;
|
||||||
final String? selected;
|
final String? selected;
|
||||||
|
final void Function(SubSpaceModel?) onConfirmed;
|
||||||
|
|
||||||
const SubSpaceDialog({
|
const SubSpaceDialog({
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.subSpaces,
|
required this.subSpaces,
|
||||||
this.selected,
|
this.selected,
|
||||||
|
required this.onConfirmed,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -84,21 +86,30 @@ class _SubSpaceDialogState extends State<SubSpaceDialog> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<SubSpaceModel?> showSubSpaceDialog(
|
void showSubSpaceDialog(
|
||||||
BuildContext context, {
|
BuildContext context, {
|
||||||
required List<SubSpaceModel> subSpaces,
|
required List<SubSpaceModel> subSpaces,
|
||||||
String? selected,
|
String? selected,
|
||||||
required String communityUuid,
|
required String communityUuid,
|
||||||
required String spaceUuid,
|
required String spaceUuid,
|
||||||
}) {
|
}) {
|
||||||
return showDialog<SubSpaceModel>(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (ctx) => BlocProvider.value(
|
barrierDismissible: true,
|
||||||
value: BlocProvider.of<SettingDeviceBloc>(context),
|
builder: (ctx) => SubSpaceDialog(
|
||||||
child: SubSpaceDialog(
|
|
||||||
subSpaces: subSpaces,
|
subSpaces: subSpaces,
|
||||||
selected: selected,
|
selected: selected,
|
||||||
|
onConfirmed: (selectedModel) {
|
||||||
|
if (selectedModel != null) {
|
||||||
|
context.read<SettingDeviceBloc>().add(
|
||||||
|
SettingBlocAssignRoom(
|
||||||
|
communityUuid: communityUuid,
|
||||||
|
spaceUuid: spaceUuid,
|
||||||
|
subSpaceUuid: selectedModel.id ?? '',
|
||||||
),
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/device_managment/device_setting/bloc/setting_bloc_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/device_setting/settings_model/sub_space_model.dart';
|
import 'package:syncrow_web/pages/device_managment/device_setting/settings_model/sub_space_model.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/device_setting/sub_space_dialog.dart';
|
import 'package:syncrow_web/pages/device_managment/device_setting/sub_space_dialog.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
@ -62,10 +64,9 @@ class SubSpaceDialogButtons extends StatelessWidget {
|
|||||||
final selectedModel = widget.subSpaces.firstWhere(
|
final selectedModel = widget.subSpaces.firstWhere(
|
||||||
(space) => space.id == _selectedId,
|
(space) => space.id == _selectedId,
|
||||||
orElse: () =>
|
orElse: () =>
|
||||||
SubSpaceModel(id: null, name: '', devices: []),
|
SubSpaceModel(id: null, name: '', devices: []));
|
||||||
);
|
widget.onConfirmed(selectedModel);
|
||||||
Navigator.of(context)
|
Navigator.of(context).pop();
|
||||||
.pop(selectedModel);
|
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
'Confirm',
|
'Confirm',
|
||||||
@ -83,3 +84,31 @@ class SubSpaceDialogButtons extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void showSubSpaceDialog(
|
||||||
|
BuildContext context, {
|
||||||
|
required List<SubSpaceModel> subSpaces,
|
||||||
|
String? selected,
|
||||||
|
required String communityUuid,
|
||||||
|
required String spaceUuid,
|
||||||
|
}) {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
barrierDismissible: true,
|
||||||
|
builder: (ctx) => SubSpaceDialog(
|
||||||
|
subSpaces: subSpaces,
|
||||||
|
selected: selected,
|
||||||
|
onConfirmed: (selectedModel) {
|
||||||
|
if (selectedModel != null) {
|
||||||
|
context.read<SettingDeviceBloc>().add(
|
||||||
|
SettingBlocAssignRoom(
|
||||||
|
communityUuid: communityUuid,
|
||||||
|
spaceUuid: spaceUuid,
|
||||||
|
subSpaceUuid: selectedModel.id ?? '',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
// ignore_for_file: invalid_use_of_visible_for_testing_member
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:firebase_database/firebase_database.dart';
|
import 'package:firebase_database/firebase_database.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
@ -14,38 +16,45 @@ class DoorLockBloc extends Bloc<DoorLockEvent, DoorLockState> {
|
|||||||
|
|
||||||
DoorLockBloc({required this.deviceId}) : super(DoorLockInitial()) {
|
DoorLockBloc({required this.deviceId}) : super(DoorLockInitial()) {
|
||||||
on<DoorLockFetchStatus>(_onFetchDeviceStatus);
|
on<DoorLockFetchStatus>(_onFetchDeviceStatus);
|
||||||
|
//on<DoorLockControl>(_onDoorLockControl);
|
||||||
on<UpdateLockEvent>(_updateLock);
|
on<UpdateLockEvent>(_updateLock);
|
||||||
on<DoorLockFactoryReset>(_onFactoryReset);
|
on<DoorLockFactoryReset>(_onFactoryReset);
|
||||||
on<StatusUpdated>(_onStatusUpdated);
|
on<StatusUpdated>(_onStatusUpdated);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _listenToChanges(String deviceId) {
|
_listenToChanges(deviceId) {
|
||||||
try {
|
try {
|
||||||
final ref = FirebaseDatabase.instance.ref('device-status/$deviceId');
|
DatabaseReference ref =
|
||||||
ref.onValue.listen((event) {
|
FirebaseDatabase.instance.ref('device-status/$deviceId');
|
||||||
final data = event.snapshot.value;
|
Stream<DatabaseEvent> stream = ref.onValue;
|
||||||
if (data is Map) {
|
|
||||||
final statusData = data['status'] as List<dynamic>? ?? [];
|
|
||||||
final statusList = statusData.map((item) {
|
|
||||||
return Status(code: item['code'], value: item['value']);
|
|
||||||
}).toList();
|
|
||||||
|
|
||||||
final model =
|
stream.listen((DatabaseEvent event) {
|
||||||
DoorLockStatusModel.fromJson(data['productUuid'], statusList);
|
Map<dynamic, dynamic> usersMap =
|
||||||
|
event.snapshot.value as Map<dynamic, dynamic>;
|
||||||
|
|
||||||
|
List<Status> statusList = [];
|
||||||
|
usersMap['status'].forEach((element) {
|
||||||
|
statusList
|
||||||
|
.add(Status(code: element['code'], value: element['value']));
|
||||||
|
});
|
||||||
|
|
||||||
|
deviceStatus =
|
||||||
|
DoorLockStatusModel.fromJson(usersMap['productUuid'], statusList);
|
||||||
if (!isClosed) {
|
if (!isClosed) {
|
||||||
add(StatusUpdated(model));
|
add(StatusUpdated(deviceStatus));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onStatusUpdated(StatusUpdated event, Emitter<DoorLockState> emit) {
|
void _onStatusUpdated(StatusUpdated event, Emitter<DoorLockState> emit) {
|
||||||
|
emit(DoorLockStatusLoading());
|
||||||
|
|
||||||
deviceStatus = event.deviceStatus;
|
deviceStatus = event.deviceStatus;
|
||||||
emit(DoorLockStatusLoaded(deviceStatus));
|
emit(DoorLockStatusLoaded(deviceStatus));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onFetchDeviceStatus(
|
FutureOr<void> _onFetchDeviceStatus(
|
||||||
DoorLockFetchStatus event, Emitter<DoorLockState> emit) async {
|
DoorLockFetchStatus event, Emitter<DoorLockState> emit) async {
|
||||||
emit(DoorLockStatusLoading());
|
emit(DoorLockStatusLoading());
|
||||||
try {
|
try {
|
||||||
@ -54,13 +63,14 @@ class DoorLockBloc extends Bloc<DoorLockEvent, DoorLockState> {
|
|||||||
deviceStatus =
|
deviceStatus =
|
||||||
DoorLockStatusModel.fromJson(event.deviceId, status.status);
|
DoorLockStatusModel.fromJson(event.deviceId, status.status);
|
||||||
_listenToChanges(event.deviceId);
|
_listenToChanges(event.deviceId);
|
||||||
|
|
||||||
emit(DoorLockStatusLoaded(deviceStatus));
|
emit(DoorLockStatusLoaded(deviceStatus));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(DoorLockControlError(e.toString()));
|
emit(DoorLockControlError(e.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _updateLock(
|
FutureOr<void> _updateLock(
|
||||||
UpdateLockEvent event, Emitter<DoorLockState> emit) async {
|
UpdateLockEvent event, Emitter<DoorLockState> emit) async {
|
||||||
final oldValue = deviceStatus.normalOpenSwitch;
|
final oldValue = deviceStatus.normalOpenSwitch;
|
||||||
deviceStatus = deviceStatus.copyWith(normalOpenSwitch: !oldValue);
|
deviceStatus = deviceStatus.copyWith(normalOpenSwitch: !oldValue);
|
||||||
@ -68,6 +78,7 @@ class DoorLockBloc extends Bloc<DoorLockEvent, DoorLockState> {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
final response = await DevicesManagementApi.openDoorLock(deviceId);
|
final response = await DevicesManagementApi.openDoorLock(deviceId);
|
||||||
|
|
||||||
if (!response) {
|
if (!response) {
|
||||||
_revertValueAndEmit(deviceId, 'normal_open_switch', oldValue, emit);
|
_revertValueAndEmit(deviceId, 'normal_open_switch', oldValue, emit);
|
||||||
}
|
}
|
||||||
@ -77,8 +88,35 @@ class DoorLockBloc extends Bloc<DoorLockEvent, DoorLockState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _revertValueAndEmit(String deviceId, String code, dynamic oldValue,
|
Future<void> _runDebounce({
|
||||||
Emitter<DoorLockState> emit) {
|
required String deviceId,
|
||||||
|
required String code,
|
||||||
|
required dynamic value,
|
||||||
|
required dynamic oldValue,
|
||||||
|
required Emitter<DoorLockState> emit,
|
||||||
|
}) async {
|
||||||
|
if (_timer != null) {
|
||||||
|
_timer!.cancel();
|
||||||
|
}
|
||||||
|
_timer = Timer(const Duration(seconds: 1), () async {
|
||||||
|
try {
|
||||||
|
final response = await DevicesManagementApi()
|
||||||
|
.deviceControl(deviceId, Status(code: code, value: value));
|
||||||
|
if (!response) {
|
||||||
|
_revertValueAndEmit(deviceId, code, oldValue, emit);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_revertValueAndEmit(deviceId, code, oldValue, emit);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _revertValueAndEmit(
|
||||||
|
String deviceId,
|
||||||
|
String code,
|
||||||
|
dynamic oldValue,
|
||||||
|
Emitter<DoorLockState> emit,
|
||||||
|
) {
|
||||||
_updateLocalValue(code, oldValue);
|
_updateLocalValue(code, oldValue);
|
||||||
emit(DoorLockStatusLoaded(deviceStatus));
|
emit(DoorLockStatusLoaded(deviceStatus));
|
||||||
emit(const DoorLockControlError('Failed to control the device.'));
|
emit(const DoorLockControlError('Failed to control the device.'));
|
||||||
@ -86,23 +124,34 @@ class DoorLockBloc extends Bloc<DoorLockEvent, DoorLockState> {
|
|||||||
|
|
||||||
void _updateLocalValue(String code, dynamic value) {
|
void _updateLocalValue(String code, dynamic value) {
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case 'normal_open_switch':
|
|
||||||
if (value is bool) {
|
|
||||||
deviceStatus = deviceStatus.copyWith(normalOpenSwitch: value);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'reverse_lock':
|
case 'reverse_lock':
|
||||||
if (value is bool) {
|
if (value is bool) {
|
||||||
deviceStatus = deviceStatus.copyWith(reverseLock: value);
|
deviceStatus = deviceStatus.copyWith(reverseLock: value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'normal_open_switch':
|
||||||
|
if (value is bool) {
|
||||||
|
deviceStatus = deviceStatus.copyWith(normalOpenSwitch: value);
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
emit(DoorLockStatusLoaded(deviceStatus));
|
emit(DoorLockStatusLoaded(deviceStatus));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onFactoryReset(
|
dynamic _getValueByCode(String code) {
|
||||||
|
switch (code) {
|
||||||
|
case 'reverse_lock':
|
||||||
|
return deviceStatus.reverseLock;
|
||||||
|
case 'normal_open_switch':
|
||||||
|
return deviceStatus.normalOpenSwitch;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FutureOr<void> _onFactoryReset(
|
||||||
DoorLockFactoryReset event, Emitter<DoorLockState> emit) async {
|
DoorLockFactoryReset event, Emitter<DoorLockState> emit) async {
|
||||||
emit(DoorLockStatusLoading());
|
emit(DoorLockStatusLoading());
|
||||||
try {
|
try {
|
||||||
|
@ -8,7 +8,7 @@ import 'package:syncrow_web/pages/device_managment/door_lock/models/door_lock_st
|
|||||||
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';
|
||||||
|
|
||||||
class DoorLockButton extends StatelessWidget {
|
class DoorLockButton extends StatefulWidget {
|
||||||
const DoorLockButton({
|
const DoorLockButton({
|
||||||
super.key,
|
super.key,
|
||||||
required this.doorLock,
|
required this.doorLock,
|
||||||
@ -18,28 +18,70 @@ class DoorLockButton extends StatelessWidget {
|
|||||||
final AllDevicesModel doorLock;
|
final AllDevicesModel doorLock;
|
||||||
final DoorLockStatusModel smartDoorModel;
|
final DoorLockStatusModel smartDoorModel;
|
||||||
|
|
||||||
double _calculateProgress() {
|
@override
|
||||||
final value = smartDoorModel.unlockRequest;
|
State<DoorLockButton> createState() =>
|
||||||
if (value <= 0 || value > 30) return 0;
|
_DoorLockButtonState(smartDoorModel: smartDoorModel);
|
||||||
return value / 30.0;
|
}
|
||||||
|
|
||||||
|
class _DoorLockButtonState extends State<DoorLockButton>
|
||||||
|
with SingleTickerProviderStateMixin {
|
||||||
|
late AnimationController _animationController;
|
||||||
|
late Animation<double> _animation;
|
||||||
|
DoorLockStatusModel smartDoorModel;
|
||||||
|
|
||||||
|
_DoorLockButtonState({required this.smartDoorModel});
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_animationController = AnimationController(
|
||||||
|
vsync: this,
|
||||||
|
duration: const Duration(milliseconds: 500),
|
||||||
|
);
|
||||||
|
_animation = Tween<double>(begin: 0, end: 1).animate(_animationController)
|
||||||
|
..addListener(() {
|
||||||
|
setState(() {});
|
||||||
|
});
|
||||||
|
|
||||||
|
if (smartDoorModel.unlockRequest > 0) {
|
||||||
|
_animationController.reverse(from: 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didUpdateWidget(covariant DoorLockButton oldWidget) {
|
||||||
|
super.didUpdateWidget(oldWidget);
|
||||||
|
if (oldWidget.smartDoorModel.normalOpenSwitch !=
|
||||||
|
widget.smartDoorModel.normalOpenSwitch) {
|
||||||
|
setState(() {
|
||||||
|
smartDoorModel = widget.smartDoorModel;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (smartDoorModel.unlockRequest > 0) {
|
||||||
|
_animationController.forward(from: 0);
|
||||||
|
} else {
|
||||||
|
_animationController.reverse(from: 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_animationController.dispose();
|
||||||
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final progress = _calculateProgress();
|
|
||||||
final isEnabled = smartDoorModel.unlockRequest > 0;
|
|
||||||
|
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
width: 255,
|
width: 255,
|
||||||
height: 255,
|
height: 255,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: isEnabled
|
onTap: () {
|
||||||
? () {
|
_animationController.forward(from: 0);
|
||||||
BlocProvider.of<DoorLockBloc>(context).add(
|
BlocProvider.of<DoorLockBloc>(context)
|
||||||
UpdateLockEvent(value: !smartDoorModel.normalOpenSwitch),
|
.add(UpdateLockEvent(value: !smartDoorModel.normalOpenSwitch));
|
||||||
);
|
},
|
||||||
}
|
|
||||||
: null,
|
|
||||||
child: Container(
|
child: Container(
|
||||||
width: 255,
|
width: 255,
|
||||||
height: 255,
|
height: 255,
|
||||||
@ -73,10 +115,9 @@ class DoorLockButton extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (progress > 0)
|
|
||||||
SizedBox.expand(
|
SizedBox.expand(
|
||||||
child: CircularProgressIndicator(
|
child: CircularProgressIndicator(
|
||||||
value: progress,
|
value: _animation.value,
|
||||||
strokeWidth: 8,
|
strokeWidth: 8,
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
valueColor: const AlwaysStoppedAnimation<Color>(
|
valueColor: const AlwaysStoppedAnimation<Color>(
|
||||||
|
@ -13,32 +13,30 @@ import 'package:syncrow_web/pages/space_tree/bloc/space_tree_event.dart';
|
|||||||
import 'package:syncrow_web/services/home_api.dart';
|
import 'package:syncrow_web/services/home_api.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';
|
||||||
|
import 'package:syncrow_web/utils/navigation_service.dart';
|
||||||
|
|
||||||
class HomeBloc extends Bloc<HomeEvent, HomeState> {
|
class HomeBloc extends Bloc<HomeEvent, HomeState> {
|
||||||
UserModel? user;
|
UserModel? user;
|
||||||
String terms = '';
|
String terms = '';
|
||||||
String policy = '';
|
String policy = '';
|
||||||
|
|
||||||
HomeBloc() : super(HomeInitial()) {
|
HomeBloc() : super((HomeInitial())) {
|
||||||
|
// on<CreateNewNode>(_createNode);
|
||||||
on<FetchUserInfo>(_fetchUserInfo);
|
on<FetchUserInfo>(_fetchUserInfo);
|
||||||
on<FetchTermEvent>(_fetchTerms);
|
on<FetchTermEvent>(_fetchTerms);
|
||||||
on<FetchPolicyEvent>(_fetchPolicy);
|
on<FetchPolicyEvent>(_fetchPolicy);
|
||||||
on<ConfirmUserAgreementEvent>(_confirmUserAgreement);
|
on<ConfirmUserAgreementEvent>(_confirmUserAgreement);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _fetchUserInfo(
|
Future _fetchUserInfo(FetchUserInfo event, Emitter<HomeState> emit) async {
|
||||||
FetchUserInfo event,
|
|
||||||
Emitter<HomeState> emit,
|
|
||||||
) async {
|
|
||||||
try {
|
try {
|
||||||
final uuid =
|
var uuid =
|
||||||
await const FlutterSecureStorage().read(key: UserModel.userUuidKey);
|
await const FlutterSecureStorage().read(key: UserModel.userUuidKey);
|
||||||
if (uuid != null) {
|
|
||||||
user = await HomeApi().fetchUserInfo(uuid);
|
user = await HomeApi().fetchUserInfo(uuid);
|
||||||
}
|
|
||||||
|
|
||||||
if (user != null && user?.project != null) {
|
if (user != null && user!.project != null) {
|
||||||
await ProjectManager.setProjectUUID(user!.project!.uuid);
|
await ProjectManager.setProjectUUID(user!.project!.uuid);
|
||||||
|
|
||||||
}
|
}
|
||||||
add(FetchTermEvent());
|
add(FetchTermEvent());
|
||||||
add(FetchPolicyEvent());
|
add(FetchPolicyEvent());
|
||||||
@ -49,7 +47,7 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _fetchTerms(FetchTermEvent event, Emitter<HomeState> emit) async {
|
Future _fetchTerms(FetchTermEvent event, Emitter<HomeState> emit) async {
|
||||||
try {
|
try {
|
||||||
emit(LoadingHome());
|
emit(LoadingHome());
|
||||||
terms = await HomeApi().fetchTerms();
|
terms = await HomeApi().fetchTerms();
|
||||||
@ -59,22 +57,22 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _fetchPolicy(FetchPolicyEvent event, Emitter<HomeState> emit) async {
|
Future _fetchPolicy(FetchPolicyEvent event, Emitter<HomeState> emit) async {
|
||||||
try {
|
try {
|
||||||
emit(LoadingHome());
|
emit(LoadingHome());
|
||||||
policy = await HomeApi().fetchPolicy();
|
policy = await HomeApi().fetchPolicy();
|
||||||
emit(HomeInitial());
|
emit(HomeInitial());
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debugPrint('Error fetching policy: $e');
|
debugPrint("Error fetching policy: $e");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _confirmUserAgreement(
|
Future _confirmUserAgreement(
|
||||||
ConfirmUserAgreementEvent event, Emitter<HomeState> emit) async {
|
ConfirmUserAgreementEvent event, Emitter<HomeState> emit) async {
|
||||||
try {
|
try {
|
||||||
emit(LoadingHome());
|
emit(LoadingHome());
|
||||||
final uuid =
|
var uuid =
|
||||||
await const FlutterSecureStorage().read(key: UserModel.userUuidKey);
|
await const FlutterSecureStorage().read(key: UserModel.userUuidKey);
|
||||||
policy = await HomeApi().confirmUserAgreements(uuid);
|
policy = await HomeApi().confirmUserAgreements(uuid);
|
||||||
emit(PolicyAgreement());
|
emit(PolicyAgreement());
|
||||||
@ -83,7 +81,7 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<HomeItemModel> homeItems = [
|
List<HomeItemModel> homeItems = [
|
||||||
HomeItemModel(
|
HomeItemModel(
|
||||||
title: 'Access Management',
|
title: 'Access Management',
|
||||||
icon: Assets.accessIcon,
|
icon: Assets.accessIcon,
|
||||||
@ -128,5 +126,41 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
|
|||||||
},
|
},
|
||||||
color: const Color(0xFF023DFE),
|
color: const Color(0xFF023DFE),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
// HomeItemModel(
|
||||||
|
// title: 'Move in',
|
||||||
|
// icon: Assets.moveinIcon,
|
||||||
|
// active: false,
|
||||||
|
// onPress: (context) {},
|
||||||
|
// color: ColorsManager.primaryColor,
|
||||||
|
// ),
|
||||||
|
// HomeItemModel(
|
||||||
|
// title: 'Construction',
|
||||||
|
// icon: Assets.constructionIcon,
|
||||||
|
// active: false,
|
||||||
|
// onPress: (context) {},
|
||||||
|
// color: ColorsManager.primaryColor,
|
||||||
|
// ),
|
||||||
|
// HomeItemModel(
|
||||||
|
// title: 'Energy',
|
||||||
|
// icon: Assets.energyIcon,
|
||||||
|
// active: false,
|
||||||
|
// onPress: (context) {},
|
||||||
|
// color: ColorsManager.slidingBlueColor.withOpacity(0.2),
|
||||||
|
// ),
|
||||||
|
// HomeItemModel(
|
||||||
|
// title: 'Integrations',
|
||||||
|
// icon: Assets.integrationsIcon,
|
||||||
|
// active: false,
|
||||||
|
// onPress: (context) {},
|
||||||
|
// color: ColorsManager.slidingBlueColor.withOpacity(0.2),
|
||||||
|
// ),
|
||||||
|
// HomeItemModel(
|
||||||
|
// title: 'Asset',
|
||||||
|
// icon: Assets.assetIcon,
|
||||||
|
// active: false,
|
||||||
|
// onPress: (context) {},
|
||||||
|
// color: ColorsManager.slidingBlueColor.withOpacity(0.2),
|
||||||
|
// ),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -34,9 +34,17 @@ class HomeCard extends StatelessWidget {
|
|||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Flexible(
|
||||||
child: SpliteNameHelperWidget(
|
child: FittedBox(
|
||||||
name: name,
|
fit: BoxFit.scaleDown,
|
||||||
|
child: Text(
|
||||||
|
name,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 30,
|
||||||
|
color: Colors.white,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -55,72 +63,3 @@ class HomeCard extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SpliteNameHelperWidget extends StatelessWidget {
|
|
||||||
final String name;
|
|
||||||
const SpliteNameHelperWidget({
|
|
||||||
super.key,
|
|
||||||
required this.name,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
List<String> parts = name.split(' ');
|
|
||||||
|
|
||||||
if (parts.length == 2) {
|
|
||||||
// Two-word string
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsetsGeometry.only(top: 10, left: 10),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: FittedBox(
|
|
||||||
fit: BoxFit.scaleDown,
|
|
||||||
child: Text(
|
|
||||||
parts[0],
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 30,
|
|
||||||
color: Colors.white,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: FittedBox(
|
|
||||||
fit: BoxFit.scaleDown,
|
|
||||||
child: Text(
|
|
||||||
parts[1],
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 30,
|
|
||||||
color: Colors.white,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
// One-word string
|
|
||||||
return Text(
|
|
||||||
name,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 30,
|
|
||||||
color: Colors.white,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Text(
|
|
||||||
// name,
|
|
||||||
// style: const TextStyle(
|
|
||||||
// fontSize: 32,
|
|
||||||
// color: Colors.white,
|
|
||||||
// fontWeight: FontWeight.bold,
|
|
||||||
// ),
|
|
||||||
// )
|
|
||||||
|
@ -1,37 +1,17 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/home/bloc/home_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/home/bloc/home_event.dart';
|
|
||||||
import 'package:syncrow_web/pages/home/view/home_page_mobile.dart';
|
import 'package:syncrow_web/pages/home/view/home_page_mobile.dart';
|
||||||
import 'package:syncrow_web/pages/home/view/home_page_web.dart';
|
import 'package:syncrow_web/pages/home/view/home_page_web.dart';
|
||||||
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
||||||
|
|
||||||
class HomePage extends StatefulWidget {
|
class HomePage extends StatelessWidget with HelperResponsiveLayout {
|
||||||
const HomePage({super.key});
|
const HomePage({super.key});
|
||||||
|
|
||||||
@override
|
|
||||||
State<HomePage> createState() => _HomePageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _HomePageState extends State<HomePage> with HelperResponsiveLayout {
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
_fetchUserInfo();
|
|
||||||
|
|
||||||
super.initState();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (isSmallScreenSize(context) || isMediumScreenSize(context)) {
|
final isSmallScreen = isSmallScreenSize(context);
|
||||||
return HomeMobilePage();
|
final isMediumScreen = isMediumScreenSize(context);
|
||||||
}
|
return isSmallScreen || isMediumScreen
|
||||||
|
? HomeMobilePage()
|
||||||
return const HomeWebPage();
|
: const HomeWebPage();
|
||||||
}
|
|
||||||
|
|
||||||
void _fetchUserInfo() {
|
|
||||||
final bloc = context.read<HomeBloc>();
|
|
||||||
if (bloc.user == null) bloc.add(const FetchUserInfo());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ class _HomeWebPageState extends State<HomeWebPage> {
|
|||||||
flex: 4,
|
flex: 4,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: size.height * 0.6,
|
height: size.height * 0.6,
|
||||||
width: size.width * 0.8,
|
width: size.width * 0.68,
|
||||||
child: GridView.builder(
|
child: GridView.builder(
|
||||||
itemCount: homeBloc.homeItems.length,
|
itemCount: homeBloc.homeItems.length,
|
||||||
gridDelegate:
|
gridDelegate:
|
||||||
|
@ -19,6 +19,7 @@ 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';
|
||||||
import 'package:syncrow_web/utils/style.dart';
|
import 'package:syncrow_web/utils/style.dart';
|
||||||
|
|
||||||
class UsersPage extends StatelessWidget {
|
class UsersPage extends StatelessWidget {
|
||||||
UsersPage({super.key});
|
UsersPage({super.key});
|
||||||
|
|
||||||
|
@ -13,35 +13,6 @@ class FunctionBloc extends Bloc<FunctionBlocEvent, FunctionBlocState> {
|
|||||||
on<AddFunction>(_onAddFunction);
|
on<AddFunction>(_onAddFunction);
|
||||||
on<SelectFunction>(_onSelectFunction);
|
on<SelectFunction>(_onSelectFunction);
|
||||||
}
|
}
|
||||||
// void _onAddFunction(AddFunction event, Emitter<FunctionBlocState> emit) {
|
|
||||||
// final functions = List<DeviceFunctionData>.from(state.addedFunctions);
|
|
||||||
// final existingIndex = functions.indexWhere(
|
|
||||||
// (f) => f.functionCode == event.functionData.functionCode,
|
|
||||||
// );
|
|
||||||
|
|
||||||
// if (existingIndex != -1) {
|
|
||||||
// final existingData = functions[existingIndex];
|
|
||||||
// functions[existingIndex] = DeviceFunctionData(
|
|
||||||
// entityId: event.functionData.entityId,
|
|
||||||
// functionCode: event.functionData.functionCode,
|
|
||||||
// operationName: event.functionData.operationName,
|
|
||||||
// value: event.functionData.value ?? existingData.value,
|
|
||||||
// valueDescription: event.functionData.valueDescription ??
|
|
||||||
// existingData.valueDescription,
|
|
||||||
// condition: event.functionData.condition ?? existingData.condition,
|
|
||||||
// step: event.functionData.step ?? existingData.step,
|
|
||||||
// );
|
|
||||||
// } else {
|
|
||||||
// functions.clear();
|
|
||||||
// functions.add(event.functionData);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// emit(state.copyWith(
|
|
||||||
// addedFunctions: functions,
|
|
||||||
// selectedFunction: event.functionData.functionCode,
|
|
||||||
// ));
|
|
||||||
// }
|
|
||||||
|
|
||||||
void _onAddFunction(AddFunction event, Emitter<FunctionBlocState> emit) {
|
void _onAddFunction(AddFunction event, Emitter<FunctionBlocState> emit) {
|
||||||
final functions = List<DeviceFunctionData>.from(state.addedFunctions);
|
final functions = List<DeviceFunctionData>.from(state.addedFunctions);
|
||||||
final existingIndex = functions.indexWhere(
|
final existingIndex = functions.indexWhere(
|
||||||
@ -49,10 +20,19 @@ class FunctionBloc extends Bloc<FunctionBlocEvent, FunctionBlocState> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (existingIndex != -1) {
|
if (existingIndex != -1) {
|
||||||
// Update the function value
|
final existingData = functions[existingIndex];
|
||||||
functions[existingIndex] = event.functionData;
|
functions[existingIndex] = DeviceFunctionData(
|
||||||
|
entityId: event.functionData.entityId,
|
||||||
|
functionCode: event.functionData.functionCode,
|
||||||
|
operationName: event.functionData.operationName,
|
||||||
|
value: event.functionData.value ?? existingData.value,
|
||||||
|
valueDescription: event.functionData.valueDescription ??
|
||||||
|
existingData.valueDescription,
|
||||||
|
condition: event.functionData.condition ?? existingData.condition,
|
||||||
|
step: event.functionData.step ?? existingData.step,
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
// Add new function value
|
functions.clear();
|
||||||
functions.add(event.functionData);
|
functions.add(event.functionData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,8 +4,8 @@ import 'package:bloc/bloc.dart';
|
|||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/common/bloc/project_manager.dart';
|
import 'package:syncrow_web/pages/common/bloc/project_manager.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/automation_scene_trigger_bloc/automation_status_update.dart';
|
import 'package:syncrow_web/pages/routines/bloc/automation_scene_trigger_bloc/automation_status_update.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_bloc.dart';
|
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_bloc.dart';
|
||||||
@ -27,6 +27,9 @@ 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';
|
||||||
|
// String 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()) {
|
||||||
on<AddToIfContainer>(_onAddToIfContainer);
|
on<AddToIfContainer>(_onAddToIfContainer);
|
||||||
@ -170,7 +173,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onLoadScenes(
|
Future<void> _onLoadScenes(
|
||||||
LoadScenes event, Emitter<RoutineState> emit) async {
|
LoadScenes event, Emitter<RoutineState> emit) async {
|
||||||
emit(state.copyWith(isLoading: true, errorMessage: null));
|
emit(state.copyWith(isLoading: true, errorMessage: null));
|
||||||
List<ScenesModel> scenes = [];
|
List<ScenesModel> scenes = [];
|
||||||
@ -208,7 +211,7 @@ Future<void> _onLoadScenes(
|
|||||||
loadAutomationErrorMessage: '',
|
loadAutomationErrorMessage: '',
|
||||||
scenes: scenes));
|
scenes: scenes));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onLoadAutomation(
|
Future<void> _onLoadAutomation(
|
||||||
LoadAutomation event, Emitter<RoutineState> emit) async {
|
LoadAutomation event, Emitter<RoutineState> emit) async {
|
||||||
@ -1160,8 +1163,8 @@ Future<void> _onLoadScenes(
|
|||||||
|
|
||||||
if (result['success']) {
|
if (result['success']) {
|
||||||
add(ResetRoutineState());
|
add(ResetRoutineState());
|
||||||
add(const LoadAutomation());
|
add(LoadAutomation());
|
||||||
add(const LoadScenes());
|
add(LoadScenes());
|
||||||
} else {
|
} else {
|
||||||
emit(state.copyWith(
|
emit(state.copyWith(
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
@ -1419,17 +1422,15 @@ Future<void> _onLoadScenes(
|
|||||||
event.automationId, event.automationStatusUpdate, projectId);
|
event.automationId, event.automationStatusUpdate, projectId);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
// await SceneApi.getAutomationByUnitId(
|
final updatedAutomations = await SceneApi.getAutomationByUnitId(
|
||||||
// event.automationStatusUpdate.spaceUuid,
|
event.automationStatusUpdate.spaceUuid,
|
||||||
// event.communityId,
|
event.communityId,
|
||||||
// projectId);
|
projectId);
|
||||||
|
|
||||||
// Remove from loading set safely
|
// Remove from loading set safely
|
||||||
|
|
||||||
final updatedLoadingIds = {...state.loadingAutomationIds!}
|
final updatedLoadingIds = {...state.loadingAutomationIds!}
|
||||||
..remove(event.automationId);
|
..remove(event.automationId);
|
||||||
final updatedAutomations = changeItemStateOnToggelingSceen(
|
|
||||||
state.automations, event.automationId);
|
|
||||||
emit(state.copyWith(
|
emit(state.copyWith(
|
||||||
automations: updatedAutomations,
|
automations: updatedAutomations,
|
||||||
loadingAutomationIds: updatedLoadingIds,
|
loadingAutomationIds: updatedLoadingIds,
|
||||||
@ -1451,24 +1452,4 @@ Future<void> _onLoadScenes(
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ScenesModel> changeItemStateOnToggelingSceen(
|
|
||||||
List<ScenesModel> oldSceen, String automationId) {
|
|
||||||
return oldSceen.map((scene) {
|
|
||||||
if (scene.id == automationId) {
|
|
||||||
return ScenesModel(
|
|
||||||
id: scene.id,
|
|
||||||
sceneTuyaId: scene.sceneTuyaId,
|
|
||||||
name: scene.name,
|
|
||||||
status: scene.status == 'enable' ? 'disable' : 'enable',
|
|
||||||
type: scene.type,
|
|
||||||
spaceName: scene.spaceName,
|
|
||||||
spaceId: scene.spaceId,
|
|
||||||
communityId: scene.communityId,
|
|
||||||
icon: scene.icon,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return scene;
|
|
||||||
}).toList();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ class _DropdownContentState extends State<_DropdownContent> {
|
|||||||
final selectedCommunity = _findCommunity(state, state.selectedSpaceId);
|
final selectedCommunity = _findCommunity(state, state.selectedSpaceId);
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
height: 40,
|
height: 46,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border.all(color: Colors.grey.shade300),
|
border: Border.all(color: Colors.grey.shade300),
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
@ -149,7 +149,7 @@ class _DropdownContentState extends State<_DropdownContent> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
height: 45,
|
height: 45,
|
||||||
width: 44,
|
width: 33,
|
||||||
child: const Icon(
|
child: const Icon(
|
||||||
Icons.keyboard_arrow_down,
|
Icons.keyboard_arrow_down,
|
||||||
color: ColorsManager.textGray,
|
color: ColorsManager.textGray,
|
||||||
|
@ -44,60 +44,51 @@ class _CreateNewRoutinesDialogState extends State<CreateNewRoutinesDialog> {
|
|||||||
_selectedSpace = null;
|
_selectedSpace = null;
|
||||||
_selectedCommunity = _selectedId;
|
_selectedCommunity = _selectedId;
|
||||||
}
|
}
|
||||||
return Dialog(
|
return AlertDialog(
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
insetPadding: const EdgeInsets.symmetric(
|
insetPadding: EdgeInsets.zero,
|
||||||
horizontal: 20,
|
contentPadding: EdgeInsets.zero,
|
||||||
),
|
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(12)),
|
borderRadius: BorderRadius.circular(12)),
|
||||||
child: Container(
|
title: Text(
|
||||||
width: 450,
|
|
||||||
child: Stack(
|
|
||||||
children: [
|
|
||||||
Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
Text(
|
|
||||||
'Create New Routines',
|
'Create New Routines',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style:
|
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
||||||
Theme.of(context).textTheme.bodyMedium!.copyWith(
|
|
||||||
color: ColorsManager.spaceColor,
|
color: ColorsManager.spaceColor,
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
fontWeight: FontWeight.w700,
|
fontWeight: FontWeight.w700,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
content: Stack(
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
const Divider(),
|
const Divider(),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
Column(
|
|
||||||
children: [
|
|
||||||
Column(
|
Column(
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(
|
padding:
|
||||||
left: 13, right: 10),
|
const EdgeInsets.only(left: 13, right: 8),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
SpaceTreeDropdown(
|
SpaceTreeDropdown(
|
||||||
selectedSpaceId: _selectedId,
|
selectedSpaceId: _selectedId,
|
||||||
onChanged: (String? newValue) {
|
onChanged: (String? newValue) {
|
||||||
setState(
|
setState(() => _selectedId = newValue!);
|
||||||
() => _selectedId = newValue!);
|
|
||||||
if (_selectedId != null) {
|
if (_selectedId != null) {
|
||||||
_bloc.add(
|
_bloc.add(SpaceOnlyWithDevicesEvent(
|
||||||
SpaceOnlyWithDevicesEvent(
|
|
||||||
_selectedId!));
|
_selectedId!));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)),
|
)),
|
||||||
const SizedBox(height: 21),
|
const SizedBox(height: 5),
|
||||||
|
const SizedBox(height: 8),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(left: 15, right: 15),
|
||||||
left: 15, right: 20),
|
|
||||||
child: SpaceDropdown(
|
child: SpaceDropdown(
|
||||||
hintMessage: spaceHint,
|
hintMessage: spaceHint,
|
||||||
spaces: spaces,
|
spaces: spaces,
|
||||||
@ -111,8 +102,6 @@ class _CreateNewRoutinesDialogState extends State<CreateNewRoutinesDialog> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
const Divider(),
|
const Divider(),
|
||||||
Row(
|
Row(
|
||||||
@ -194,7 +183,6 @@ class _CreateNewRoutinesDialogState extends State<CreateNewRoutinesDialog> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
|
@ -34,9 +34,7 @@ class SpaceDropdown extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
child: Container(
|
child: Container(
|
||||||
height: 40,
|
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: ColorsManager.whiteColors,
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
borderRadius: BorderRadius.circular(10),
|
||||||
),
|
),
|
||||||
child: DropdownButton2<String>(
|
child: DropdownButton2<String>(
|
||||||
@ -47,7 +45,7 @@ class SpaceDropdown extends StatelessWidget {
|
|||||||
value: space.uuid,
|
value: space.uuid,
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
' ${space.name}',
|
' ${space.name}',
|
||||||
@ -90,7 +88,7 @@ class SpaceDropdown extends StatelessWidget {
|
|||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 8,
|
flex: 6,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.only(left: 10),
|
padding: const EdgeInsets.only(left: 10),
|
||||||
child: Text(
|
child: Text(
|
||||||
@ -131,7 +129,6 @@ class SpaceDropdown extends StatelessWidget {
|
|||||||
dropdownStyleData: DropdownStyleData(
|
dropdownStyleData: DropdownStyleData(
|
||||||
maxHeight: MediaQuery.of(context).size.height * 0.4,
|
maxHeight: MediaQuery.of(context).size.height * 0.4,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: ColorsManager.whiteColors,
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
borderRadius: BorderRadius.circular(10),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -4,7 +4,6 @@ import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
|||||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/ac_dialog.dart';
|
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/ac_dialog.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/ceiling_sensor/ceiling_sensor_helper.dart';
|
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/ceiling_sensor/ceiling_sensor_helper.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/curtain_dialog.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/flush_presence_sensor/flush_presence_sensor.dart';
|
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/flush_presence_sensor/flush_presence_sensor.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/gateway/gateway_helper.dart';
|
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/gateway/gateway_helper.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/one_gang_switch_dialog.dart';
|
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/one_gang_switch_dialog.dart';
|
||||||
@ -27,7 +26,7 @@ class DeviceDialogHelper {
|
|||||||
final result = await _getDialogForDeviceType(
|
final result = await _getDialogForDeviceType(
|
||||||
dialogType: dialogType,
|
dialogType: dialogType,
|
||||||
context: context,
|
context: context,
|
||||||
productType: data['productType'] as String,
|
productType: data['productType'],
|
||||||
data: data,
|
data: data,
|
||||||
functions: functions,
|
functions: functions,
|
||||||
removeComparetors: removeComparetors,
|
removeComparetors: removeComparetors,
|
||||||
@ -66,14 +65,7 @@ class DeviceDialogHelper {
|
|||||||
removeComparetors: removeComparetors,
|
removeComparetors: removeComparetors,
|
||||||
dialogType: dialogType,
|
dialogType: dialogType,
|
||||||
);
|
);
|
||||||
case 'CUR':
|
|
||||||
return CurtainHelper.showControlDialog(
|
|
||||||
dialogType: dialogType,
|
|
||||||
context: context,
|
|
||||||
functions: functions,
|
|
||||||
uniqueCustomId: data['uniqueCustomId'],
|
|
||||||
device: data['device'],
|
|
||||||
);
|
|
||||||
case '1G':
|
case '1G':
|
||||||
return OneGangSwitchHelper.showSwitchFunctionsDialog(
|
return OneGangSwitchHelper.showSwitchFunctionsDialog(
|
||||||
dialogType: dialogType,
|
dialogType: dialogType,
|
||||||
|
@ -17,8 +17,7 @@ class SaveRoutineHelper {
|
|||||||
builder: (context) {
|
builder: (context) {
|
||||||
return BlocBuilder<RoutineBloc, RoutineState>(
|
return BlocBuilder<RoutineBloc, RoutineState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final selectedConditionLabel =
|
final selectedConditionLabel = state.selectedAutomationOperator == 'and'
|
||||||
state.selectedAutomationOperator == 'and'
|
|
||||||
? 'All Conditions are met'
|
? 'All Conditions are met'
|
||||||
: 'Any Condition is met';
|
: 'Any Condition is met';
|
||||||
|
|
||||||
@ -38,8 +37,7 @@ class SaveRoutineHelper {
|
|||||||
Text(
|
Text(
|
||||||
'Create a scene: ${state.routineName ?? ""}',
|
'Create a scene: ${state.routineName ?? ""}',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style:
|
style: Theme.of(context).textTheme.headlineMedium!.copyWith(
|
||||||
Theme.of(context).textTheme.headlineMedium!.copyWith(
|
|
||||||
color: ColorsManager.primaryColorWithOpacity,
|
color: ColorsManager.primaryColorWithOpacity,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
@ -60,8 +58,7 @@ class SaveRoutineHelper {
|
|||||||
_buildIfConditions(state, context),
|
_buildIfConditions(state, context),
|
||||||
Container(
|
Container(
|
||||||
width: 1,
|
width: 1,
|
||||||
color: ColorsManager.greyColor
|
color: ColorsManager.greyColor.withValues(alpha: 0.8),
|
||||||
.withValues(alpha: 0.8),
|
|
||||||
),
|
),
|
||||||
_buildThenActions(state, context),
|
_buildThenActions(state, context),
|
||||||
],
|
],
|
||||||
@ -100,8 +97,7 @@ class SaveRoutineHelper {
|
|||||||
child: Row(
|
child: Row(
|
||||||
spacing: 16,
|
spacing: 16,
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(child: Text('IF: $selectedConditionLabel', style: textStyle)),
|
||||||
child: Text('IF: $selectedConditionLabel', style: textStyle)),
|
|
||||||
const Expanded(child: Text('THEN:', style: textStyle)),
|
const Expanded(child: Text('THEN:', style: textStyle)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -147,8 +143,7 @@ class SaveRoutineHelper {
|
|||||||
child: ListView(
|
child: ListView(
|
||||||
// shrinkWrap: true,
|
// shrinkWrap: true,
|
||||||
children: state.thenItems.map((item) {
|
children: state.thenItems.map((item) {
|
||||||
final functions =
|
final functions = state.selectedFunctions[item['uniqueCustomId']] ?? [];
|
||||||
state.selectedFunctions[item['uniqueCustomId']] ?? [];
|
|
||||||
return functionRow(item, context, functions);
|
return functionRow(item, context, functions);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
),
|
),
|
||||||
@ -208,8 +203,7 @@ class SaveRoutineHelper {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Center(
|
child: Center(
|
||||||
child:
|
child: item['type'] == 'tap_to_run' || item['type'] == 'scene'
|
||||||
item['type'] == 'tap_to_run' || item['type'] == 'scene'
|
|
||||||
? Image.memory(
|
? Image.memory(
|
||||||
base64Decode(item['icon']),
|
base64Decode(item['icon']),
|
||||||
width: 12,
|
width: 12,
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
import 'package:syncrow_web/pages/device_managment/curtain/model/curtain_model.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/models/curtain/curtain_opertion_value.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart'
|
|
||||||
show DeviceFunction;
|
|
||||||
import 'package:syncrow_web/utils/constants/app_enum.dart';
|
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
|
||||||
|
|
||||||
abstract class CurtainFunction extends DeviceFunction<CurtainModel> {
|
|
||||||
final String type;
|
|
||||||
CurtainFunction({
|
|
||||||
required super.deviceId,
|
|
||||||
required super.deviceName,
|
|
||||||
required this.type,
|
|
||||||
required super.code,
|
|
||||||
required super.operationName,
|
|
||||||
required super.icon,
|
|
||||||
});
|
|
||||||
List<CurtainOperationalValue> getOperationalValues();
|
|
||||||
}
|
|
||||||
|
|
||||||
class ControlCurtainFunction extends CurtainFunction {
|
|
||||||
ControlCurtainFunction({
|
|
||||||
required super.deviceId,
|
|
||||||
required super.deviceName,
|
|
||||||
required super.type,
|
|
||||||
super.code = 'control',
|
|
||||||
super.operationName = 'Control',
|
|
||||||
super.icon = Assets.curtain,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<CurtainOperationalValue> getOperationalValues() => [
|
|
||||||
CurtainOperationalValue(
|
|
||||||
icon: Assets.curtain,
|
|
||||||
description: 'OPEN',
|
|
||||||
value: 'open',
|
|
||||||
),
|
|
||||||
CurtainOperationalValue(
|
|
||||||
icon: Assets.curtain,
|
|
||||||
description: 'STOP',
|
|
||||||
value: 'stop',
|
|
||||||
),
|
|
||||||
CurtainOperationalValue(
|
|
||||||
icon: Assets.curtain,
|
|
||||||
description: 'CLOSE',
|
|
||||||
value: 'close',
|
|
||||||
)
|
|
||||||
];
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
class CurtainOperationalValue {
|
|
||||||
final String icon;
|
|
||||||
final String description;
|
|
||||||
final String value;
|
|
||||||
|
|
||||||
CurtainOperationalValue({
|
|
||||||
required this.icon,
|
|
||||||
required this.description,
|
|
||||||
required this.value,
|
|
||||||
});
|
|
||||||
}
|
|
@ -405,8 +405,8 @@ class PowerFactorCStatusFunction extends EnergyClampFunctions {
|
|||||||
code: 'PowerFactorC',
|
code: 'PowerFactorC',
|
||||||
operationName: 'Power Factor C',
|
operationName: 'Power Factor C',
|
||||||
icon: Assets.speedoMeter,
|
icon: Assets.speedoMeter,
|
||||||
min: 0.0,
|
min: 0.00,
|
||||||
max: 1.0,
|
max: 1.00,
|
||||||
step: 0.1,
|
step: 0.1,
|
||||||
unit: "",
|
unit: "",
|
||||||
);
|
);
|
||||||
|
@ -148,7 +148,6 @@ class IfContainer extends StatelessWidget {
|
|||||||
'NCPS',
|
'NCPS',
|
||||||
'WH',
|
'WH',
|
||||||
'PC',
|
'PC',
|
||||||
'CUR',
|
|
||||||
].contains(mutableData['productType'])) {
|
].contains(mutableData['productType'])) {
|
||||||
context
|
context
|
||||||
.read<RoutineBloc>()
|
.read<RoutineBloc>()
|
||||||
|
@ -28,7 +28,6 @@ class _RoutineDevicesState extends State<RoutineDevices> {
|
|||||||
'NCPS',
|
'NCPS',
|
||||||
'WH',
|
'WH',
|
||||||
'PC',
|
'PC',
|
||||||
'CUR',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -117,22 +117,10 @@ class ACHelper {
|
|||||||
},
|
},
|
||||||
onConfirm: state.addedFunctions.isNotEmpty
|
onConfirm: state.addedFunctions.isNotEmpty
|
||||||
? () {
|
? () {
|
||||||
final selectedFunctionData =
|
|
||||||
state.addedFunctions.firstWhere(
|
|
||||||
(f) =>
|
|
||||||
f.functionCode == state.selectedFunction,
|
|
||||||
orElse: () => DeviceFunctionData(
|
|
||||||
entityId: '',
|
|
||||||
functionCode: state.selectedFunction ?? '',
|
|
||||||
operationName: '',
|
|
||||||
value: null,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
/// add the functions to the routine bloc
|
/// add the functions to the routine bloc
|
||||||
context.read<RoutineBloc>().add(
|
context.read<RoutineBloc>().add(
|
||||||
AddFunctionToRoutine(
|
AddFunctionToRoutine(
|
||||||
[selectedFunctionData],
|
state.addedFunctions,
|
||||||
uniqueCustomId,
|
uniqueCustomId,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -78,22 +78,12 @@ class _CeilingSensorDialogState extends State<CeilingSensorDialog> {
|
|||||||
onCancel: () => Navigator.pop(context),
|
onCancel: () => Navigator.pop(context),
|
||||||
onConfirm: state.addedFunctions.isNotEmpty
|
onConfirm: state.addedFunctions.isNotEmpty
|
||||||
? () {
|
? () {
|
||||||
final selectedFunctionData =
|
|
||||||
state.addedFunctions.firstWhere(
|
|
||||||
(f) => f.functionCode == state.selectedFunction,
|
|
||||||
orElse: () => DeviceFunctionData(
|
|
||||||
entityId: '',
|
|
||||||
functionCode: state.selectedFunction ?? '',
|
|
||||||
operationName: '',
|
|
||||||
value: null,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
final functions = _updateValuesForAddedFunctions(
|
final functions = _updateValuesForAddedFunctions(
|
||||||
state.addedFunctions,
|
state.addedFunctions,
|
||||||
);
|
);
|
||||||
context.read<RoutineBloc>().add(
|
context.read<RoutineBloc>().add(
|
||||||
AddFunctionToRoutine(
|
AddFunctionToRoutine(
|
||||||
[selectedFunctionData],
|
functions,
|
||||||
'${widget.uniqueCustomId}',
|
'${widget.uniqueCustomId}',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -1,270 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
import 'package:flutter_svg/svg.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/routines/bloc/routine_bloc/routine_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/models/curtain/curtain_function.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/models/curtain/curtain_opertion_value.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/widgets/dialog_footer.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/widgets/dialog_header.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/helpers/routine_tap_function_helper.dart';
|
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
|
||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
|
||||||
|
|
||||||
class CurtainHelper {
|
|
||||||
static Future<Map<String, dynamic>?> showControlDialog({
|
|
||||||
required String dialogType,
|
|
||||||
required BuildContext context,
|
|
||||||
required List<DeviceFunction> functions,
|
|
||||||
required String uniqueCustomId,
|
|
||||||
required AllDevicesModel? device,
|
|
||||||
}) async {
|
|
||||||
List<ControlCurtainFunction> curtainFunctions =
|
|
||||||
functions.whereType<ControlCurtainFunction>().where((function) {
|
|
||||||
if (dialogType == 'THEN') {
|
|
||||||
return function.type == 'THEN' || function.type == 'BOTH';
|
|
||||||
}
|
|
||||||
return function.type == 'IF' || function.type == 'BOTH';
|
|
||||||
}).toList();
|
|
||||||
return showDialog<Map<String, dynamic>?>(
|
|
||||||
context: context,
|
|
||||||
builder: (context) => BlocProvider(
|
|
||||||
create: (_) => FunctionBloc()..add(const InitializeFunctions([])),
|
|
||||||
child: AlertDialog(
|
|
||||||
contentPadding: EdgeInsets.zero,
|
|
||||||
content: BlocBuilder<FunctionBloc, FunctionBlocState>(
|
|
||||||
builder: (context, state) {
|
|
||||||
final selectedFunction = state.selectedFunction;
|
|
||||||
final selectedOperationName = state.selectedOperationName;
|
|
||||||
final selectedFunctionData = state.addedFunctions
|
|
||||||
.firstWhere((f) => f.functionCode == selectedFunction,
|
|
||||||
orElse: () => DeviceFunctionData(
|
|
||||||
entityId: '',
|
|
||||||
functionCode: selectedFunction ?? '',
|
|
||||||
operationName: '',
|
|
||||||
value: null,
|
|
||||||
));
|
|
||||||
|
|
||||||
return Container(
|
|
||||||
width: selectedFunction != null ? 600 : 360,
|
|
||||||
height: 450,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.white,
|
|
||||||
borderRadius: BorderRadius.circular(20),
|
|
||||||
),
|
|
||||||
padding: const EdgeInsets.only(top: 20),
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
const DialogHeader('AC Functions'),
|
|
||||||
Expanded(
|
|
||||||
child: Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
||||||
children: [
|
|
||||||
// Function list
|
|
||||||
SizedBox(
|
|
||||||
width: selectedFunction != null ? 320 : 360,
|
|
||||||
child: _buildFunctionsList(
|
|
||||||
context: context,
|
|
||||||
curtainFunctions: curtainFunctions,
|
|
||||||
onFunctionSelected:
|
|
||||||
(functionCode, operationName) {
|
|
||||||
RoutineTapFunctionHelper.onTapFunction(
|
|
||||||
context,
|
|
||||||
functionCode: functionCode,
|
|
||||||
functionOperationName: operationName,
|
|
||||||
functionValueDescription:
|
|
||||||
selectedFunctionData.valueDescription,
|
|
||||||
deviceUuid: device?.uuid,
|
|
||||||
codesToAddIntoFunctionsWithDefaultValue: [
|
|
||||||
'temp_set',
|
|
||||||
'temp_current',
|
|
||||||
],
|
|
||||||
defaultValue: 0);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
// Value selector
|
|
||||||
if (selectedFunction != null)
|
|
||||||
Expanded(
|
|
||||||
child: _buildValueSelector(
|
|
||||||
context: context,
|
|
||||||
selectedFunction: selectedFunction,
|
|
||||||
selectedFunctionData: selectedFunctionData,
|
|
||||||
controlFunctions: curtainFunctions,
|
|
||||||
device: device,
|
|
||||||
operationName: selectedOperationName ?? '',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
DialogFooter(
|
|
||||||
onCancel: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
onConfirm: state.addedFunctions.isNotEmpty
|
|
||||||
? () {
|
|
||||||
/// add the functions to the routine bloc
|
|
||||||
context.read<RoutineBloc>().add(
|
|
||||||
AddFunctionToRoutine(
|
|
||||||
state.addedFunctions,
|
|
||||||
uniqueCustomId,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Return the device data to be added to the container
|
|
||||||
Navigator.pop(context, {
|
|
||||||
'deviceId': functions.first.deviceId,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
isConfirmEnabled: selectedFunction != null,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
).then((value) {
|
|
||||||
return value;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
static Widget _buildFunctionsList({
|
|
||||||
required BuildContext context,
|
|
||||||
required List<ControlCurtainFunction> curtainFunctions,
|
|
||||||
required Function(String, String) onFunctionSelected,
|
|
||||||
}) {
|
|
||||||
return ListView.separated(
|
|
||||||
shrinkWrap: false,
|
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
|
||||||
itemCount: curtainFunctions.length,
|
|
||||||
separatorBuilder: (context, index) => const Padding(
|
|
||||||
padding: EdgeInsets.symmetric(horizontal: 40.0),
|
|
||||||
child: Divider(
|
|
||||||
color: ColorsManager.dividerColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
final function = curtainFunctions[index];
|
|
||||||
return ListTile(
|
|
||||||
leading: SvgPicture.asset(
|
|
||||||
function.icon,
|
|
||||||
width: 24,
|
|
||||||
height: 24,
|
|
||||||
placeholderBuilder: (BuildContext context) => Container(
|
|
||||||
width: 24,
|
|
||||||
height: 24,
|
|
||||||
color: Colors.transparent,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
title: Text(
|
|
||||||
function.operationName,
|
|
||||||
style: context.textTheme.bodyMedium,
|
|
||||||
),
|
|
||||||
trailing: const Icon(
|
|
||||||
Icons.arrow_forward_ios,
|
|
||||||
size: 16,
|
|
||||||
color: ColorsManager.textGray,
|
|
||||||
),
|
|
||||||
onTap: () => onFunctionSelected(
|
|
||||||
function.code,
|
|
||||||
function.operationName,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Widget _buildValueSelector({
|
|
||||||
required BuildContext context,
|
|
||||||
required String selectedFunction,
|
|
||||||
required DeviceFunctionData? selectedFunctionData,
|
|
||||||
required List<ControlCurtainFunction> controlFunctions,
|
|
||||||
AllDevicesModel? device,
|
|
||||||
required String operationName,
|
|
||||||
}) {
|
|
||||||
final selectedFn =
|
|
||||||
controlFunctions.firstWhere((f) => f.code == selectedFunction);
|
|
||||||
|
|
||||||
// Rest of your existing code for other value selectors
|
|
||||||
final values = selectedFn.getOperationalValues();
|
|
||||||
return _buildOperationalValuesList(
|
|
||||||
context: context,
|
|
||||||
values: values,
|
|
||||||
selectedValue: selectedFunctionData?.value,
|
|
||||||
device: device,
|
|
||||||
operationName: operationName,
|
|
||||||
selectCode: selectedFunction,
|
|
||||||
selectedFunctionData: selectedFunctionData,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Widget _buildOperationalValuesList({
|
|
||||||
required BuildContext context,
|
|
||||||
required List<CurtainOperationalValue> values,
|
|
||||||
required dynamic selectedValue,
|
|
||||||
AllDevicesModel? device,
|
|
||||||
required String operationName,
|
|
||||||
required String selectCode,
|
|
||||||
DeviceFunctionData? selectedFunctionData,
|
|
||||||
|
|
||||||
// required Function(dynamic) onValueChanged,
|
|
||||||
}) {
|
|
||||||
return ListView.builder(
|
|
||||||
shrinkWrap: false,
|
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
|
||||||
itemCount: values.length,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
final value = values[index];
|
|
||||||
final isSelected = selectedValue == value.value;
|
|
||||||
return ListTile(
|
|
||||||
leading: SvgPicture.asset(
|
|
||||||
value.icon,
|
|
||||||
width: 24,
|
|
||||||
height: 24,
|
|
||||||
placeholderBuilder: (BuildContext context) => Container(
|
|
||||||
width: 24,
|
|
||||||
height: 24,
|
|
||||||
color: Colors.transparent,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
title: Text(
|
|
||||||
value.description,
|
|
||||||
style: context.textTheme.bodyMedium,
|
|
||||||
),
|
|
||||||
trailing: Icon(
|
|
||||||
isSelected
|
|
||||||
? Icons.radio_button_checked
|
|
||||||
: Icons.radio_button_unchecked,
|
|
||||||
size: 24,
|
|
||||||
color: isSelected
|
|
||||||
? ColorsManager.primaryColorWithOpacity
|
|
||||||
: ColorsManager.textGray,
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
if (!isSelected) {
|
|
||||||
context.read<FunctionBloc>().add(
|
|
||||||
AddFunction(
|
|
||||||
functionData: DeviceFunctionData(
|
|
||||||
entityId: device?.uuid ?? '',
|
|
||||||
functionCode: selectCode,
|
|
||||||
operationName: operationName,
|
|
||||||
value: value.value,
|
|
||||||
condition: selectedFunctionData?.condition,
|
|
||||||
valueDescription:
|
|
||||||
selectedFunctionData?.valueDescription,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -192,18 +192,9 @@ class _WallPresenceSensorState extends State<FlushPresenceSensor> {
|
|||||||
onCancel: () => Navigator.pop(context),
|
onCancel: () => Navigator.pop(context),
|
||||||
onConfirm: state.addedFunctions.isNotEmpty
|
onConfirm: state.addedFunctions.isNotEmpty
|
||||||
? () {
|
? () {
|
||||||
final selectedFunctionData = state.addedFunctions.firstWhere(
|
|
||||||
(f) => f.functionCode == state.selectedFunction,
|
|
||||||
orElse: () => DeviceFunctionData(
|
|
||||||
entityId: '',
|
|
||||||
functionCode: state.selectedFunction ?? '',
|
|
||||||
operationName: '',
|
|
||||||
value: null,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
context.read<RoutineBloc>().add(
|
context.read<RoutineBloc>().add(
|
||||||
AddFunctionToRoutine(
|
AddFunctionToRoutine(
|
||||||
[selectedFunctionData],
|
state.addedFunctions,
|
||||||
widget.uniqueCustomId!,
|
widget.uniqueCustomId!,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -115,18 +115,9 @@ class _GatewayDialogState extends State<GatewayDialog> {
|
|||||||
onCancel: () => Navigator.pop(context),
|
onCancel: () => Navigator.pop(context),
|
||||||
onConfirm: state.addedFunctions.isNotEmpty
|
onConfirm: state.addedFunctions.isNotEmpty
|
||||||
? () {
|
? () {
|
||||||
final selectedFunctionData = state.addedFunctions.firstWhere(
|
|
||||||
(f) => f.functionCode == state.selectedFunction,
|
|
||||||
orElse: () => DeviceFunctionData(
|
|
||||||
entityId: '',
|
|
||||||
functionCode: state.selectedFunction ?? '',
|
|
||||||
operationName: '',
|
|
||||||
value: null,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
context.read<RoutineBloc>().add(
|
context.read<RoutineBloc>().add(
|
||||||
AddFunctionToRoutine(
|
AddFunctionToRoutine(
|
||||||
[selectedFunctionData],
|
state.addedFunctions,
|
||||||
widget.uniqueCustomId ?? '-1',
|
widget.uniqueCustomId ?? '-1',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -147,7 +147,7 @@ class OneGangSwitchHelper {
|
|||||||
// }
|
// }
|
||||||
context.read<RoutineBloc>().add(
|
context.read<RoutineBloc>().add(
|
||||||
AddFunctionToRoutine(
|
AddFunctionToRoutine(
|
||||||
[selectedFunctionData],
|
state.addedFunctions,
|
||||||
uniqueCustomId,
|
uniqueCustomId,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -250,18 +250,9 @@ class _EnergyClampDialogState extends State<EnergyClampDialog> {
|
|||||||
onCancel: () => Navigator.pop(context),
|
onCancel: () => Navigator.pop(context),
|
||||||
onConfirm: state.addedFunctions.isNotEmpty
|
onConfirm: state.addedFunctions.isNotEmpty
|
||||||
? () {
|
? () {
|
||||||
final selectedFunctionData = state.addedFunctions.firstWhere(
|
|
||||||
(f) => f.functionCode == state.selectedFunction,
|
|
||||||
orElse: () => DeviceFunctionData(
|
|
||||||
entityId: '',
|
|
||||||
functionCode: state.selectedFunction ?? '',
|
|
||||||
operationName: '',
|
|
||||||
value: null,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
context.read<RoutineBloc>().add(
|
context.read<RoutineBloc>().add(
|
||||||
AddFunctionToRoutine(
|
AddFunctionToRoutine(
|
||||||
[selectedFunctionData],
|
state.addedFunctions,
|
||||||
widget.uniqueCustomId!,
|
widget.uniqueCustomId!,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -27,16 +27,17 @@ class EnergyValueSelectorWidget extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final selectedFn = functions.firstWhere((f) => f.code == selectedFunction);
|
final selectedFn =
|
||||||
|
functions.firstWhere((f) => f.code == selectedFunction);
|
||||||
final values = selectedFn.getOperationalValues();
|
final values = selectedFn.getOperationalValues();
|
||||||
final step = selectedFn.step;
|
final step = selectedFn.step ?? 1.0;
|
||||||
final _unit = selectedFn.unit ?? '';
|
final _unit = selectedFn.unit ?? '';
|
||||||
final (double, double) sliderRange =
|
final (double, double) sliderRange =
|
||||||
(selectedFn.min ?? 0.0, selectedFn.max ?? 100.0);
|
(selectedFn.min ?? 0.0, selectedFn.max ?? 100.0);
|
||||||
|
|
||||||
if (_isSliderFunction(selectedFunction)) {
|
if (_isSliderFunction(selectedFunction)) {
|
||||||
return CustomRoutinesTextbox(
|
return CustomRoutinesTextbox(
|
||||||
withSpecialChar: true,
|
withSpecialChar: false,
|
||||||
currentCondition: functionData.condition,
|
currentCondition: functionData.condition,
|
||||||
dialogType: dialogType,
|
dialogType: dialogType,
|
||||||
sliderRange: sliderRange,
|
sliderRange: sliderRange,
|
||||||
@ -59,14 +60,14 @@ class EnergyValueSelectorWidget extends StatelessWidget {
|
|||||||
entityId: device?.uuid ?? '',
|
entityId: device?.uuid ?? '',
|
||||||
functionCode: selectedFunction,
|
functionCode: selectedFunction,
|
||||||
operationName: functionData.operationName,
|
operationName: functionData.operationName,
|
||||||
value: value,
|
value: value.toInt(),
|
||||||
condition: functionData.condition,
|
condition: functionData.condition,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
unit: _unit,
|
unit: _unit,
|
||||||
dividendOfRange: 1,
|
dividendOfRange: 1,
|
||||||
stepIncreaseAmount: step!,
|
stepIncreaseAmount: step,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,22 +145,9 @@ class TwoGangSwitchHelper {
|
|||||||
// ),
|
// ),
|
||||||
// );
|
// );
|
||||||
// }
|
// }
|
||||||
final selectedFunctionData =
|
|
||||||
state.addedFunctions.firstWhere(
|
|
||||||
(f) =>
|
|
||||||
f.functionCode ==
|
|
||||||
state.selectedFunction,
|
|
||||||
orElse: () => DeviceFunctionData(
|
|
||||||
entityId: '',
|
|
||||||
functionCode:
|
|
||||||
state.selectedFunction ?? '',
|
|
||||||
operationName: '',
|
|
||||||
value: null,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
context.read<RoutineBloc>().add(
|
context.read<RoutineBloc>().add(
|
||||||
AddFunctionToRoutine(
|
AddFunctionToRoutine(
|
||||||
[selectedFunctionData],
|
state.addedFunctions,
|
||||||
uniqueCustomId,
|
uniqueCustomId,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -210,18 +210,9 @@ class _WallPresenceSensorState extends State<WallPresenceSensor> {
|
|||||||
onCancel: () => Navigator.pop(context),
|
onCancel: () => Navigator.pop(context),
|
||||||
onConfirm: state.addedFunctions.isNotEmpty
|
onConfirm: state.addedFunctions.isNotEmpty
|
||||||
? () {
|
? () {
|
||||||
final selectedFunctionData = state.addedFunctions.firstWhere(
|
|
||||||
(f) => f.functionCode == state.selectedFunction,
|
|
||||||
orElse: () => DeviceFunctionData(
|
|
||||||
entityId: '',
|
|
||||||
functionCode: state.selectedFunction ?? '',
|
|
||||||
operationName: '',
|
|
||||||
value: null,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
context.read<RoutineBloc>().add(
|
context.read<RoutineBloc>().add(
|
||||||
AddFunctionToRoutine(
|
AddFunctionToRoutine(
|
||||||
[selectedFunctionData],
|
state.addedFunctions,
|
||||||
widget.uniqueCustomId!,
|
widget.uniqueCustomId!,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -188,18 +188,9 @@ class _WaterHeaterDialogRoutinesState extends State<WaterHeaterDialogRoutines> {
|
|||||||
onCancel: () => Navigator.pop(context),
|
onCancel: () => Navigator.pop(context),
|
||||||
onConfirm: state.addedFunctions.isNotEmpty
|
onConfirm: state.addedFunctions.isNotEmpty
|
||||||
? () {
|
? () {
|
||||||
final selectedFunctionData = state.addedFunctions.firstWhere(
|
|
||||||
(f) => f.functionCode == state.selectedFunction,
|
|
||||||
orElse: () => DeviceFunctionData(
|
|
||||||
entityId: '',
|
|
||||||
functionCode: state.selectedFunction ?? '',
|
|
||||||
operationName: '',
|
|
||||||
value: null,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
context.read<RoutineBloc>().add(
|
context.read<RoutineBloc>().add(
|
||||||
AddFunctionToRoutine(
|
AddFunctionToRoutine(
|
||||||
[selectedFunctionData],
|
state.addedFunctions,
|
||||||
widget.uniqueCustomId!,
|
widget.uniqueCustomId!,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -30,19 +30,19 @@ class ThenContainer extends StatelessWidget {
|
|||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 18, fontWeight: FontWeight.bold)),
|
fontSize: 18, fontWeight: FontWeight.bold)),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
if (state.isLoading && state.isUpdate == true)
|
state.isLoading && state.isUpdate == true
|
||||||
const Center(
|
? const Center(
|
||||||
child: CircularProgressIndicator(),
|
child: CircularProgressIndicator(),
|
||||||
)
|
)
|
||||||
else
|
: Wrap(
|
||||||
Wrap(
|
|
||||||
spacing: 8,
|
spacing: 8,
|
||||||
runSpacing: 8,
|
runSpacing: 8,
|
||||||
children: List.generate(
|
children: List.generate(
|
||||||
state.thenItems.length,
|
state.thenItems.length,
|
||||||
(index) => GestureDetector(
|
(index) => GestureDetector(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
if (state.thenItems[index]['deviceId'] ==
|
if (state.thenItems[index]
|
||||||
|
['deviceId'] ==
|
||||||
'delay') {
|
'delay') {
|
||||||
final result = await DelayHelper
|
final result = await DelayHelper
|
||||||
.showDelayPickerDialog(context,
|
.showDelayPickerDialog(context,
|
||||||
@ -67,15 +67,16 @@ class ThenContainer extends StatelessWidget {
|
|||||||
builder: (BuildContext context) =>
|
builder: (BuildContext context) =>
|
||||||
AutomationDialog(
|
AutomationDialog(
|
||||||
automationName:
|
automationName:
|
||||||
state.thenItems[index]['name']
|
state.thenItems[index]
|
||||||
as String? ??
|
['name'] ??
|
||||||
'Automation',
|
'Automation',
|
||||||
automationId: state.thenItems[index]
|
automationId:
|
||||||
['deviceId'] as String? ??
|
state.thenItems[index]
|
||||||
|
['deviceId'] ??
|
||||||
'',
|
'',
|
||||||
uniqueCustomId: state
|
uniqueCustomId:
|
||||||
.thenItems[index]
|
state.thenItems[index]
|
||||||
['uniqueCustomId'] as String,
|
['uniqueCustomId'],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -84,8 +85,10 @@ class ThenContainer extends StatelessWidget {
|
|||||||
.read<RoutineBloc>()
|
.read<RoutineBloc>()
|
||||||
.add(AddToThenContainer({
|
.add(AddToThenContainer({
|
||||||
...state.thenItems[index],
|
...state.thenItems[index],
|
||||||
'imagePath': Assets.automation,
|
'imagePath':
|
||||||
'title': state.thenItems[index]
|
Assets.automation,
|
||||||
|
'title':
|
||||||
|
state.thenItems[index]
|
||||||
['name'] ??
|
['name'] ??
|
||||||
state.thenItems[index]
|
state.thenItems[index]
|
||||||
['title'],
|
['title'],
|
||||||
@ -99,7 +102,8 @@ class ThenContainer extends StatelessWidget {
|
|||||||
context: context,
|
context: context,
|
||||||
data: state.thenItems[index],
|
data: state.thenItems[index],
|
||||||
removeComparetors: true,
|
removeComparetors: true,
|
||||||
dialogType: 'THEN');
|
dialogType: "THEN");
|
||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
context.read<RoutineBloc>().add(
|
context.read<RoutineBloc>().add(
|
||||||
AddToThenContainer(
|
AddToThenContainer(
|
||||||
@ -111,10 +115,9 @@ class ThenContainer extends StatelessWidget {
|
|||||||
'3G',
|
'3G',
|
||||||
'WPS',
|
'WPS',
|
||||||
'CPS',
|
'CPS',
|
||||||
'GW',
|
"GW",
|
||||||
'NCPS',
|
"NCPS",
|
||||||
'WH',
|
'WH',
|
||||||
'CUR',
|
|
||||||
].contains(state.thenItems[index]
|
].contains(state.thenItems[index]
|
||||||
['productType'])) {
|
['productType'])) {
|
||||||
context.read<RoutineBloc>().add(
|
context.read<RoutineBloc>().add(
|
||||||
@ -124,10 +127,10 @@ class ThenContainer extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
child: DraggableCard(
|
child: DraggableCard(
|
||||||
imagePath: state.thenItems[index]
|
imagePath: state.thenItems[index]
|
||||||
['imagePath'] as String? ??
|
['imagePath'] ??
|
||||||
'',
|
'',
|
||||||
title: state.thenItems[index]['title']
|
title: state.thenItems[index]
|
||||||
as String? ??
|
['title'] ??
|
||||||
'',
|
'',
|
||||||
deviceData: state.thenItems[index],
|
deviceData: state.thenItems[index],
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
@ -140,8 +143,7 @@ class ThenContainer extends StatelessWidget {
|
|||||||
index: index,
|
index: index,
|
||||||
isFromThen: true,
|
isFromThen: true,
|
||||||
key: state.thenItems[index]
|
key: state.thenItems[index]
|
||||||
['uniqueCustomId']
|
['uniqueCustomId']));
|
||||||
as String));
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
))),
|
))),
|
||||||
@ -228,7 +230,7 @@ class ThenContainer extends StatelessWidget {
|
|||||||
context: context,
|
context: context,
|
||||||
data: mutableData,
|
data: mutableData,
|
||||||
removeComparetors: true,
|
removeComparetors: true,
|
||||||
dialogType: 'THEN');
|
dialogType: "THEN");
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
context.read<RoutineBloc>().add(AddToThenContainer(mutableData));
|
context.read<RoutineBloc>().add(AddToThenContainer(mutableData));
|
||||||
} else if (![
|
} else if (![
|
||||||
@ -239,10 +241,9 @@ class ThenContainer extends StatelessWidget {
|
|||||||
'WPS',
|
'WPS',
|
||||||
'GW',
|
'GW',
|
||||||
'CPS',
|
'CPS',
|
||||||
'NCPS',
|
"NCPS",
|
||||||
'WH',
|
"WH",
|
||||||
'PC',
|
'PC',
|
||||||
'CUR',
|
|
||||||
].contains(mutableData['productType'])) {
|
].contains(mutableData['productType'])) {
|
||||||
context.read<RoutineBloc>().add(AddToThenContainer(mutableData));
|
context.read<RoutineBloc>().add(AddToThenContainer(mutableData));
|
||||||
}
|
}
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
class SpaceConnectionModel {
|
|
||||||
final String from;
|
|
||||||
final String to;
|
|
||||||
|
|
||||||
const SpaceConnectionModel({required this.from, required this.to});
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/main_module/models/space_connection_model.dart';
|
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
|
||||||
|
|
||||||
class SpacesConnectionsArrowPainter extends CustomPainter {
|
|
||||||
final List<SpaceConnectionModel> connections;
|
|
||||||
final Map<String, Offset> positions;
|
|
||||||
final double cardWidth = 150.0;
|
|
||||||
final double cardHeight = 90.0;
|
|
||||||
final String? selectedSpaceUuid;
|
|
||||||
|
|
||||||
SpacesConnectionsArrowPainter({
|
|
||||||
required this.connections,
|
|
||||||
required this.positions,
|
|
||||||
this.selectedSpaceUuid,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
void paint(Canvas canvas, Size size) {
|
|
||||||
for (final connection in connections) {
|
|
||||||
final isSelected = connection.to == selectedSpaceUuid;
|
|
||||||
final paint = Paint()
|
|
||||||
..color = isSelected
|
|
||||||
? ColorsManager.primaryColor
|
|
||||||
: ColorsManager.blackColor.withValues(alpha: 0.5)
|
|
||||||
..strokeWidth = 2.0
|
|
||||||
..style = PaintingStyle.stroke;
|
|
||||||
|
|
||||||
final from = positions[connection.from];
|
|
||||||
final to = positions[connection.to];
|
|
||||||
|
|
||||||
if (from != null && to != null) {
|
|
||||||
final startPoint =
|
|
||||||
Offset(from.dx + cardWidth / 2, from.dy + cardHeight - 10);
|
|
||||||
final endPoint = Offset(to.dx + cardWidth / 2, to.dy);
|
|
||||||
|
|
||||||
final path = Path()..moveTo(startPoint.dx, startPoint.dy);
|
|
||||||
|
|
||||||
final controlPoint1 = Offset(startPoint.dx, startPoint.dy + 60);
|
|
||||||
final controlPoint2 = Offset(endPoint.dx, endPoint.dy - 60);
|
|
||||||
|
|
||||||
path.cubicTo(controlPoint1.dx, controlPoint1.dy, controlPoint2.dx,
|
|
||||||
controlPoint2.dy, endPoint.dx, endPoint.dy);
|
|
||||||
|
|
||||||
canvas.drawPath(path, paint);
|
|
||||||
|
|
||||||
final circlePaint = Paint()
|
|
||||||
..color = isSelected
|
|
||||||
? ColorsManager.primaryColor
|
|
||||||
: ColorsManager.blackColor.withValues(alpha: 0.5)
|
|
||||||
..style = PaintingStyle.fill
|
|
||||||
..blendMode = BlendMode.srcIn;
|
|
||||||
canvas.drawCircle(endPoint, 4, circlePaint);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool shouldRepaint(covariant CustomPainter oldDelegate) => true;
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/presentation/bloc/communities_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/presentation/communities_tree_selection_bloc/communities_tree_selection_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/create_community/presentation/create_community_dialog.dart';
|
|
||||||
|
|
||||||
abstract final class SpaceManagementCommunityDialogHelper {
|
|
||||||
static void showCreateDialog(BuildContext context) {
|
|
||||||
showDialog<void>(
|
|
||||||
context: context,
|
|
||||||
builder: (_) => CreateCommunityDialog(
|
|
||||||
title: const SelectableText('Community Name'),
|
|
||||||
onCreateCommunity: (community) {
|
|
||||||
context.read<CommunitiesBloc>().add(
|
|
||||||
InsertCommunity(community),
|
|
||||||
);
|
|
||||||
context.read<CommunitiesTreeSelectionBloc>().add(
|
|
||||||
SelectCommunityEvent(community: community),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
import 'package:equatable/equatable.dart';
|
|
||||||
|
|
||||||
class PaginatedDataModel<T> extends Equatable {
|
|
||||||
const PaginatedDataModel({
|
|
||||||
required this.data,
|
|
||||||
required this.page,
|
|
||||||
required this.size,
|
|
||||||
required this.hasNext,
|
|
||||||
required this.totalItems,
|
|
||||||
required this.totalPages,
|
|
||||||
});
|
|
||||||
|
|
||||||
final List<T> data;
|
|
||||||
final int page;
|
|
||||||
final int size;
|
|
||||||
final bool hasNext;
|
|
||||||
final int totalItems;
|
|
||||||
final int totalPages;
|
|
||||||
|
|
||||||
factory PaginatedDataModel.fromJson(
|
|
||||||
Map<String, dynamic> json,
|
|
||||||
List<T> Function(List<dynamic>) fromJsonList,
|
|
||||||
) {
|
|
||||||
return PaginatedDataModel<T>(
|
|
||||||
data: fromJsonList(json['data'] as List<dynamic>),
|
|
||||||
page: json['page'] as int? ?? 1,
|
|
||||||
size: json['size'] as int? ?? 25,
|
|
||||||
hasNext: json['hasNext'] as bool? ?? false,
|
|
||||||
totalItems: json['totalItem'] as int? ?? 0,
|
|
||||||
totalPages: json['totalPage'] as int? ?? 0,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object?> get props => [
|
|
||||||
data,
|
|
||||||
page,
|
|
||||||
size,
|
|
||||||
hasNext,
|
|
||||||
totalItems,
|
|
||||||
totalPages,
|
|
||||||
];
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/device_managment/shared/navigate_home_grid_view.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/main_module/widgets/space_management_body.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/data/services/debounced_communities_service.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/data/services/remote_communities_service.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/domain/params/load_communities_param.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/presentation/bloc/communities_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/presentation/communities_tree_selection_bloc/communities_tree_selection_bloc.dart';
|
|
||||||
import 'package:syncrow_web/services/api/http_service.dart';
|
|
||||||
import 'package:syncrow_web/utils/theme/responsive_text_theme.dart';
|
|
||||||
import 'package:syncrow_web/web_layout/web_scaffold.dart';
|
|
||||||
|
|
||||||
class SpaceManagementPage extends StatelessWidget {
|
|
||||||
const SpaceManagementPage({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return MultiBlocProvider(
|
|
||||||
providers: [
|
|
||||||
BlocProvider(
|
|
||||||
create: (context) => CommunitiesBloc(
|
|
||||||
communitiesService: DebouncedCommunitiesService(
|
|
||||||
RemoteCommunitiesService(HTTPService()),
|
|
||||||
),
|
|
||||||
)..add(const LoadCommunities(LoadCommunitiesParam())),
|
|
||||||
),
|
|
||||||
BlocProvider(create: (context) => CommunitiesTreeSelectionBloc()),
|
|
||||||
],
|
|
||||||
child: WebScaffold(
|
|
||||||
appBarTitle: Text(
|
|
||||||
'Space Management',
|
|
||||||
style: ResponsiveTextTheme.of(context).deviceManagementTitle,
|
|
||||||
),
|
|
||||||
enableMenuSidebar: false,
|
|
||||||
centerBody: Text(
|
|
||||||
'Community Structure',
|
|
||||||
style: Theme.of(context).textTheme.bodyLarge!.copyWith(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
rightBody: const NavigateHomeGridView(),
|
|
||||||
scaffoldBody: const SpaceManagementBody(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,236 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/main_module/models/space_connection_model.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/main_module/painters/spaces_connections_arrow_painter.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/main_module/widgets/space_card_widget.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/main_module/widgets/space_cell.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/domain/models/community_model.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/domain/models/space_model.dart';
|
|
||||||
|
|
||||||
class CommunityStructureCanvas extends StatefulWidget {
|
|
||||||
const CommunityStructureCanvas({
|
|
||||||
required this.community,
|
|
||||||
super.key,
|
|
||||||
});
|
|
||||||
|
|
||||||
final CommunityModel community;
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<CommunityStructureCanvas> createState() =>_CommunityStructureCanvasState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _CommunityStructureCanvasState extends State<CommunityStructureCanvas>
|
|
||||||
with SingleTickerProviderStateMixin {
|
|
||||||
final Map<String, Offset> _positions = {};
|
|
||||||
final double _cardWidth = 150.0;
|
|
||||||
final double _cardHeight = 90.0;
|
|
||||||
final double _horizontalSpacing = 150.0;
|
|
||||||
final double _verticalSpacing = 120.0;
|
|
||||||
String? _selectedSpaceUuid;
|
|
||||||
|
|
||||||
late TransformationController _transformationController;
|
|
||||||
late AnimationController _animationController;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
_transformationController = TransformationController();
|
|
||||||
_animationController = AnimationController(
|
|
||||||
vsync: this,
|
|
||||||
duration: const Duration(milliseconds: 100),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_transformationController.dispose();
|
|
||||||
_animationController.dispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
void _runAnimation(Matrix4 target) {
|
|
||||||
final animation = Matrix4Tween(
|
|
||||||
begin: _transformationController.value,
|
|
||||||
end: target,
|
|
||||||
).animate(_animationController);
|
|
||||||
|
|
||||||
void listener() {
|
|
||||||
_transformationController.value = animation.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
animation.addListener(listener);
|
|
||||||
_animationController.forward(from: 0).whenCompleteOrCancel(() {
|
|
||||||
animation.removeListener(listener);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void _onSpaceTapped(String spaceUuid) {
|
|
||||||
setState(() {
|
|
||||||
_selectedSpaceUuid = spaceUuid;
|
|
||||||
});
|
|
||||||
|
|
||||||
final position = _positions[spaceUuid];
|
|
||||||
if (position == null) return;
|
|
||||||
|
|
||||||
const scale = 2.0;
|
|
||||||
final viewSize = context.size;
|
|
||||||
if (viewSize == null) return;
|
|
||||||
|
|
||||||
final x = -position.dx * scale + (viewSize.width / 2) - (_cardWidth * scale / 2);
|
|
||||||
final y =
|
|
||||||
-position.dy * scale + (viewSize.height / 2) - (_cardHeight * scale / 2);
|
|
||||||
|
|
||||||
final matrix = Matrix4.identity()
|
|
||||||
..translate(x, y)
|
|
||||||
..scale(scale);
|
|
||||||
|
|
||||||
_runAnimation(matrix);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _resetSelectionAndZoom() {
|
|
||||||
setState(() {
|
|
||||||
_selectedSpaceUuid = null;
|
|
||||||
});
|
|
||||||
_runAnimation(Matrix4.identity());
|
|
||||||
}
|
|
||||||
|
|
||||||
void _calculateLayout(
|
|
||||||
List<SpaceModel> spaces,
|
|
||||||
int depth,
|
|
||||||
Map<int, double> levelXOffset,
|
|
||||||
) {
|
|
||||||
for (final space in spaces) {
|
|
||||||
double childSubtreeWidth = 0;
|
|
||||||
if (space.children.isNotEmpty) {
|
|
||||||
_calculateLayout(space.children, depth + 1, levelXOffset);
|
|
||||||
final firstChildPos = _positions[space.children.first.uuid];
|
|
||||||
final lastChildPos = _positions[space.children.last.uuid];
|
|
||||||
if (firstChildPos != null && lastChildPos != null) {
|
|
||||||
childSubtreeWidth = (lastChildPos.dx + _cardWidth) - firstChildPos.dx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final currentX = levelXOffset.putIfAbsent(depth, () => 0.0);
|
|
||||||
double? x;
|
|
||||||
|
|
||||||
if (space.children.isNotEmpty) {
|
|
||||||
final firstChildPos = _positions[space.children.first.uuid]!;
|
|
||||||
x = firstChildPos.dx + (childSubtreeWidth - _cardWidth) / 2;
|
|
||||||
} else {
|
|
||||||
x = currentX;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (x < currentX) {
|
|
||||||
final shiftX = currentX - x;
|
|
||||||
_shiftSubtree(space, shiftX);
|
|
||||||
final keysToShift = levelXOffset.keys.where((d) => d > depth).toList();
|
|
||||||
for (final key in keysToShift) {
|
|
||||||
levelXOffset[key] = levelXOffset[key]! + shiftX;
|
|
||||||
}
|
|
||||||
x += shiftX;
|
|
||||||
}
|
|
||||||
|
|
||||||
final y = depth * (_verticalSpacing + _cardHeight);
|
|
||||||
_positions[space.uuid] = Offset(x, y);
|
|
||||||
levelXOffset[depth] = x + _cardWidth + _horizontalSpacing;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _shiftSubtree(SpaceModel space, double shiftX) {
|
|
||||||
if (_positions.containsKey(space.uuid)) {
|
|
||||||
_positions[space.uuid] = _positions[space.uuid]!.translate(shiftX, 0);
|
|
||||||
}
|
|
||||||
for (final child in space.children) {
|
|
||||||
_shiftSubtree(child, shiftX);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Widget> _buildTreeWidgets() {
|
|
||||||
_positions.clear();
|
|
||||||
final community = widget.community;
|
|
||||||
|
|
||||||
_calculateLayout(community.spaces, 0, {});
|
|
||||||
|
|
||||||
final widgets = <Widget>[];
|
|
||||||
final connections = <SpaceConnectionModel>[];
|
|
||||||
_generateWidgets(community.spaces, widgets, connections);
|
|
||||||
|
|
||||||
return [
|
|
||||||
CustomPaint(
|
|
||||||
painter: SpacesConnectionsArrowPainter(
|
|
||||||
connections: connections,
|
|
||||||
positions: _positions,
|
|
||||||
selectedSpaceUuid: _selectedSpaceUuid,
|
|
||||||
),
|
|
||||||
child: Stack(alignment: AlignmentDirectional.center, children: widgets),
|
|
||||||
),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
void _generateWidgets(
|
|
||||||
List<SpaceModel> spaces,
|
|
||||||
List<Widget> widgets,
|
|
||||||
List<SpaceConnectionModel> connections,
|
|
||||||
) {
|
|
||||||
for (final space in spaces) {
|
|
||||||
final position = _positions[space.uuid];
|
|
||||||
if (position == null) continue;
|
|
||||||
|
|
||||||
widgets.add(
|
|
||||||
Positioned(
|
|
||||||
left: position.dx,
|
|
||||||
top: position.dy,
|
|
||||||
width: _cardWidth,
|
|
||||||
height: _cardHeight,
|
|
||||||
child: SpaceCardWidget(
|
|
||||||
index: spaces.indexOf(space),
|
|
||||||
onPositionChanged: (newPosition) {},
|
|
||||||
buildSpaceContainer: (index) {
|
|
||||||
return Opacity(
|
|
||||||
opacity: 1.0,
|
|
||||||
child: SpaceCell(
|
|
||||||
index: index,
|
|
||||||
onTap: () => _onSpaceTapped(space.uuid),
|
|
||||||
icon: space.icon,
|
|
||||||
name: space.spaceName,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
screenSize: MediaQuery.sizeOf(context),
|
|
||||||
position: position,
|
|
||||||
isHovered: false,
|
|
||||||
onHoverChanged: (int index, bool isHovered) {},
|
|
||||||
onButtonTap: (int index, Offset newPosition) {},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
for (final child in space.children) {
|
|
||||||
connections.add(SpaceConnectionModel(from: space.uuid, to: child.uuid));
|
|
||||||
}
|
|
||||||
_generateWidgets(space.children, widgets, connections);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final treeWidgets = _buildTreeWidgets();
|
|
||||||
return InteractiveViewer(
|
|
||||||
transformationController: _transformationController,
|
|
||||||
boundaryMargin: EdgeInsets.symmetric(
|
|
||||||
horizontal: MediaQuery.sizeOf(context).width * 0.3,
|
|
||||||
vertical: MediaQuery.sizeOf(context).height * 0.2,
|
|
||||||
),
|
|
||||||
minScale: 0.5,
|
|
||||||
maxScale: 3.0,
|
|
||||||
constrained: false,
|
|
||||||
child: GestureDetector(
|
|
||||||
onTap: _resetSelectionAndZoom,
|
|
||||||
child: SizedBox(
|
|
||||||
width: MediaQuery.sizeOf(context).width * 2,
|
|
||||||
height: MediaQuery.sizeOf(context).height * 2,
|
|
||||||
child: Stack(children: treeWidgets),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
|
||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
|
||||||
|
|
||||||
class CommunityTemplateCell extends StatelessWidget {
|
|
||||||
const CommunityTemplateCell({
|
|
||||||
super.key,
|
|
||||||
required this.onTap,
|
|
||||||
required this.title,
|
|
||||||
});
|
|
||||||
|
|
||||||
final void Function() onTap;
|
|
||||||
final Widget title;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return GestureDetector(
|
|
||||||
onTap: onTap,
|
|
||||||
child: Column(
|
|
||||||
spacing: 8,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: AspectRatio(
|
|
||||||
aspectRatio: 2.0,
|
|
||||||
child: Container(
|
|
||||||
decoration: ShapeDecoration(
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
side: const BorderSide(
|
|
||||||
width: 4,
|
|
||||||
strokeAlign: BorderSide.strokeAlignOutside,
|
|
||||||
color: ColorsManager.borderColor,
|
|
||||||
),
|
|
||||||
borderRadius: BorderRadius.circular(5),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
DefaultTextStyle(
|
|
||||||
style: context.textTheme.bodyLarge!.copyWith(
|
|
||||||
color: ColorsManager.blackColor,
|
|
||||||
),
|
|
||||||
child: title,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
|
||||||
|
|
||||||
class CreateSpaceButton extends StatelessWidget {
|
|
||||||
const CreateSpaceButton({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return GestureDetector(
|
|
||||||
onTap: () {},
|
|
||||||
child: Container(
|
|
||||||
height: 60,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.white,
|
|
||||||
borderRadius: BorderRadius.circular(20),
|
|
||||||
boxShadow: [
|
|
||||||
BoxShadow(
|
|
||||||
color: Colors.grey.withValues(alpha: 0.5),
|
|
||||||
spreadRadius: 5,
|
|
||||||
blurRadius: 7,
|
|
||||||
offset: const Offset(0, 3),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
child: Center(
|
|
||||||
child: Container(
|
|
||||||
width: 40,
|
|
||||||
height: 40,
|
|
||||||
decoration: const BoxDecoration(
|
|
||||||
color: ColorsManager.boxColor,
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
),
|
|
||||||
child: const Icon(
|
|
||||||
Icons.add,
|
|
||||||
color: Colors.blue,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
|
||||||
|
|
||||||
class PlusButtonWidget extends StatelessWidget {
|
|
||||||
final int index;
|
|
||||||
final String direction;
|
|
||||||
final Offset offset;
|
|
||||||
final void Function(int index, Offset newPosition) onButtonTap;
|
|
||||||
|
|
||||||
const PlusButtonWidget({
|
|
||||||
super.key,
|
|
||||||
required this.index,
|
|
||||||
required this.direction,
|
|
||||||
required this.offset,
|
|
||||||
required this.onButtonTap,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return GestureDetector(
|
|
||||||
onTap: () {
|
|
||||||
if (direction == 'down') {
|
|
||||||
onButtonTap(index, const Offset(0, 150));
|
|
||||||
} else {
|
|
||||||
onButtonTap(index, const Offset(150, 0));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: Container(
|
|
||||||
width: 30,
|
|
||||||
height: 30,
|
|
||||||
decoration: const BoxDecoration(
|
|
||||||
color: ColorsManager.spaceColor,
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
),
|
|
||||||
child: const Icon(
|
|
||||||
Icons.add,
|
|
||||||
color: ColorsManager.whiteColors,
|
|
||||||
size: 20,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,65 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/main_module/widgets/plus_button_widget.dart';
|
|
||||||
|
|
||||||
class SpaceCardWidget extends StatelessWidget {
|
|
||||||
final int index;
|
|
||||||
final Size screenSize;
|
|
||||||
final Offset position;
|
|
||||||
final bool isHovered;
|
|
||||||
final void Function(int index, bool isHovered) onHoverChanged;
|
|
||||||
final void Function(int index, Offset newPosition) onButtonTap;
|
|
||||||
final Widget Function(int index) buildSpaceContainer;
|
|
||||||
final ValueChanged<Offset> onPositionChanged;
|
|
||||||
|
|
||||||
const SpaceCardWidget({
|
|
||||||
super.key,
|
|
||||||
required this.index,
|
|
||||||
required this.onPositionChanged,
|
|
||||||
required this.screenSize,
|
|
||||||
required this.position,
|
|
||||||
required this.isHovered,
|
|
||||||
required this.onHoverChanged,
|
|
||||||
required this.onButtonTap,
|
|
||||||
required this.buildSpaceContainer,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return MouseRegion(
|
|
||||||
onEnter: (_) => onHoverChanged(index, true),
|
|
||||||
onExit: (_) => onHoverChanged(index, false),
|
|
||||||
child: SizedBox(
|
|
||||||
width: 150,
|
|
||||||
height: 90,
|
|
||||||
child: Stack(
|
|
||||||
clipBehavior: Clip.none,
|
|
||||||
alignment: Alignment.center,
|
|
||||||
children: [
|
|
||||||
buildSpaceContainer(index),
|
|
||||||
|
|
||||||
if (isHovered)
|
|
||||||
Positioned(
|
|
||||||
bottom: 0,
|
|
||||||
child: PlusButtonWidget(
|
|
||||||
index: index,
|
|
||||||
direction: 'down',
|
|
||||||
offset: Offset.zero,
|
|
||||||
onButtonTap: onButtonTap,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (isHovered)
|
|
||||||
Positioned(
|
|
||||||
right: -15,
|
|
||||||
child: PlusButtonWidget(
|
|
||||||
index: index,
|
|
||||||
direction: 'right',
|
|
||||||
offset: Offset.zero,
|
|
||||||
onButtonTap: onButtonTap,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,88 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_svg/svg.dart';
|
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
|
||||||
|
|
||||||
class SpaceCell extends StatelessWidget {
|
|
||||||
final int index;
|
|
||||||
final String icon;
|
|
||||||
final String name;
|
|
||||||
final VoidCallback? onDoubleTap;
|
|
||||||
final VoidCallback? onTap;
|
|
||||||
|
|
||||||
const SpaceCell({
|
|
||||||
super.key,
|
|
||||||
required this.index,
|
|
||||||
required this.icon,
|
|
||||||
required this.name,
|
|
||||||
this.onTap,
|
|
||||||
this.onDoubleTap,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final theme = Theme.of(context);
|
|
||||||
|
|
||||||
return GestureDetector(
|
|
||||||
onDoubleTap: onDoubleTap,
|
|
||||||
onTap: onTap,
|
|
||||||
child: Container(
|
|
||||||
width: 150,
|
|
||||||
height: 70,
|
|
||||||
decoration: _containerDecoration(),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
_buildIconContainer(),
|
|
||||||
const SizedBox(width: 10),
|
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
name,
|
|
||||||
style: theme.textTheme.bodyLarge?.copyWith(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: ColorsManager.blackColor,
|
|
||||||
),
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildIconContainer() {
|
|
||||||
return Container(
|
|
||||||
width: 40,
|
|
||||||
height: double.infinity,
|
|
||||||
decoration: const BoxDecoration(
|
|
||||||
color: ColorsManager.spaceColor,
|
|
||||||
borderRadius: BorderRadius.only(
|
|
||||||
topLeft: Radius.circular(15),
|
|
||||||
bottomLeft: Radius.circular(15),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Center(
|
|
||||||
child: SvgPicture.asset(
|
|
||||||
icon,
|
|
||||||
color: ColorsManager.whiteColors,
|
|
||||||
width: 24,
|
|
||||||
height: 24,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
BoxDecoration _containerDecoration() {
|
|
||||||
return BoxDecoration(
|
|
||||||
color: ColorsManager.whiteColors,
|
|
||||||
borderRadius: BorderRadius.circular(15),
|
|
||||||
boxShadow: [
|
|
||||||
BoxShadow(
|
|
||||||
color: ColorsManager.lightGrayColor.withValues(alpha: 0.5),
|
|
||||||
spreadRadius: 2,
|
|
||||||
blurRadius: 5,
|
|
||||||
offset: const Offset(0, 3),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/main_module/widgets/space_management_community_structure.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/main_module/widgets/space_management_templates_view.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/presentation/communities_tree_selection_bloc/communities_tree_selection_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/presentation/widgets/space_management_communities_tree.dart';
|
|
||||||
|
|
||||||
class SpaceManagementBody extends StatelessWidget {
|
|
||||||
const SpaceManagementBody({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Row(
|
|
||||||
children: [
|
|
||||||
const SpaceManagementCommunitiesTree(),
|
|
||||||
Expanded(
|
|
||||||
child: BlocBuilder<CommunitiesTreeSelectionBloc,
|
|
||||||
CommunitiesTreeSelectionState>(
|
|
||||||
buildWhen: (previous, current) =>
|
|
||||||
previous.selectedCommunity != current.selectedCommunity,
|
|
||||||
builder: (context, state) => Visibility(
|
|
||||||
visible: state.selectedCommunity == null,
|
|
||||||
replacement: const SpaceManagementCommunityStructure(),
|
|
||||||
child: const SpaceManagementTemplatesView(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/main_module/widgets/community_structure_canvas.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/main_module/widgets/create_space_button.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/presentation/communities_tree_selection_bloc/communities_tree_selection_bloc.dart';
|
|
||||||
|
|
||||||
class SpaceManagementCommunityStructure extends StatelessWidget {
|
|
||||||
const SpaceManagementCommunityStructure({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final selectedCommunity =
|
|
||||||
context.watch<CommunitiesTreeSelectionBloc>().state.selectedCommunity!;
|
|
||||||
const spacer = Spacer(flex: 10);
|
|
||||||
return Visibility(
|
|
||||||
visible: selectedCommunity.spaces.isNotEmpty,
|
|
||||||
replacement: const Row(
|
|
||||||
children: [spacer, Expanded(child: CreateSpaceButton()), spacer]),
|
|
||||||
child: CommunityStructureCanvas(community: selectedCommunity),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/main_module/shared/helpers/space_management_community_dialog_helper.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/main_module/widgets/community_template_cell.dart';
|
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
|
||||||
|
|
||||||
class SpaceManagementTemplatesView extends StatelessWidget {
|
|
||||||
const SpaceManagementTemplatesView({super.key});
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Expanded(
|
|
||||||
child: ColoredBox(
|
|
||||||
color: ColorsManager.whiteColors,
|
|
||||||
child: GridView.builder(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 40, vertical: 20),
|
|
||||||
gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
|
|
||||||
maxCrossAxisExtent: 400,
|
|
||||||
mainAxisSpacing: 10,
|
|
||||||
crossAxisSpacing: 10,
|
|
||||||
childAspectRatio: 2.0,
|
|
||||||
),
|
|
||||||
itemCount: _gridItems(context).length,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
final model = _gridItems(context)[index];
|
|
||||||
return CommunityTemplateCell(
|
|
||||||
onTap: model.onTap,
|
|
||||||
title: model.title,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<_CommunityTemplateModel> _gridItems(BuildContext context) {
|
|
||||||
return [
|
|
||||||
_CommunityTemplateModel(
|
|
||||||
title: const Text('Blank'),
|
|
||||||
onTap: () => SpaceManagementCommunityDialogHelper.showCreateDialog(context),
|
|
||||||
),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _CommunityTemplateModel {
|
|
||||||
final Widget title;
|
|
||||||
final void Function() onTap;
|
|
||||||
|
|
||||||
_CommunityTemplateModel({
|
|
||||||
required this.title,
|
|
||||||
required this.onTap,
|
|
||||||
});
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
import 'dart:async';
|
|
||||||
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/domain/params/load_communities_param.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/domain/services/communities_service.dart';
|
|
||||||
|
|
||||||
final class DebouncedCommunitiesService implements CommunitiesService {
|
|
||||||
DebouncedCommunitiesService(
|
|
||||||
this._decoratee, {
|
|
||||||
this.debounceDuration = const Duration(milliseconds: 500),
|
|
||||||
});
|
|
||||||
|
|
||||||
final CommunitiesService _decoratee;
|
|
||||||
final Duration debounceDuration;
|
|
||||||
|
|
||||||
Timer? _debounceTimer;
|
|
||||||
late Completer<CommunitiesPaginationModel>? _completer;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<CommunitiesPaginationModel> getCommunity(
|
|
||||||
LoadCommunitiesParam param,
|
|
||||||
) async {
|
|
||||||
_debounceTimer?.cancel();
|
|
||||||
|
|
||||||
_completer = Completer<CommunitiesPaginationModel>();
|
|
||||||
final currentCompleter = _completer!;
|
|
||||||
|
|
||||||
_debounceTimer = Timer(debounceDuration, () async {
|
|
||||||
try {
|
|
||||||
final result = await _decoratee.getCommunity(param);
|
|
||||||
if (!currentCompleter.isCompleted) {
|
|
||||||
currentCompleter.complete(result);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
if (!currentCompleter.isCompleted) {
|
|
||||||
currentCompleter.completeError(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return currentCompleter.future;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
import 'package:dio/dio.dart';
|
|
||||||
import 'package:syncrow_web/pages/common/bloc/project_manager.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/domain/models/community_model.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/domain/params/load_communities_param.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/domain/services/communities_service.dart';
|
|
||||||
import 'package:syncrow_web/services/api/api_exception.dart';
|
|
||||||
import 'package:syncrow_web/services/api/http_service.dart';
|
|
||||||
import 'package:syncrow_web/utils/constants/api_const.dart';
|
|
||||||
|
|
||||||
class RemoteCommunitiesService implements CommunitiesService {
|
|
||||||
const RemoteCommunitiesService(this._httpService);
|
|
||||||
|
|
||||||
final HTTPService _httpService;
|
|
||||||
|
|
||||||
static const _defaultErrorMessage = 'Failed to load communities';
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<CommunitiesPaginationModel> getCommunity(
|
|
||||||
LoadCommunitiesParam param,
|
|
||||||
) async {
|
|
||||||
try {
|
|
||||||
final response = await _httpService.get(
|
|
||||||
path: await _makeUrl(),
|
|
||||||
queryParameters: {
|
|
||||||
'page': param.page,
|
|
||||||
'size': param.size,
|
|
||||||
'includeSpaces': param.includeSpaces,
|
|
||||||
if (param.search.isNotEmpty && param.search != 'null')
|
|
||||||
'search': param.search,
|
|
||||||
},
|
|
||||||
expectedResponseModel: (json) => CommunitiesPaginationModel.fromJson(
|
|
||||||
json as Map<String, dynamic>,
|
|
||||||
CommunityModel.fromJsonList,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
return response;
|
|
||||||
} on DioException catch (e) {
|
|
||||||
final message = e.response?.data as Map<String, dynamic>?;
|
|
||||||
final error = message?['error'] as Map<String, dynamic>?;
|
|
||||||
final errorMessage = error?['error'] as String? ?? '';
|
|
||||||
throw APIException(errorMessage);
|
|
||||||
} catch (e) {
|
|
||||||
final formattedErrorMessage = [_defaultErrorMessage, '$e'].join(': ');
|
|
||||||
throw APIException(formattedErrorMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<String> _makeUrl() async {
|
|
||||||
final projectUuid = await ProjectManager.getProjectUUID();
|
|
||||||
if (projectUuid == null) throw APIException('Project UUID is required');
|
|
||||||
return ApiEndpoints.getCommunityListv2.replaceAll(
|
|
||||||
'{projectId}',
|
|
||||||
projectUuid,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
import 'package:equatable/equatable.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/domain/models/space_model.dart';
|
|
||||||
|
|
||||||
class CommunityModel extends Equatable {
|
|
||||||
final String uuid;
|
|
||||||
final String name;
|
|
||||||
final DateTime createdAt;
|
|
||||||
final DateTime updatedAt;
|
|
||||||
final String description;
|
|
||||||
final String externalId;
|
|
||||||
final List<SpaceModel> spaces;
|
|
||||||
|
|
||||||
const CommunityModel({
|
|
||||||
required this.uuid,
|
|
||||||
required this.name,
|
|
||||||
required this.createdAt,
|
|
||||||
required this.updatedAt,
|
|
||||||
required this.description,
|
|
||||||
required this.externalId,
|
|
||||||
required this.spaces,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory CommunityModel.fromJson(Map<String, dynamic> json) {
|
|
||||||
return CommunityModel(
|
|
||||||
uuid: json['uuid'] as String,
|
|
||||||
name: json['name'] as String,
|
|
||||||
createdAt: DateTime.parse(json['createdAt'] as String),
|
|
||||||
updatedAt: DateTime.parse(json['updatedAt'] as String),
|
|
||||||
description: json['description'] as String,
|
|
||||||
externalId: json['externalId']?.toString() ?? '',
|
|
||||||
spaces: (json['spaces'] as List<dynamic>? ?? <dynamic>[])
|
|
||||||
.map((e) => SpaceModel.fromJson(e as Map<String, dynamic>))
|
|
||||||
.toList(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
static List<CommunityModel> fromJsonList(List<dynamic> json) {
|
|
||||||
return json
|
|
||||||
.map((e) => CommunityModel.fromJson(e as Map<String, dynamic>))
|
|
||||||
.toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object?> get props => [uuid, name, spaces];
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
import 'package:equatable/equatable.dart';
|
|
||||||
|
|
||||||
class SpaceModel extends Equatable {
|
|
||||||
final String uuid;
|
|
||||||
final DateTime? createdAt;
|
|
||||||
final DateTime? updatedAt;
|
|
||||||
final String spaceName;
|
|
||||||
final String icon;
|
|
||||||
final List<SpaceModel> children;
|
|
||||||
final SpaceModel? parent;
|
|
||||||
|
|
||||||
const SpaceModel({
|
|
||||||
required this.uuid,
|
|
||||||
required this.createdAt,
|
|
||||||
required this.updatedAt,
|
|
||||||
required this.spaceName,
|
|
||||||
required this.icon,
|
|
||||||
required this.children,
|
|
||||||
required this.parent,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory SpaceModel.fromJson(Map<String, dynamic> json) {
|
|
||||||
return SpaceModel(
|
|
||||||
uuid: json['uuid'] as String? ?? '',
|
|
||||||
createdAt: DateTime.tryParse(json['createdAt'] as String? ?? ''),
|
|
||||||
updatedAt: DateTime.tryParse(json['updatedAt'] as String? ?? ''),
|
|
||||||
spaceName: json['spaceName'] as String? ?? '',
|
|
||||||
icon: json['icon'] as String? ?? 'assets/icons/location_icon.svg',
|
|
||||||
children: (json['children'] as List<dynamic>?)
|
|
||||||
?.map((e) => SpaceModel.fromJson(e as Map<String, dynamic>))
|
|
||||||
.toList() ??
|
|
||||||
[],
|
|
||||||
parent: json['parent'] != null
|
|
||||||
? SpaceModel.fromJson(json['parent'] as Map<String, dynamic>)
|
|
||||||
: null,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object?> get props => [uuid, spaceName, icon, children];
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
import 'package:equatable/equatable.dart';
|
|
||||||
|
|
||||||
class LoadCommunitiesParam extends Equatable {
|
|
||||||
const LoadCommunitiesParam({
|
|
||||||
this.page = 1,
|
|
||||||
this.size = 25,
|
|
||||||
this.search = '',
|
|
||||||
this.includeSpaces = true,
|
|
||||||
});
|
|
||||||
|
|
||||||
final int page;
|
|
||||||
final int size;
|
|
||||||
final String search;
|
|
||||||
final bool includeSpaces;
|
|
||||||
|
|
||||||
LoadCommunitiesParam copyWith({
|
|
||||||
int? page,
|
|
||||||
int? size,
|
|
||||||
String? search,
|
|
||||||
bool? includeSpaces,
|
|
||||||
}) {
|
|
||||||
return LoadCommunitiesParam(
|
|
||||||
page: page ?? this.page,
|
|
||||||
size: size ?? this.size,
|
|
||||||
search: search ?? this.search,
|
|
||||||
includeSpaces: includeSpaces ?? this.includeSpaces,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object?> get props => [page, size, search, includeSpaces];
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
import 'package:syncrow_web/pages/space_management_v2/main_module/shared/models/paginated_data_model.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/domain/models/community_model.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/domain/params/load_communities_param.dart';
|
|
||||||
|
|
||||||
typedef CommunitiesPaginationModel = PaginatedDataModel<CommunityModel>;
|
|
||||||
|
|
||||||
abstract class CommunitiesService {
|
|
||||||
Future<CommunitiesPaginationModel> getCommunity(LoadCommunitiesParam param);
|
|
||||||
}
|
|
@ -1,117 +0,0 @@
|
|||||||
import 'package:equatable/equatable.dart';
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/domain/models/community_model.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/domain/params/load_communities_param.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/domain/services/communities_service.dart';
|
|
||||||
import 'package:syncrow_web/services/api/api_exception.dart';
|
|
||||||
|
|
||||||
part 'communities_event.dart';
|
|
||||||
part 'communities_state.dart';
|
|
||||||
|
|
||||||
class CommunitiesBloc extends Bloc<CommunitiesEvent, CommunitiesState> {
|
|
||||||
CommunitiesBloc({
|
|
||||||
required CommunitiesService communitiesService,
|
|
||||||
}) : _communitiesService = communitiesService,
|
|
||||||
super(const CommunitiesState()) {
|
|
||||||
on<LoadCommunities>(_onLoadCommunities);
|
|
||||||
on<LoadMoreCommunities>(_onLoadMoreCommunities);
|
|
||||||
on<InsertCommunity>(_onInsertCommunity);
|
|
||||||
}
|
|
||||||
|
|
||||||
final CommunitiesService _communitiesService;
|
|
||||||
|
|
||||||
Future<void> _onLoadCommunities(
|
|
||||||
LoadCommunities event,
|
|
||||||
Emitter<CommunitiesState> emit,
|
|
||||||
) async {
|
|
||||||
try {
|
|
||||||
emit(
|
|
||||||
state.copyWith(status: CommunitiesStatus.loading),
|
|
||||||
);
|
|
||||||
|
|
||||||
final paginationResponse = await _communitiesService.getCommunity(
|
|
||||||
event.param,
|
|
||||||
);
|
|
||||||
|
|
||||||
emit(
|
|
||||||
CommunitiesState(
|
|
||||||
status: CommunitiesStatus.success,
|
|
||||||
communities: paginationResponse.data,
|
|
||||||
hasNext: paginationResponse.hasNext,
|
|
||||||
currentPage: paginationResponse.page,
|
|
||||||
searchQuery: event.param.search,
|
|
||||||
isLoadingMore: false,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} on APIException catch (e) {
|
|
||||||
_onApiException(e, emit);
|
|
||||||
} catch (e) {
|
|
||||||
_onError(e, emit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _onLoadMoreCommunities(
|
|
||||||
LoadMoreCommunities event,
|
|
||||||
Emitter<CommunitiesState> emit,
|
|
||||||
) async {
|
|
||||||
if (!state.hasNext || state.isLoadingMore) return;
|
|
||||||
|
|
||||||
try {
|
|
||||||
emit(state.copyWith(isLoadingMore: true));
|
|
||||||
|
|
||||||
final param = LoadCommunitiesParam(
|
|
||||||
page: state.currentPage + 1,
|
|
||||||
search: state.searchQuery,
|
|
||||||
);
|
|
||||||
|
|
||||||
final paginationResponse = await _communitiesService.getCommunity(param);
|
|
||||||
|
|
||||||
final updatedCommunities = List<CommunityModel>.from(state.communities)
|
|
||||||
..addAll(paginationResponse.data);
|
|
||||||
|
|
||||||
emit(
|
|
||||||
state.copyWith(
|
|
||||||
status: CommunitiesStatus.success,
|
|
||||||
communities: updatedCommunities,
|
|
||||||
hasNext: paginationResponse.hasNext,
|
|
||||||
currentPage: paginationResponse.page,
|
|
||||||
isLoadingMore: false,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} on APIException catch (e) {
|
|
||||||
_onApiException(e, emit);
|
|
||||||
} catch (e) {
|
|
||||||
_onError(e, emit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _onApiException(
|
|
||||||
APIException e,
|
|
||||||
Emitter<CommunitiesState> emit,
|
|
||||||
) {
|
|
||||||
emit(
|
|
||||||
state.copyWith(
|
|
||||||
status: CommunitiesStatus.failure,
|
|
||||||
isLoadingMore: false,
|
|
||||||
errorMessage: e.message,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _onError(Object e, Emitter<CommunitiesState> emit) {
|
|
||||||
emit(
|
|
||||||
state.copyWith(
|
|
||||||
status: CommunitiesStatus.failure,
|
|
||||||
isLoadingMore: false,
|
|
||||||
errorMessage: e.toString(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _onInsertCommunity(
|
|
||||||
InsertCommunity event,
|
|
||||||
Emitter<CommunitiesState> emit,
|
|
||||||
) {
|
|
||||||
emit(state.copyWith(communities: [event.community, ...state.communities]));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
part of 'communities_bloc.dart';
|
|
||||||
|
|
||||||
sealed class CommunitiesEvent extends Equatable {
|
|
||||||
const CommunitiesEvent();
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object?> get props => [];
|
|
||||||
}
|
|
||||||
|
|
||||||
class LoadCommunities extends CommunitiesEvent {
|
|
||||||
const LoadCommunities(this.param);
|
|
||||||
|
|
||||||
final LoadCommunitiesParam param;
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object?> get props => [param];
|
|
||||||
}
|
|
||||||
|
|
||||||
class LoadMoreCommunities extends CommunitiesEvent {
|
|
||||||
const LoadMoreCommunities();
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object?> get props => [];
|
|
||||||
}
|
|
||||||
|
|
||||||
final class InsertCommunity extends CommunitiesEvent {
|
|
||||||
const InsertCommunity(this.community);
|
|
||||||
|
|
||||||
final CommunityModel community;
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object?> get props => [community];
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
part of 'communities_bloc.dart';
|
|
||||||
|
|
||||||
enum CommunitiesStatus { initial, loading, success, failure }
|
|
||||||
|
|
||||||
final class CommunitiesState extends Equatable {
|
|
||||||
const CommunitiesState({
|
|
||||||
this.status = CommunitiesStatus.initial,
|
|
||||||
this.communities = const [],
|
|
||||||
this.errorMessage,
|
|
||||||
this.isLoadingMore = false,
|
|
||||||
this.hasNext = false,
|
|
||||||
this.currentPage = 1,
|
|
||||||
this.searchQuery = '',
|
|
||||||
});
|
|
||||||
|
|
||||||
final CommunitiesStatus status;
|
|
||||||
final List<CommunityModel> communities;
|
|
||||||
final String? errorMessage;
|
|
||||||
final bool isLoadingMore;
|
|
||||||
final bool hasNext;
|
|
||||||
final int currentPage;
|
|
||||||
final String searchQuery;
|
|
||||||
|
|
||||||
CommunitiesState copyWith({
|
|
||||||
CommunitiesStatus? status,
|
|
||||||
List<CommunityModel>? communities,
|
|
||||||
String? errorMessage,
|
|
||||||
bool? isLoadingMore,
|
|
||||||
bool? hasNext,
|
|
||||||
int? currentPage,
|
|
||||||
String? searchQuery,
|
|
||||||
}) {
|
|
||||||
return CommunitiesState(
|
|
||||||
status: status ?? this.status,
|
|
||||||
communities: communities ?? this.communities,
|
|
||||||
errorMessage: errorMessage ?? this.errorMessage,
|
|
||||||
isLoadingMore: isLoadingMore ?? this.isLoadingMore,
|
|
||||||
hasNext: hasNext ?? this.hasNext,
|
|
||||||
currentPage: currentPage ?? this.currentPage,
|
|
||||||
searchQuery: searchQuery ?? this.searchQuery,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object?> get props => [
|
|
||||||
status,
|
|
||||||
communities,
|
|
||||||
errorMessage,
|
|
||||||
isLoadingMore,
|
|
||||||
hasNext,
|
|
||||||
currentPage,
|
|
||||||
searchQuery,
|
|
||||||
];
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
import 'package:bloc/bloc.dart';
|
|
||||||
import 'package:equatable/equatable.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/domain/models/community_model.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/domain/models/space_model.dart';
|
|
||||||
|
|
||||||
part 'communities_tree_selection_event.dart';
|
|
||||||
part 'communities_tree_selection_state.dart';
|
|
||||||
|
|
||||||
class CommunitiesTreeSelectionBloc
|
|
||||||
extends Bloc<CommunitiesTreeSelectionEvent, CommunitiesTreeSelectionState> {
|
|
||||||
CommunitiesTreeSelectionBloc() : super(const CommunitiesTreeSelectionState()) {
|
|
||||||
on<SelectCommunityEvent>(_onSelectCommunity);
|
|
||||||
on<SelectSpaceEvent>(_onSelectSpace);
|
|
||||||
on<ClearCommunitiesTreeSelectionEvent>(_onClearSelection);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _onSelectCommunity(
|
|
||||||
SelectCommunityEvent event,
|
|
||||||
Emitter<CommunitiesTreeSelectionState> emit,
|
|
||||||
) {
|
|
||||||
emit(
|
|
||||||
CommunitiesTreeSelectionState(
|
|
||||||
selectedCommunity: event.community,
|
|
||||||
selectedSpace: null,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _onSelectSpace(
|
|
||||||
SelectSpaceEvent event,
|
|
||||||
Emitter<CommunitiesTreeSelectionState> emit,
|
|
||||||
) {
|
|
||||||
emit(
|
|
||||||
CommunitiesTreeSelectionState(
|
|
||||||
selectedCommunity: event.community,
|
|
||||||
selectedSpace: event.space,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _onClearSelection(
|
|
||||||
ClearCommunitiesTreeSelectionEvent event,
|
|
||||||
Emitter<CommunitiesTreeSelectionState> emit,
|
|
||||||
) {
|
|
||||||
emit(const CommunitiesTreeSelectionState());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
part of 'communities_tree_selection_bloc.dart';
|
|
||||||
|
|
||||||
sealed class CommunitiesTreeSelectionEvent extends Equatable {
|
|
||||||
const CommunitiesTreeSelectionEvent();
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object?> get props => [];
|
|
||||||
}
|
|
||||||
|
|
||||||
final class SelectCommunityEvent extends CommunitiesTreeSelectionEvent {
|
|
||||||
final CommunityModel community;
|
|
||||||
|
|
||||||
const SelectCommunityEvent({required this.community});
|
|
||||||
@override
|
|
||||||
List<Object?> get props => [community];
|
|
||||||
}
|
|
||||||
|
|
||||||
final class SelectSpaceEvent extends CommunitiesTreeSelectionEvent {
|
|
||||||
final SpaceModel space;
|
|
||||||
final CommunityModel community;
|
|
||||||
|
|
||||||
const SelectSpaceEvent({required this.space, required this.community});
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object?> get props => [space];
|
|
||||||
}
|
|
||||||
|
|
||||||
final class ClearCommunitiesTreeSelectionEvent
|
|
||||||
extends CommunitiesTreeSelectionEvent {
|
|
||||||
const ClearCommunitiesTreeSelectionEvent();
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
part of 'communities_tree_selection_bloc.dart';
|
|
||||||
|
|
||||||
final class CommunitiesTreeSelectionState extends Equatable {
|
|
||||||
const CommunitiesTreeSelectionState({
|
|
||||||
this.selectedCommunity,
|
|
||||||
this.selectedSpace,
|
|
||||||
});
|
|
||||||
|
|
||||||
final CommunityModel? selectedCommunity;
|
|
||||||
final SpaceModel? selectedSpace;
|
|
||||||
|
|
||||||
CommunitiesTreeSelectionState copyWith({
|
|
||||||
CommunityModel? selectedCommunity,
|
|
||||||
SpaceModel? selectedSpace,
|
|
||||||
List<CommunityModel>? expandedCommunities,
|
|
||||||
List<SpaceModel>? expandedSpaces,
|
|
||||||
}) {
|
|
||||||
return CommunitiesTreeSelectionState(
|
|
||||||
selectedCommunity: selectedCommunity ?? this.selectedCommunity,
|
|
||||||
selectedSpace: selectedSpace ?? this.selectedSpace,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object?> get props => [
|
|
||||||
selectedCommunity,
|
|
||||||
selectedSpace,
|
|
||||||
];
|
|
||||||
}
|
|
@ -1,38 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/domain/params/load_communities_param.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/presentation/bloc/communities_bloc.dart';
|
|
||||||
|
|
||||||
class CommunitiesTreeFailureWidget extends StatelessWidget {
|
|
||||||
const CommunitiesTreeFailureWidget({super.key, this.errorMessage});
|
|
||||||
|
|
||||||
final String? errorMessage;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Expanded(
|
|
||||||
child: Center(
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
errorMessage ?? 'Something went wrong',
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
ElevatedButton(
|
|
||||||
onPressed: () => context.read<CommunitiesBloc>().add(
|
|
||||||
LoadCommunities(
|
|
||||||
LoadCommunitiesParam(
|
|
||||||
search: context.read<CommunitiesBloc>().state.searchQuery,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: const Text('Retry'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:syncrow_web/common/widgets/custom_expansion_tile.dart';
|
|
||||||
|
|
||||||
class CommunityTile extends StatelessWidget {
|
|
||||||
final String title;
|
|
||||||
final List<Widget>? children;
|
|
||||||
final bool isExpanded;
|
|
||||||
final bool isSelected;
|
|
||||||
final void Function(String, bool isExpanded) onExpansionChanged;
|
|
||||||
final void Function() onItemSelected;
|
|
||||||
|
|
||||||
const CommunityTile({
|
|
||||||
super.key,
|
|
||||||
required this.title,
|
|
||||||
required this.isExpanded,
|
|
||||||
required this.onExpansionChanged,
|
|
||||||
required this.onItemSelected,
|
|
||||||
required this.isSelected,
|
|
||||||
this.children,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: CustomExpansionTile(
|
|
||||||
title: title,
|
|
||||||
initiallyExpanded: isExpanded,
|
|
||||||
isSelected: isSelected,
|
|
||||||
onExpansionChanged: (bool expanded) {
|
|
||||||
onExpansionChanged(title, expanded);
|
|
||||||
},
|
|
||||||
onItemSelected: onItemSelected,
|
|
||||||
children: children ?? [],
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
class EmptyCommunitiesTreeSearchResultWidget extends StatelessWidget {
|
|
||||||
const EmptyCommunitiesTreeSearchResultWidget({
|
|
||||||
required this.searchQuery,
|
|
||||||
super.key,
|
|
||||||
});
|
|
||||||
|
|
||||||
final String searchQuery;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Center(
|
|
||||||
child: Text(
|
|
||||||
searchQuery.isEmpty
|
|
||||||
? 'No communities found'
|
|
||||||
: 'No communities found for "$searchQuery"',
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,112 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
import 'package:syncrow_web/common/widgets/app_loading_indicator.dart';
|
|
||||||
import 'package:syncrow_web/common/widgets/search_bar.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/domain/params/load_communities_param.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/presentation/bloc/communities_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/presentation/widgets/communities_tree_failure_widget.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/presentation/widgets/empty_communities_tree_search_result_widget.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/presentation/widgets/space_management_communities_tree_community_tile.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/presentation/widgets/space_management_sidebar_communities_list.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/presentation/widgets/space_management_sidebar_header.dart';
|
|
||||||
import 'package:syncrow_web/utils/style.dart';
|
|
||||||
|
|
||||||
class SpaceManagementCommunitiesTree extends StatefulWidget {
|
|
||||||
const SpaceManagementCommunitiesTree({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<SpaceManagementCommunitiesTree> createState() =>
|
|
||||||
_SpaceManagementCommunitiesTreeState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _SpaceManagementCommunitiesTreeState
|
|
||||||
extends State<SpaceManagementCommunitiesTree> {
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
context.read<CommunitiesBloc>().add(
|
|
||||||
const LoadCommunities(LoadCommunitiesParam()),
|
|
||||||
);
|
|
||||||
super.initState();
|
|
||||||
}
|
|
||||||
|
|
||||||
void _onSearchChanged(String searchQuery) {
|
|
||||||
context
|
|
||||||
.read<CommunitiesBloc>()
|
|
||||||
.add(LoadCommunities(LoadCommunitiesParam(search: searchQuery.trim())));
|
|
||||||
}
|
|
||||||
|
|
||||||
void _onLoadMore() {
|
|
||||||
context.read<CommunitiesBloc>().add(const LoadMoreCommunities());
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return BlocBuilder<CommunitiesBloc, CommunitiesState>(
|
|
||||||
builder: (context, state) => Container(
|
|
||||||
width: 320,
|
|
||||||
decoration: subSectionContainerDecoration,
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
const SpaceManagementSidebarHeader(),
|
|
||||||
CustomSearchBar(
|
|
||||||
onSearchChanged: _onSearchChanged,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
switch (state.status) {
|
|
||||||
CommunitiesStatus.initial => const AppLoadingIndicator(),
|
|
||||||
CommunitiesStatus.loading => state.communities.isEmpty
|
|
||||||
? const AppLoadingIndicator()
|
|
||||||
: _buildCommunitiesTree(context, state),
|
|
||||||
CommunitiesStatus.success => _buildCommunitiesTree(context, state),
|
|
||||||
CommunitiesStatus.failure => CommunitiesTreeFailureWidget(
|
|
||||||
errorMessage: state.errorMessage,
|
|
||||||
),
|
|
||||||
},
|
|
||||||
Visibility(
|
|
||||||
visible: state.isLoadingMore,
|
|
||||||
child: const AppLoadingIndicator(),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildCommunitiesTree(
|
|
||||||
BuildContext context,
|
|
||||||
CommunitiesState state,
|
|
||||||
) {
|
|
||||||
final communitiesIsEmpty = state.communities.isEmpty;
|
|
||||||
final statusIsSuccess = state.status == CommunitiesStatus.success;
|
|
||||||
|
|
||||||
return Expanded(
|
|
||||||
child: Visibility(
|
|
||||||
visible: statusIsSuccess && communitiesIsEmpty,
|
|
||||||
replacement: Stack(
|
|
||||||
children: [
|
|
||||||
SpaceManagementSidebarCommunitiesList(
|
|
||||||
communities: state.communities,
|
|
||||||
onLoadMore: state.hasNext ? _onLoadMore : null,
|
|
||||||
isLoadingMore: state.isLoadingMore,
|
|
||||||
hasNext: state.hasNext,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
return SpaceManagementCommunitiesTreeCommunityTile(
|
|
||||||
community: state.communities[index],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
if (state.status == CommunitiesStatus.loading &&
|
|
||||||
state.communities.isNotEmpty)
|
|
||||||
ColoredBox(
|
|
||||||
color: Colors.white.withValues(alpha: 0.7),
|
|
||||||
child: const AppLoadingIndicator(),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
child: EmptyCommunitiesTreeSearchResultWidget(
|
|
||||||
searchQuery: state.searchQuery,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user