mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-11 07:38:05 +00:00
Compare commits
91 Commits
SP-1510-oc
...
SP-1607-FE
Author | SHA1 | Date | |
---|---|---|---|
78f42dacf6 | |||
0a9d53e5bd | |||
010960c89b | |||
fccf395c38 | |||
7c65b874eb | |||
25db6ec687 | |||
7f5d2ca6ea | |||
5a5173c19b | |||
83363b4c50 | |||
6ebdc59966 | |||
5f3a0c74ac | |||
03009ed276 | |||
a1142eb38c | |||
1aa7bf2162 | |||
043820f84f | |||
d90d3d4026 | |||
3ac5254abf | |||
f5d926f5a2 | |||
c1d6db8bba | |||
50fc5f9562 | |||
1b0d8d446c | |||
8a5173f429 | |||
bee8652d03 | |||
9546d7bdd1 | |||
cb4956f915 | |||
ec7b0aa078 | |||
296b03e1aa | |||
177c7f1030 | |||
3746c36a71 | |||
0b4337fb6c | |||
171dc52e28 | |||
642d8e9591 | |||
5a8ef578c3 | |||
63ca98895f | |||
7e54cfdccd | |||
fb4d44450f | |||
12e4285b14 | |||
82adbcf4df | |||
7305d511bc | |||
61acaa17c5 | |||
4af81bcc10 | |||
d4dd7a19ba | |||
9ab906d24c | |||
5c57143ea5 | |||
4a3085e1b4 | |||
eb8ba1806c | |||
902419f9c4 | |||
926bcd9a5d | |||
33f9add78a | |||
563a3e1cf5 | |||
791b71276a | |||
24e3eb2311 | |||
82006e9aaf | |||
cedef666f6 | |||
a10d998ec6 | |||
ed50ac03d3 | |||
cd2eb46f49 | |||
39351a710d | |||
c8fe4e3baa | |||
12deceb7d3 | |||
9d27ed2dc5 | |||
a878b9328a | |||
6606491458 | |||
92abcdc4f9 | |||
7aa9e7e5dc | |||
e9abac7933 | |||
0f9227a6f5 | |||
5b13962d41 | |||
8c53d5322a | |||
af4d37939b | |||
d43c1847ff | |||
4c5b390887 | |||
5eeac01666 | |||
717d698378 | |||
9adbbb9a2d | |||
e792dbd72f | |||
9eaa367d32 | |||
d2eea33714 | |||
24372a0618 | |||
8988947694 | |||
ef875ef7dc | |||
5a61647fe4 | |||
568b6be354 | |||
94e4fbd5db | |||
302ef36b17 | |||
c508d016c2 | |||
64a29681de | |||
06b320a75d | |||
a15b5439f0 | |||
baaf5111b1 | |||
745205063e |
30
.github/pull_request_template.md
vendored
Normal file
30
.github/pull_request_template.md
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
<!--
|
||||
Thanks for contributing!
|
||||
|
||||
Provide a description of your changes below and a general summary in the title
|
||||
|
||||
Please look at the following checklist to ensure that your PR can be accepted quickly:
|
||||
-->
|
||||
|
||||
## Jira Ticket
|
||||
<!-- Add your Jira ticket number as a link (e.g., [PROJ-123](https://jira.company.com/browse/PROJ-123)) -->
|
||||
|
||||
## Status
|
||||
|
||||
**READY/IN DEVELOPMENT/HOLD**
|
||||
|
||||
## Description
|
||||
|
||||
<!--- Describe your changes in detail -->
|
||||
|
||||
## Type of Change
|
||||
|
||||
<!--- Put an `x` in all the boxes that apply: -->
|
||||
|
||||
- [ ] ✨ New feature (non-breaking change which adds functionality)
|
||||
- [ ] 🛠️ Bug fix (non-breaking change which fixes an issue)
|
||||
- [ ] ❌ Breaking change (fix or feature that would cause existing functionality to change)
|
||||
- [ ] 🧹 Code refactor
|
||||
- [ ] ✅ Build configuration change
|
||||
- [ ] 📝 Documentation
|
||||
- [ ] 🗑️ Chore
|
10
assets/icons/energy_consumed_icon.svg
Normal file
10
assets/icons/energy_consumed_icon.svg
Normal file
@ -0,0 +1,10 @@
|
||||
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M20 6.90237L13.6328 13.1837L6.60156 6.1524L2.32422 10.418L1.50391 9.59769L6.60156 4.48828L13.6328 11.5195L19.1797 6.08206L20 6.90237Z" fill="#64E1DC"/>
|
||||
<path d="M20 13.1133L19.1797 13.9336L13.6328 8.49615L7.77344 14.3555L5.42969 12.0118L2.32422 15.1055L1.50391 14.2852L5.42969 10.3477L7.77344 12.6914L13.6328 6.83203L20 13.1133Z" fill="#FDBF00"/>
|
||||
<path d="M20 6.90234L13.6328 13.1836L10.1172 9.668V8.00388L13.6328 11.5195L19.1797 6.08203L20 6.90234Z" fill="#00C8C8"/>
|
||||
<path d="M20 13.1133L19.1797 13.9336L13.6328 8.49615L10.1172 12.0118V10.3477L13.6328 6.83203L20 13.1133Z" fill="#FF9100"/>
|
||||
<path d="M19.1714 17.625V18.7813L17.7184 18.7821L10.1172 18.7851L1.32812 18.7891V0.75H2.5V17.625H19.1714Z" fill="#676E74"/>
|
||||
<path d="M3.0127 2.37976L1.91406 1.50024L0.732422 2.37976L0 1.46423L1.91406 0L3.74512 1.46423L3.0127 2.37976Z" fill="#676E74"/>
|
||||
<path d="M19.1714 17.625V18.7813L17.7176 18.7824L17.7184 18.7821L10.1172 18.7851V17.625H19.1714Z" fill="#474F54"/>
|
||||
<path d="M19.9998 18.2108L18.1205 19.9999L17.292 19.1714L17.7174 18.7823L17.7182 18.782L18.3427 18.2108L17.7565 17.6249L17.292 17.1604L18.1205 16.332L19.9998 18.2108Z" fill="#474F54"/>
|
||||
</svg>
|
After Width: | Height: | Size: 1.2 KiB |
19
assets/icons/landing_analytics.svg
Normal file
19
assets/icons/landing_analytics.svg
Normal file
@ -0,0 +1,19 @@
|
||||
<svg width="101" height="101" viewBox="0 0 101 101" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_9554_2115)">
|
||||
<path d="M93.8334 86.1048C97.5937 86.1048 100.653 83.0454 100.653 79.2849V9.83487C100.653 4.4501 96.2722 0.0692444 90.8875 0.0692444H10.4187C5.03394 0.0692444 0.653076 4.4501 0.653076 9.83487V79.2849C0.653076 83.0454 3.71245 86.1048 7.4728 86.1048H9.63745V96.163H2.6062C1.52749 96.163 0.653076 97.0376 0.653076 98.1161C0.653076 99.1946 1.52749 100.069 2.6062 100.069H98.7C99.7787 100.069 100.653 99.1946 100.653 98.1161C100.653 97.0376 99.7787 96.163 98.7 96.163H91.6687V86.1048H93.8334ZM4.55933 9.83487C4.55933 6.60401 7.18784 3.97549 10.4187 3.97549H90.8875C94.1183 3.97549 96.7468 6.60401 96.7468 9.83487V14.1317H4.75542C4.68921 14.1317 4.62378 14.1353 4.55933 14.1417V9.83487ZM22.1375 96.163H13.5437V78.5849H22.1375V96.163ZM44.0125 96.163H35.4187V56.9896H44.0125V96.163ZM65.8875 96.163H57.2937V73.5067H65.8875V96.163ZM89.7156 50.1669H77.2156C76.1369 50.1669 75.2625 51.0415 75.2625 52.12V61.9831C75.2625 63.0616 76.1369 63.9362 77.2156 63.9362C78.2943 63.9362 79.1687 63.0616 79.1687 61.9831V54.0732H87.7625V96.163H79.1687V75.1181C79.1687 74.0396 78.2943 73.1649 77.2156 73.1649C76.1369 73.1649 75.2625 74.0396 75.2625 75.1181V96.163H69.7937V71.5536C69.7937 70.4751 68.9193 69.6005 67.8406 69.6005H55.3406C54.2619 69.6005 53.3875 70.4751 53.3875 71.5536V96.163H47.9187V55.0364C47.9187 53.9579 47.0443 53.0833 45.9656 53.0833H33.4656C32.3869 53.0833 31.5125 53.9579 31.5125 55.0364V96.163H26.0437V76.6317C26.0437 75.5532 25.1693 74.6786 24.0906 74.6786H11.5906C10.5119 74.6786 9.63745 75.5532 9.63745 76.6317V82.1985H7.4728C5.86616 82.1985 4.55933 80.8915 4.55933 79.2849V18.028C4.62378 18.0345 4.68921 18.038 4.75542 18.038H96.7468V79.2849C96.7468 80.8915 95.4398 82.1985 93.8334 82.1985H91.6687V52.12C91.6687 51.0415 90.7943 50.1669 89.7156 50.1669Z" fill="white"/>
|
||||
<path d="M88.1531 7.10049H44.0251C42.9464 7.10049 42.072 7.9751 42.072 9.05362C42.072 10.1321 42.9464 11.0067 44.0251 11.0067H88.1531C89.2318 11.0067 90.1062 10.1321 90.1062 9.05362C90.1062 7.9751 89.2318 7.10049 88.1531 7.10049Z" fill="white"/>
|
||||
<path d="M22.3464 7.67276C21.9832 7.30948 21.4792 7.10049 20.9656 7.10049C20.4519 7.10049 19.948 7.30928 19.5847 7.67276C19.2214 8.03604 19.0125 8.53995 19.0125 9.05362C19.0125 9.56729 19.2214 10.0712 19.5847 10.4343C19.948 10.7978 20.4519 11.0067 20.9656 11.0067C21.4792 11.0067 21.9832 10.7978 22.3464 10.4343C22.7097 10.0712 22.9187 9.56729 22.9187 9.05362C22.9187 8.53995 22.7097 8.03604 22.3464 7.67276Z" fill="white"/>
|
||||
<path d="M14.5339 7.67276C14.1707 7.30948 13.6667 7.10049 13.1531 7.10049C12.6394 7.10049 12.1355 7.30928 11.7722 7.67276C11.4089 8.03604 11.2 8.53995 11.2 9.05362C11.2 9.56729 11.4089 10.0712 11.7722 10.4343C12.1355 10.7978 12.6394 11.0067 13.1531 11.0067C13.6667 11.0067 14.1707 10.7978 14.5339 10.4343C14.8972 10.0712 15.1062 9.56729 15.1062 9.05362C15.1062 8.53995 14.8972 8.03604 14.5339 7.67276Z" fill="white"/>
|
||||
<path d="M30.1589 7.67276C29.7957 7.30948 29.2937 7.10049 28.7781 7.10049C28.2644 7.10049 27.7605 7.30928 27.3972 7.67276C27.0339 8.03604 26.825 8.53995 26.825 9.05362C26.825 9.56729 27.0339 10.0712 27.3972 10.4343C27.7605 10.7978 28.2644 11.0067 28.7781 11.0067C29.2917 11.0067 29.7957 10.7978 30.1589 10.4343C30.5222 10.0712 30.7312 9.56729 30.7312 9.05362C30.7312 8.53995 30.5222 8.03604 30.1589 7.67276Z" fill="white"/>
|
||||
<path d="M78.5964 67.5634C78.2332 67.1981 77.7292 66.9911 77.2156 66.9911C76.7019 66.9911 76.198 67.1983 75.8347 67.5634C75.4714 67.9267 75.2625 68.4306 75.2625 68.9442C75.2625 69.4579 75.4714 69.9618 75.8347 70.3251C76.198 70.6882 76.7019 70.8974 77.2156 70.8974C77.7292 70.8974 78.2332 70.6884 78.5964 70.3251C78.9597 69.9618 79.1687 69.4579 79.1687 68.9442C79.1687 68.4286 78.9597 67.9267 78.5964 67.5634Z" fill="white"/>
|
||||
<path d="M83.4656 26.6198C79.5885 26.6198 76.4344 29.7739 76.4344 33.6511C76.4344 35.1911 76.9334 36.6161 77.7764 37.7757L64.8027 50.7493C63.7959 50.1921 62.6393 49.8737 61.4092 49.8737C60.3008 49.8737 59.252 50.1325 58.3186 50.5913L44.7719 37.0446C45.3291 36.0378 45.6475 34.8812 45.6475 33.6511C45.6475 29.7739 42.4934 26.6198 38.6162 26.6198C34.7391 26.6198 31.585 29.7739 31.585 33.6511C31.585 35.0062 31.9713 36.2722 32.6381 37.3468L21.1043 48.8804C20.0975 48.3232 18.9408 48.0048 17.7109 48.0048C13.8338 48.0048 10.6797 51.1589 10.6797 55.0361C10.6797 58.9132 13.8338 62.0673 17.7109 62.0673C21.5881 62.0673 24.7422 58.9132 24.7422 55.0361C24.7422 53.806 24.4238 52.6493 23.8666 51.6425L35.5381 39.971C36.4684 40.4259 37.5129 40.6821 38.6162 40.6821C39.8461 40.6821 41.0027 40.3638 42.0096 39.8066L55.4236 53.2204C54.7613 54.2927 54.3779 55.5544 54.3779 56.9046C54.3779 60.7818 57.532 63.9359 61.4092 63.9359C65.2863 63.9359 68.4404 60.7818 68.4404 56.9046C68.4404 55.6745 68.1221 54.5179 67.5648 53.5111L80.8861 40.1898C81.6855 40.5066 82.5553 40.6823 83.4656 40.6823C87.3428 40.6823 90.4969 37.5282 90.4969 33.6511C90.4969 29.7739 87.3428 26.6198 83.4656 26.6198ZM17.7111 58.1614C15.9881 58.1614 14.5861 56.7595 14.5861 55.0364C14.5861 53.3134 15.9881 51.9114 17.7111 51.9114C19.4342 51.9114 20.8361 53.3134 20.8361 55.0364C20.8361 56.7595 19.4342 58.1614 17.7111 58.1614ZM38.6164 36.7761C36.8934 36.7761 35.4914 35.3741 35.4914 33.6511C35.4914 31.928 36.8934 30.5261 38.6164 30.5261C40.3395 30.5261 41.7414 31.928 41.7414 33.6511C41.7414 35.3741 40.3395 36.7761 38.6164 36.7761ZM61.4094 60.03C59.6863 60.03 58.2844 58.628 58.2844 56.905C58.2844 55.182 59.6863 53.78 61.4094 53.78C63.1324 53.78 64.5344 55.182 64.5344 56.905C64.5344 58.628 63.1324 60.03 61.4094 60.03ZM83.4656 36.7761C81.7426 36.7761 80.3406 35.3741 80.3406 33.6511C80.3406 31.928 81.7426 30.5261 83.4656 30.5261C85.1887 30.5261 86.5906 31.928 86.5906 33.6511C86.5906 35.3741 85.1887 36.7761 83.4656 36.7761Z" fill="white"/>
|
||||
<path d="M29.6238 25.255C29.2585 24.8917 28.7566 24.6825 28.2429 24.6825C27.7273 24.6825 27.2234 24.8915 26.8601 25.255C26.4968 25.6181 26.2898 26.122 26.2898 26.6357C26.2898 27.1493 26.4968 27.6532 26.8601 28.0165C27.2253 28.3798 27.7273 28.5888 28.2429 28.5888C28.7566 28.5888 29.2585 28.38 29.6238 28.0165C29.9871 27.6532 30.196 27.1493 30.196 26.6357C30.196 26.122 29.9871 25.6181 29.6238 25.255Z" fill="white"/>
|
||||
<path d="M20.9656 24.6827H11.5906C10.5119 24.6827 9.63745 25.5573 9.63745 26.6358C9.63745 27.7143 10.5119 28.589 11.5906 28.589H20.9656C22.0443 28.589 22.9187 27.7143 22.9187 26.6358C22.9187 25.5573 22.0443 24.6827 20.9656 24.6827Z" fill="white"/>
|
||||
<path d="M20.9656 34.0577H11.5906C10.5119 34.0577 9.63745 34.9323 9.63745 36.0108C9.63745 37.0893 10.5119 37.964 11.5906 37.964H20.9656C22.0443 37.964 22.9187 37.0893 22.9187 36.0108C22.9187 34.9323 22.0443 34.0577 20.9656 34.0577Z" fill="white"/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_9554_2115">
|
||||
<rect width="100" height="100" fill="white" transform="translate(0.653076 0.0692444)"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
After Width: | Height: | Size: 6.8 KiB |
BIN
assets/images/web_Background.png
Normal file
BIN
assets/images/web_Background.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 40 KiB |
18
lib/pages/analytics/models/range_of_aqi.dart
Normal file
18
lib/pages/analytics/models/range_of_aqi.dart
Normal file
@ -0,0 +1,18 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
class RangeOfAqi extends Equatable {
|
||||
final double min;
|
||||
final double avg;
|
||||
final double max;
|
||||
final DateTime date;
|
||||
|
||||
const RangeOfAqi({
|
||||
required this.min,
|
||||
required this.avg,
|
||||
required this.max,
|
||||
required this.date,
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [min, avg, max, date];
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:syncrow_web/pages/analytics/models/range_of_aqi.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';
|
||||
|
||||
part 'range_of_aqi_event.dart';
|
||||
part 'range_of_aqi_state.dart';
|
||||
|
||||
class RangeOfAqiBloc extends Bloc<RangeOfAqiEvent, RangeOfAqiState> {
|
||||
RangeOfAqiBloc(this._rangeOfAqiService) : super(const RangeOfAqiState()) {
|
||||
on<LoadRangeOfAqiEvent>(_onLoadRangeOfAqiEvent);
|
||||
on<ClearRangeOfAqiEvent>(_onClearRangeOfAqiEvent);
|
||||
}
|
||||
|
||||
final RangeOfAqiService _rangeOfAqiService;
|
||||
|
||||
Future<void> _onLoadRangeOfAqiEvent(
|
||||
LoadRangeOfAqiEvent event,
|
||||
Emitter<RangeOfAqiState> emit,
|
||||
) async {
|
||||
emit(
|
||||
RangeOfAqiState(
|
||||
status: RangeOfAqiStatus.loading,
|
||||
rangeOfAqi: state.rangeOfAqi,
|
||||
),
|
||||
);
|
||||
try {
|
||||
final rangeOfAqi = await _rangeOfAqiService.load(event.param);
|
||||
emit(RangeOfAqiState(status: RangeOfAqiStatus.loaded, rangeOfAqi: rangeOfAqi));
|
||||
} catch (e) {
|
||||
emit(RangeOfAqiState(status: RangeOfAqiStatus.failure, errorMessage: '$e'));
|
||||
}
|
||||
}
|
||||
|
||||
void _onClearRangeOfAqiEvent(
|
||||
ClearRangeOfAqiEvent event,
|
||||
Emitter<RangeOfAqiState> emit,
|
||||
) {
|
||||
emit(const RangeOfAqiState());
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
part of 'range_of_aqi_bloc.dart';
|
||||
|
||||
sealed class RangeOfAqiEvent extends Equatable {
|
||||
const RangeOfAqiEvent();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class LoadRangeOfAqiEvent extends RangeOfAqiEvent {
|
||||
const LoadRangeOfAqiEvent(this.param);
|
||||
|
||||
final GetRangeOfAqiParam param;
|
||||
|
||||
@override
|
||||
List<Object> get props => [param];
|
||||
}
|
||||
|
||||
class ClearRangeOfAqiEvent extends RangeOfAqiEvent {
|
||||
const ClearRangeOfAqiEvent();
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
part of 'range_of_aqi_bloc.dart';
|
||||
|
||||
enum RangeOfAqiStatus { initial, loading, loaded, failure }
|
||||
|
||||
final class RangeOfAqiState extends Equatable {
|
||||
const RangeOfAqiState({
|
||||
this.rangeOfAqi = const [],
|
||||
this.status = RangeOfAqiStatus.initial,
|
||||
this.errorMessage,
|
||||
});
|
||||
|
||||
final RangeOfAqiStatus status;
|
||||
final List<RangeOfAqi> rangeOfAqi;
|
||||
final String? errorMessage;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [status, rangeOfAqi, errorMessage];
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_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_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/params/get_analytics_devices_param.dart';
|
||||
import 'package:syncrow_web/pages/analytics/params/get_range_of_aqi_param.dart';
|
||||
|
||||
abstract final class FetchAirQualityDataHelper {
|
||||
const FetchAirQualityDataHelper._();
|
||||
|
||||
static void loadAirQualityData(
|
||||
BuildContext context, {
|
||||
required String communityUuid,
|
||||
required String spaceUuid,
|
||||
}) {
|
||||
final date = context.read<AnalyticsDatePickerBloc>().state.monthlyDate;
|
||||
loadAnalyticsDevices(
|
||||
context,
|
||||
communityUuid: communityUuid,
|
||||
spaceUuid: spaceUuid,
|
||||
);
|
||||
loadRangeOfAqi(
|
||||
context,
|
||||
spaceUuid: spaceUuid,
|
||||
date: date,
|
||||
aqiType: AqiType.aqi,
|
||||
);
|
||||
}
|
||||
|
||||
static void clearAllData(BuildContext context) {
|
||||
context.read<AnalyticsDevicesBloc>().add(
|
||||
const ClearAnalyticsDeviceEvent(),
|
||||
);
|
||||
context.read<RealtimeDeviceChangesBloc>().add(
|
||||
const RealtimeDeviceChangesClosed(),
|
||||
);
|
||||
|
||||
context.read<RangeOfAqiBloc>().add(const ClearRangeOfAqiEvent());
|
||||
}
|
||||
|
||||
static void loadAnalyticsDevices(
|
||||
BuildContext context, {
|
||||
required String communityUuid,
|
||||
required String spaceUuid,
|
||||
}) {
|
||||
context.read<AnalyticsDevicesBloc>().add(
|
||||
LoadAnalyticsDevicesEvent(
|
||||
param: GetAnalyticsDevicesParam(
|
||||
communityUuid: communityUuid,
|
||||
spaceUuid: spaceUuid,
|
||||
deviceTypes: ['AQI'],
|
||||
requestType: AnalyticsDeviceRequestType.energyManagement,
|
||||
),
|
||||
onSuccess: (device) {
|
||||
context.read<RealtimeDeviceChangesBloc>()
|
||||
..add(const RealtimeDeviceChangesClosed())
|
||||
..add(RealtimeDeviceChangesStarted(device.uuid));
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static void loadRangeOfAqi(
|
||||
BuildContext context, {
|
||||
required String spaceUuid,
|
||||
required DateTime date,
|
||||
required AqiType aqiType,
|
||||
}) {
|
||||
context.read<RangeOfAqiBloc>().add(
|
||||
LoadRangeOfAqiEvent(
|
||||
GetRangeOfAqiParam(
|
||||
date: date,
|
||||
spaceUuid: spaceUuid,
|
||||
aqiType: aqiType,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,115 @@
|
||||
import 'package:fl_chart/fl_chart.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:syncrow_web/pages/analytics/models/range_of_aqi.dart';
|
||||
import 'package:syncrow_web/pages/analytics/modules/energy_management/helpers/energy_management_charts_helper.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||
|
||||
abstract final class RangeOfAqiChartsHelper {
|
||||
const RangeOfAqiChartsHelper._();
|
||||
|
||||
static const gradientData = <(Color color, String label)>[
|
||||
(ColorsManager.goodGreen, 'Good'),
|
||||
(ColorsManager.moderateYellow, 'Moderate'),
|
||||
(ColorsManager.poorOrange, 'Poor'),
|
||||
(ColorsManager.unhealthyRed, 'Unhealthy'),
|
||||
(ColorsManager.severePink, 'Severe'),
|
||||
(ColorsManager.hazardousPurple, 'Hazardous'),
|
||||
];
|
||||
|
||||
static FlTitlesData titlesData(BuildContext context, List<RangeOfAqi> data) {
|
||||
final titlesData = EnergyManagementChartsHelper.titlesData(context);
|
||||
return titlesData.copyWith(
|
||||
bottomTitles: titlesData.bottomTitles.copyWith(
|
||||
sideTitles: titlesData.bottomTitles.sideTitles.copyWith(
|
||||
getTitlesWidget: (value, meta) => Padding(
|
||||
padding: const EdgeInsetsDirectional.only(top: 20.0),
|
||||
child: Text(
|
||||
data.isNotEmpty ? data[value.toInt()].date.day.toString() : '',
|
||||
style: context.textTheme.bodySmall?.copyWith(
|
||||
fontSize: 12,
|
||||
color: ColorsManager.lightGreyColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
leftTitles: titlesData.leftTitles.copyWith(
|
||||
sideTitles: titlesData.leftTitles.sideTitles.copyWith(
|
||||
reservedSize: 70,
|
||||
interval: 50,
|
||||
maxIncluded: false,
|
||||
getTitlesWidget: (value, meta) {
|
||||
final text = value >= 300 ? '301+' : value.toInt().toString();
|
||||
return Padding(
|
||||
padding: const EdgeInsetsDirectional.only(end: 12),
|
||||
child: FittedBox(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Text(
|
||||
text,
|
||||
style: context.textTheme.bodySmall?.copyWith(
|
||||
fontSize: 12,
|
||||
color: ColorsManager.lightGreyColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static List<LineTooltipItem?> getTooltipItems(
|
||||
List<LineBarSpot> touchedSpots,
|
||||
List<RangeOfAqi> chartData,
|
||||
) {
|
||||
return touchedSpots.asMap().entries.map((entry) {
|
||||
final index = entry.key;
|
||||
final spot = entry.value;
|
||||
|
||||
final label = switch (spot.barIndex) {
|
||||
0 => 'Max',
|
||||
1 => 'Avg',
|
||||
2 => 'Min',
|
||||
_ => '',
|
||||
};
|
||||
|
||||
final date = DateFormat('dd/MM').format(chartData[spot.x.toInt()].date);
|
||||
|
||||
return LineTooltipItem(
|
||||
index == 0 ? '$date\n' : '',
|
||||
const TextStyle(
|
||||
color: ColorsManager.textPrimaryColor,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 12,
|
||||
),
|
||||
children: [
|
||||
TextSpan(text: '$label: ${spot.y.toStringAsFixed(0)}'),
|
||||
],
|
||||
);
|
||||
}).toList();
|
||||
}
|
||||
|
||||
static LineTouchData lineTouchData(
|
||||
List<RangeOfAqi> chartData,
|
||||
) {
|
||||
return LineTouchData(
|
||||
touchTooltipData: LineTouchTooltipData(
|
||||
getTooltipColor: (touchTooltipItem) => ColorsManager.whiteColors,
|
||||
tooltipBorder: const BorderSide(
|
||||
color: ColorsManager.semiTransparentBlack,
|
||||
),
|
||||
tooltipRoundedRadius: 16,
|
||||
showOnTopOfTheChartBoxArea: false,
|
||||
tooltipPadding: const EdgeInsets.all(8),
|
||||
getTooltipItems: (touchedSpots) => RangeOfAqiChartsHelper.getTooltipItems(
|
||||
touchedSpots,
|
||||
chartData,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_web/pages/analytics/modules/air_quality/widgets/air_quality_end_side_widget.dart';
|
||||
import 'package:syncrow_web/pages/analytics/modules/air_quality/widgets/range_of_aqi_chart_box.dart';
|
||||
|
||||
class AirQualityView extends StatelessWidget {
|
||||
const AirQualityView({super.key});
|
||||
|
||||
static const _padding = EdgeInsetsDirectional.all(32);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final isMediumOrLess = constraints.maxWidth <= 900;
|
||||
final height = MediaQuery.sizeOf(context).height;
|
||||
if (isMediumOrLess) {
|
||||
return SingleChildScrollView(
|
||||
padding: _padding,
|
||||
child: Column(
|
||||
spacing: 32,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: height * 1.2,
|
||||
child: const AirQualityEndSideWidget(),
|
||||
),
|
||||
SizedBox(height: height * 0.5, child: const RangeOfAqiChartBox()),
|
||||
SizedBox(height: height * 0.5, child: const Placeholder()),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return SingleChildScrollView(
|
||||
child: Container(
|
||||
padding: _padding,
|
||||
height: height,
|
||||
child: const Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Row(
|
||||
spacing: 32,
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 5,
|
||||
child: Column(
|
||||
spacing: 20,
|
||||
children: [
|
||||
Expanded(child: RangeOfAqiChartBox()),
|
||||
Expanded(child: Placeholder()),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(flex: 2, child: AirQualityEndSideWidget()),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_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/helpers/fetch_energy_management_data_helper.dart';
|
||||
import 'package:syncrow_web/pages/analytics/modules/energy_management/widgets/analytics_device_dropdown.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||
import 'package:syncrow_web/utils/style.dart';
|
||||
|
||||
class AirQualityEndSideWidget extends StatelessWidget {
|
||||
const AirQualityEndSideWidget({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
decoration: subSectionContainerDecoration.copyWith(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
),
|
||||
padding: const EdgeInsetsDirectional.all(32),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildHeader(context),
|
||||
Text(
|
||||
'Device ID:',
|
||||
style: context.textTheme.bodySmall?.copyWith(
|
||||
color: ColorsManager.textPrimaryColor,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
SelectableText(
|
||||
context.watch<AnalyticsDevicesBloc>().state.selectedDevice?.uuid ??
|
||||
'N/A',
|
||||
style: context.textTheme.bodySmall?.copyWith(
|
||||
color: ColorsManager.blackColor,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildHeader(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: FittedBox(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: SelectableText(
|
||||
'AQI Sensor',
|
||||
style: context.textTheme.headlineSmall?.copyWith(
|
||||
fontWeight: FontWeight.w700,
|
||||
color: ColorsManager.vividBlue.withValues(alpha: 0.6),
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
Expanded(
|
||||
flex: 4,
|
||||
child: FittedBox(
|
||||
alignment: AlignmentDirectional.centerEnd,
|
||||
child: AnalyticsDeviceDropdown(
|
||||
onChanged: (value) {
|
||||
context.read<AnalyticsDevicesBloc>().add(
|
||||
SelectAnalyticsDeviceEvent(value),
|
||||
);
|
||||
FetchEnergyManagementDataHelper.loadRealtimeDeviceChanges(
|
||||
context,
|
||||
deviceUuid: value.uuid,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||
|
||||
enum AqiType {
|
||||
aqi('AQI'),
|
||||
pm25('PM2.5'),
|
||||
pm10('PM10'),
|
||||
hcho('HCHO'),
|
||||
tvoc('TVOC'),
|
||||
co2('CO2'),
|
||||
c6h6('C6H6');
|
||||
|
||||
final String value;
|
||||
const AqiType(this.value);
|
||||
}
|
||||
|
||||
class AqiTypeDropdown extends StatefulWidget {
|
||||
const AqiTypeDropdown({super.key, required this.onChanged});
|
||||
|
||||
final ValueChanged<AqiType?> onChanged;
|
||||
|
||||
@override
|
||||
State<AqiTypeDropdown> createState() => _AqiTypeDropdownState();
|
||||
}
|
||||
|
||||
class _AqiTypeDropdownState extends State<AqiTypeDropdown> {
|
||||
AqiType? _selectedItem = AqiType.aqi;
|
||||
|
||||
void _updateSelectedItem(AqiType? item) => setState(() => _selectedItem = item);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(
|
||||
color: ColorsManager.greyColor,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: DropdownButton<AqiType?>(
|
||||
value: _selectedItem,
|
||||
isDense: true,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
dropdownColor: ColorsManager.whiteColors,
|
||||
underline: const SizedBox.shrink(),
|
||||
icon: const RotatedBox(
|
||||
quarterTurns: 1,
|
||||
child: Icon(Icons.chevron_right, size: 24),
|
||||
),
|
||||
style: _getTextStyle(context),
|
||||
padding: const EdgeInsetsDirectional.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 2,
|
||||
),
|
||||
items: AqiType.values
|
||||
.map((e) => DropdownMenuItem(value: e, child: Text(e.value)))
|
||||
.toList(),
|
||||
onChanged: (value) {
|
||||
_updateSelectedItem(value);
|
||||
widget.onChanged(value);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
TextStyle? _getTextStyle(BuildContext context) {
|
||||
return context.textTheme.labelSmall?.copyWith(
|
||||
color: ColorsManager.textPrimaryColor,
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 12,
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
import 'package:fl_chart/fl_chart.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_web/pages/analytics/models/range_of_aqi.dart';
|
||||
import 'package:syncrow_web/pages/analytics/modules/air_quality/helpers/range_of_aqi_charts_helper.dart';
|
||||
import 'package:syncrow_web/pages/analytics/modules/energy_management/helpers/energy_management_charts_helper.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
|
||||
class RangeOfAqiChart extends StatelessWidget {
|
||||
final List<RangeOfAqi> chartData;
|
||||
|
||||
const RangeOfAqiChart({
|
||||
super.key,
|
||||
required this.chartData,
|
||||
});
|
||||
|
||||
List<(List<double> values, Color color, Color? dotColor)> get _lines => [
|
||||
(
|
||||
chartData.map((e) => e.max).toList(),
|
||||
ColorsManager.maxPurple,
|
||||
ColorsManager.maxPurpleDot,
|
||||
),
|
||||
(
|
||||
chartData.map((e) => e.avg).toList(),
|
||||
Colors.white,
|
||||
null,
|
||||
),
|
||||
(
|
||||
chartData.map((e) => e.min).toList(),
|
||||
ColorsManager.minBlue,
|
||||
ColorsManager.minBlueDot,
|
||||
),
|
||||
];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LineChart(
|
||||
LineChartData(
|
||||
minY: 0,
|
||||
maxY: 301,
|
||||
clipData: const FlClipData.vertical(),
|
||||
gridData: EnergyManagementChartsHelper.gridData(horizontalInterval: 50),
|
||||
titlesData: RangeOfAqiChartsHelper.titlesData(context, chartData),
|
||||
borderData: EnergyManagementChartsHelper.borderData(),
|
||||
lineTouchData: RangeOfAqiChartsHelper.lineTouchData(chartData),
|
||||
betweenBarsData: [
|
||||
BetweenBarsData(
|
||||
fromIndex: 0,
|
||||
toIndex: 2,
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.bottomCenter,
|
||||
end: Alignment.topCenter,
|
||||
stops: [0.0, 0.2, 0.4, 0.6, 0.8, 1.0],
|
||||
colors: RangeOfAqiChartsHelper.gradientData.map((e) {
|
||||
final (color, _) = e;
|
||||
return color.withValues(alpha: 0.6);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
],
|
||||
lineBarsData: _lines.map((e) {
|
||||
final (values, color, dotColor) = e;
|
||||
return _buildLine(values: values, color: color, dotColor: dotColor);
|
||||
}).toList(),
|
||||
),
|
||||
duration: Duration.zero,
|
||||
);
|
||||
}
|
||||
|
||||
FlDotData _buildDotData(Color color) {
|
||||
return FlDotData(
|
||||
show: true,
|
||||
getDotPainter: (_, __, ___, ____) => FlDotCirclePainter(
|
||||
radius: 2,
|
||||
color: ColorsManager.whiteColors,
|
||||
strokeWidth: 2,
|
||||
strokeColor: color,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
LineChartBarData _buildLine({
|
||||
required List<double> values,
|
||||
required Color color,
|
||||
Color? dotColor,
|
||||
}) {
|
||||
const invisibleDot = FlDotData(show: false);
|
||||
return LineChartBarData(
|
||||
spots: List.generate(values.length, (i) => FlSpot(i.toDouble(), values[i])),
|
||||
isCurved: true,
|
||||
color: color,
|
||||
barWidth: 4,
|
||||
isStrokeCapRound: true,
|
||||
dotData: dotColor != null ? _buildDotData(dotColor) : invisibleDot,
|
||||
belowBarData: BarAreaData(show: false),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_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/range_of_aqi_chart.dart';
|
||||
import 'package:syncrow_web/pages/analytics/modules/air_quality/widgets/range_of_aqi_chart_title.dart';
|
||||
import 'package:syncrow_web/pages/analytics/widgets/analytics_error_widget.dart';
|
||||
import 'package:syncrow_web/utils/style.dart';
|
||||
|
||||
class RangeOfAqiChartBox extends StatelessWidget {
|
||||
const RangeOfAqiChartBox({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<RangeOfAqiBloc, RangeOfAqiState>(
|
||||
builder: (context, state) {
|
||||
return Container(
|
||||
padding: const EdgeInsetsDirectional.all(30),
|
||||
decoration: subSectionContainerDecoration.copyWith(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (state.errorMessage != null) ...[
|
||||
AnalyticsErrorWidget(state.errorMessage),
|
||||
const SizedBox(height: 10),
|
||||
],
|
||||
RangeOfAqiChartTitle(
|
||||
isLoading: state.status == RangeOfAqiStatus.loading,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
const Divider(),
|
||||
const SizedBox(height: 20),
|
||||
Expanded(child: RangeOfAqiChart(chartData: state.rangeOfAqi)),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/analytics/modules/air_quality/helpers/fetch_air_quality_data_helper.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/widgets/chart_informative_cell.dart';
|
||||
import 'package:syncrow_web/pages/analytics/modules/energy_management/widgets/chart_title.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 RangeOfAqiChartTitle extends StatelessWidget {
|
||||
const RangeOfAqiChartTitle({required this.isLoading, super.key});
|
||||
final bool isLoading;
|
||||
|
||||
static const List<(Color color, String title, bool hasBorder)> _colors = [
|
||||
(Color(0xFF962DFF), 'Max', false),
|
||||
(Color(0xFF93AAFD), 'Min', false),
|
||||
(Colors.transparent, 'Avg', true),
|
||||
];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
ChartsLoadingWidget(isLoading: isLoading),
|
||||
const Expanded(
|
||||
flex: 3,
|
||||
child: FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: ChartTitle(title: Text('Range of AQI')),
|
||||
),
|
||||
),
|
||||
const Spacer(flex: 3),
|
||||
..._colors.map(
|
||||
(e) {
|
||||
final (color, title, hasBorder) = e;
|
||||
return Expanded(
|
||||
child: IntrinsicHeight(
|
||||
child: FittedBox(
|
||||
fit: BoxFit.fitWidth,
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: Padding(
|
||||
padding: const EdgeInsetsDirectional.only(end: 16),
|
||||
child: ChartInformativeCell(
|
||||
title: Text(title),
|
||||
color: color,
|
||||
hasBorder: hasBorder,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const Spacer(),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
alignment: AlignmentDirectional.centerEnd,
|
||||
child: AqiTypeDropdown(
|
||||
onChanged: (value) {
|
||||
final spaceTreeState = context.read<SpaceTreeBloc>().state;
|
||||
final spaceUuid = spaceTreeState.selectedSpaces.firstOrNull;
|
||||
|
||||
if (spaceUuid == null) return;
|
||||
|
||||
FetchAirQualityDataHelper.loadRangeOfAqi(
|
||||
context,
|
||||
spaceUuid: spaceUuid,
|
||||
date: context.read<AnalyticsDatePickerBloc>().state.monthlyDate,
|
||||
aqiType: value ?? AqiType.aqi,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_web/pages/analytics/modules/air_quality/views/air_quality_view.dart';
|
||||
import 'package:syncrow_web/pages/analytics/modules/energy_management/views/analytics_energy_management_view.dart';
|
||||
import 'package:syncrow_web/pages/analytics/modules/occupancy/views/analytics_occupancy_view.dart';
|
||||
|
||||
@ -10,6 +11,10 @@ enum AnalyticsPageTab {
|
||||
occupancy(
|
||||
title: 'Occupancy',
|
||||
child: AnalyticsOccupancyView(),
|
||||
),
|
||||
airQuality(
|
||||
title: 'Air Quality',
|
||||
child: AirQualityView(),
|
||||
);
|
||||
|
||||
const AnalyticsPageTab({
|
||||
|
@ -0,0 +1,59 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/analytics/modules/air_quality/helpers/fetch_air_quality_data_helper.dart';
|
||||
import 'package:syncrow_web/pages/analytics/modules/analytics/strategies/analytics_data_loading_strategy.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/spaces_management/all_spaces/model/community_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
|
||||
|
||||
final class AirQualityDataLoadingStrategy implements AnalyticsDataLoadingStrategy {
|
||||
@override
|
||||
void onCommunitySelected(
|
||||
BuildContext context,
|
||||
CommunityModel community,
|
||||
List<SpaceModel> spaces,
|
||||
) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@override
|
||||
void onSpaceSelected(
|
||||
BuildContext context,
|
||||
CommunityModel community,
|
||||
SpaceModel space,
|
||||
) {
|
||||
final spaceTreeBloc = context.read<SpaceTreeBloc>();
|
||||
final isSpaceSelected = spaceTreeBloc.state.selectedSpaces.contains(space.uuid);
|
||||
|
||||
if (isSpaceSelected) {
|
||||
clearData(context);
|
||||
return;
|
||||
}
|
||||
|
||||
spaceTreeBloc
|
||||
..add(const SpaceTreeClearSelectionEvent())
|
||||
..add(OnSpaceSelected(community, space.uuid ?? '', []));
|
||||
|
||||
FetchAirQualityDataHelper.loadAirQualityData(
|
||||
context,
|
||||
communityUuid: community.uuid,
|
||||
spaceUuid: space.uuid ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void onChildSpaceSelected(
|
||||
BuildContext context,
|
||||
CommunityModel community,
|
||||
SpaceModel child,
|
||||
) {
|
||||
return onSpaceSelected(context, community, child);
|
||||
}
|
||||
|
||||
@override
|
||||
void clearData(BuildContext context) {
|
||||
context.read<SpaceTreeBloc>().add(const SpaceTreeClearSelectionEvent());
|
||||
FetchAirQualityDataHelper.clearAllData(context);
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
import 'package:syncrow_web/pages/analytics/modules/analytics/enums/analytics_page_tab.dart';
|
||||
import 'package:syncrow_web/pages/analytics/modules/analytics/strategies/air_quality_data_loading_strategy.dart';
|
||||
import 'package:syncrow_web/pages/analytics/modules/analytics/strategies/analytics_data_loading_strategy.dart';
|
||||
import 'package:syncrow_web/pages/analytics/modules/analytics/strategies/energy_management_data_loading_strategy.dart';
|
||||
import 'package:syncrow_web/pages/analytics/modules/analytics/strategies/occupancy_data_loading_strategy.dart';
|
||||
@ -9,6 +10,7 @@ abstract final class AnalyticsDataLoadingStrategyFactory {
|
||||
return switch (tab) {
|
||||
AnalyticsPageTab.energyManagement => EnergyManagementDataLoadingStrategy(),
|
||||
AnalyticsPageTab.occupancy => OccupancyDataLoadingStrategy(),
|
||||
AnalyticsPageTab.airQuality => AirQualityDataLoadingStrategy(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ class EnergyManagementDataLoadingStrategy implements AnalyticsDataLoadingStrateg
|
||||
CommunityModel community,
|
||||
List<SpaceModel> spaces,
|
||||
) {
|
||||
// Add to space tree bloc first
|
||||
context.read<SpaceTreeBloc>().add(
|
||||
OnCommunitySelected(
|
||||
community.uuid,
|
||||
@ -69,7 +68,7 @@ class EnergyManagementDataLoadingStrategy implements AnalyticsDataLoadingStrateg
|
||||
CommunityModel community,
|
||||
SpaceModel child,
|
||||
) {
|
||||
// Do nothing else as per original implementation
|
||||
return onSpaceSelected(context, community, child);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -14,23 +14,7 @@ class OccupancyDataLoadingStrategy implements AnalyticsDataLoadingStrategy {
|
||||
CommunityModel community,
|
||||
List<SpaceModel> spaces,
|
||||
) {
|
||||
context.read<SpaceTreeBloc>().add(
|
||||
OnCommunitySelected(
|
||||
community.uuid,
|
||||
spaces.isNotEmpty ? [spaces.first] : [],
|
||||
),
|
||||
);
|
||||
|
||||
final spaceTreeState = context.read<SpaceTreeBloc>().state;
|
||||
if (spaceTreeState.selectedCommunities.contains(community.uuid)) {
|
||||
clearData(context);
|
||||
return;
|
||||
}
|
||||
FetchOccupancyDataHelper.loadOccupancyData(
|
||||
context,
|
||||
communityId: community.uuid,
|
||||
spaceId: spaces.isNotEmpty ? spaces.first.uuid ?? '' : '',
|
||||
);
|
||||
// Do Nothing
|
||||
}
|
||||
|
||||
@override
|
||||
@ -40,26 +24,17 @@ class OccupancyDataLoadingStrategy implements AnalyticsDataLoadingStrategy {
|
||||
SpaceModel space,
|
||||
) {
|
||||
final spaceTreeBloc = context.read<SpaceTreeBloc>();
|
||||
final selectedSpacesIds = spaceTreeBloc.state.selectedSpaces;
|
||||
final isSpaceSelected = selectedSpacesIds.contains(space.uuid);
|
||||
final isSpaceSelected = spaceTreeBloc.state.selectedSpaces.contains(space.uuid);
|
||||
|
||||
if (selectedSpacesIds.isEmpty) {
|
||||
spaceTreeBloc.add(OnCommunitySelected(community.uuid, [space]));
|
||||
} else if (isSpaceSelected) {
|
||||
spaceTreeBloc.add(const SpaceTreeClearSelectionEvent());
|
||||
} else {
|
||||
spaceTreeBloc
|
||||
..add(const SpaceTreeClearSelectionEvent())
|
||||
..add(OnSpaceSelected(community, space.uuid ?? '', []));
|
||||
}
|
||||
|
||||
final spaceTreeState = context.read<SpaceTreeBloc>().state;
|
||||
if (spaceTreeState.selectedCommunities.contains(community.uuid) ||
|
||||
spaceTreeState.selectedSpaces.contains(space.uuid)) {
|
||||
if (isSpaceSelected) {
|
||||
clearData(context);
|
||||
return;
|
||||
}
|
||||
|
||||
spaceTreeBloc
|
||||
..add(const SpaceTreeClearSelectionEvent())
|
||||
..add(OnSpaceSelected(community, space.uuid ?? '', []));
|
||||
|
||||
FetchOccupancyDataHelper.loadOccupancyData(
|
||||
context,
|
||||
communityId: community.uuid,
|
||||
@ -73,7 +48,7 @@ class OccupancyDataLoadingStrategy implements AnalyticsDataLoadingStrategy {
|
||||
CommunityModel community,
|
||||
SpaceModel child,
|
||||
) {
|
||||
// Do nothing
|
||||
return onSpaceSelected(context, community, child);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_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/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_tab/analytics_tab_bloc.dart';
|
||||
@ -20,6 +21,7 @@ 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/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/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/total_energy_consumption/remote_total_energy_consumption_service.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/shared/navigate_home_grid_view.dart';
|
||||
@ -94,6 +96,11 @@ class _AnalyticsPageState extends State<AnalyticsPage> {
|
||||
),
|
||||
),
|
||||
),
|
||||
BlocProvider(
|
||||
create: (context) => RangeOfAqiBloc(
|
||||
FakeRangeOfAqiService(),
|
||||
),
|
||||
),
|
||||
],
|
||||
child: const AnalyticsPageForm(),
|
||||
);
|
||||
|
@ -0,0 +1,59 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
|
||||
class ChartInformativeCell extends StatelessWidget {
|
||||
const ChartInformativeCell({
|
||||
super.key,
|
||||
required this.title,
|
||||
required this.color,
|
||||
this.hasBorder = false,
|
||||
});
|
||||
|
||||
final Widget title;
|
||||
final Color color;
|
||||
final bool hasBorder;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: MediaQuery.sizeOf(context).height * 0.0385,
|
||||
padding: const EdgeInsetsDirectional.symmetric(
|
||||
vertical: 8,
|
||||
horizontal: 12,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadiusDirectional.circular(8),
|
||||
border: Border.all(
|
||||
color: ColorsManager.greyColor,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
alignment: Alignment.center,
|
||||
child: Row(
|
||||
spacing: 6,
|
||||
children: [
|
||||
Container(
|
||||
height: 8,
|
||||
width: 8,
|
||||
decoration: BoxDecoration(
|
||||
color: color,
|
||||
border: Border.all(color: ColorsManager.grayBorder),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
DefaultTextStyle(
|
||||
style: const TextStyle(
|
||||
color: ColorsManager.blackColor,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 14,
|
||||
),
|
||||
child: title,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -38,7 +38,7 @@ abstract final class EnergyManagementChartsHelper {
|
||||
sideTitles: SideTitles(
|
||||
showTitles: true,
|
||||
maxIncluded: false,
|
||||
minIncluded: true,
|
||||
minIncluded: false,
|
||||
interval: leftTitlesInterval,
|
||||
reservedSize: 110,
|
||||
getTitlesWidget: (value, meta) => Padding(
|
||||
@ -50,7 +50,7 @@ abstract final class EnergyManagementChartsHelper {
|
||||
value.formatNumberToKwh,
|
||||
style: context.textTheme.bodySmall?.copyWith(
|
||||
fontSize: 12,
|
||||
color: ColorsManager.greyColor,
|
||||
color: ColorsManager.lightGreyColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -93,12 +93,14 @@ abstract final class EnergyManagementChartsHelper {
|
||||
);
|
||||
}
|
||||
|
||||
static FlGridData gridData() {
|
||||
static FlGridData gridData({
|
||||
double horizontalInterval = 250,
|
||||
}) {
|
||||
return FlGridData(
|
||||
show: true,
|
||||
drawVerticalLine: false,
|
||||
drawHorizontalLine: true,
|
||||
horizontalInterval: 250,
|
||||
horizontalInterval: horizontalInterval,
|
||||
getDrawingHorizontalLine: (value) {
|
||||
return FlLine(
|
||||
color: ColorsManager.greyColor,
|
||||
|
@ -18,6 +18,7 @@ class EnergyConsumptionByPhasesChart extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return BarChart(
|
||||
BarChartData(
|
||||
|
||||
gridData: EnergyManagementChartsHelper.gridData().copyWith(
|
||||
checkToShowHorizontalLine: (value) => true,
|
||||
horizontalInterval: 250,
|
||||
@ -170,7 +171,7 @@ class EnergyConsumptionByPhasesChart extends StatelessWidget {
|
||||
child: Text(
|
||||
month,
|
||||
style: context.textTheme.bodySmall?.copyWith(
|
||||
color: ColorsManager.greyColor,
|
||||
color: ColorsManager.lightGreyColor,
|
||||
fontSize: 11,
|
||||
),
|
||||
),
|
||||
|
@ -19,10 +19,12 @@ class EnergyConsumptionByPhasesChartBox extends StatelessWidget {
|
||||
decoration: secondarySection,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
spacing: 20,
|
||||
children: [
|
||||
AnalyticsErrorWidget(state.errorMessage),
|
||||
EnergyConsumptionByPhasesTitle(isLoading: state.status == EnergyConsumptionByPhasesStatus.loading,),
|
||||
EnergyConsumptionByPhasesTitle(
|
||||
isLoading: state.status == EnergyConsumptionByPhasesStatus.loading,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Expanded(
|
||||
child: EnergyConsumptionByPhasesChart(
|
||||
energyData: state.chartData,
|
||||
|
@ -12,6 +12,7 @@ class EnergyConsumptionPerDeviceChart extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return LineChart(
|
||||
LineChartData(
|
||||
clipData: const FlClipData.vertical(),
|
||||
titlesData: EnergyManagementChartsHelper.titlesData(
|
||||
context,
|
||||
leftTitlesInterval: 250,
|
||||
|
@ -1,7 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_web/pages/analytics/models/analytics_device.dart';
|
||||
import 'package:syncrow_web/pages/analytics/models/device_energy_data_model.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/pages/analytics/modules/analytics/widgets/chart_informative_cell.dart';
|
||||
|
||||
class EnergyConsumptionPerDeviceDevicesList extends StatelessWidget {
|
||||
const EnergyConsumptionPerDeviceDevicesList({
|
||||
@ -42,42 +42,7 @@ class EnergyConsumptionPerDeviceDevicesList extends StatelessWidget {
|
||||
|
||||
return Tooltip(
|
||||
message: '${device.name}\n${device.productDevice?.uuid ?? ''}',
|
||||
child: Container(
|
||||
height: MediaQuery.sizeOf(context).height * 0.0365,
|
||||
padding: const EdgeInsetsDirectional.symmetric(
|
||||
vertical: 8,
|
||||
horizontal: 12,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadiusDirectional.circular(8),
|
||||
border: Border.all(
|
||||
color: ColorsManager.greyColor,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
alignment: Alignment.center,
|
||||
child: Row(
|
||||
spacing: 6,
|
||||
children: [
|
||||
CircleAvatar(
|
||||
radius: 4,
|
||||
backgroundColor: deviceColor,
|
||||
),
|
||||
Text(
|
||||
device.name,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
color: ColorsManager.blackColor,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
child: ChartInformativeCell(title: Text(device.name), color: deviceColor),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -69,13 +69,18 @@ class PowerClampEnergyDataWidget extends StatelessWidget {
|
||||
PowerClampEnergyStatus(
|
||||
iconPath: Assets.powerActiveIcon,
|
||||
title: 'Active',
|
||||
value: _valueFromCode('EnergyConsumed', generalDataPoints),
|
||||
value: _valueFromCode('ActivePower', generalDataPoints),
|
||||
unit: 'W',
|
||||
),
|
||||
PowerClampEnergyStatus(
|
||||
iconPath: Assets.voltMeterIcon,
|
||||
title: 'Current',
|
||||
value: _valueFromCode('Current', generalDataPoints),
|
||||
value: _valueFromCode('Current', generalDataPoints)
|
||||
.replaceAllMapped(
|
||||
RegExp(r'(\d{1,3})(?=(\d{3})+(?!\d))'),
|
||||
(Match m) => '${m[1]}.',
|
||||
)
|
||||
.replaceAll('.0', ''),
|
||||
unit: 'A',
|
||||
),
|
||||
PowerClampEnergyStatus(
|
||||
|
@ -55,7 +55,7 @@ class PowerClampPhasesDataWidget extends StatelessWidget {
|
||||
iconPath: Assets.powerActiveIcon,
|
||||
title: 'Active Power',
|
||||
value: _valueFromCode(
|
||||
code: 'ReactivePower$phaseSuffix',
|
||||
code: 'ActivePower$phaseSuffix',
|
||||
points: phase?.dataPoints,
|
||||
),
|
||||
unit: 'W',
|
||||
@ -125,7 +125,48 @@ class PowerClampPhasesDataWidget extends StatelessWidget {
|
||||
(e) => e.code == code,
|
||||
orElse: () => DataPoint(value: '--'),
|
||||
);
|
||||
final value = element?.value;
|
||||
if (code.contains('Current')) {
|
||||
return _formatCurrentValue(value?.toString());
|
||||
}
|
||||
if (code.contains('PowerFactor')) {
|
||||
return _formatPowerFactor(value?.toString());
|
||||
}
|
||||
if (code.contains('Voltage')) {
|
||||
return _formatVoltage(value?.toString());
|
||||
}
|
||||
return value?.toString() ?? '--';
|
||||
}
|
||||
|
||||
return element?.value.toString() ?? '--';
|
||||
String _formatCurrentValue(String? value) {
|
||||
if (value == null) return '--';
|
||||
String str = value;
|
||||
if (str.isEmpty || str == '--') return '--';
|
||||
str = str.replaceAll(RegExp(r'[^0-9]'), '');
|
||||
if (str.isEmpty) return '--';
|
||||
if (str.length == 1) return '${str[0]}.0';
|
||||
return '${str[0]}.${str.substring(1)}';
|
||||
}
|
||||
|
||||
String _formatPowerFactor(String? value) {
|
||||
if (value == null) return '--';
|
||||
String str = value;
|
||||
if (str.isEmpty || str == '--') return '--';
|
||||
str = str.replaceAll(RegExp(r'[^0-9]'), '');
|
||||
if (str.isEmpty) return '--';
|
||||
final intValue = int.tryParse(str);
|
||||
if (intValue == null) return '--';
|
||||
final doubleValue = intValue / 100;
|
||||
return doubleValue.toStringAsFixed(2);
|
||||
}
|
||||
|
||||
String _formatVoltage(String? value) {
|
||||
if (value == null) return '--';
|
||||
String str = value;
|
||||
if (str.isEmpty || str == '--') return '--';
|
||||
str = str.replaceAll(RegExp(r'[^0-9]'), '');
|
||||
if (str.isEmpty) return '--';
|
||||
if (str.length == 1) return '0.${str[0]}';
|
||||
return '${str.substring(0, str.length - 1)}.${str.substring(str.length - 1)}';
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ class TotalEnergyConsumptionChart extends StatelessWidget {
|
||||
return Expanded(
|
||||
child: LineChart(
|
||||
LineChartData(
|
||||
clipData: const FlClipData.vertical(),
|
||||
titlesData: EnergyManagementChartsHelper.titlesData(
|
||||
context,
|
||||
leftTitlesInterval: 250,
|
||||
@ -28,6 +29,7 @@ class TotalEnergyConsumptionChart extends StatelessWidget {
|
||||
),
|
||||
duration: Duration.zero,
|
||||
curve: Curves.easeIn,
|
||||
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -35,9 +37,6 @@ class TotalEnergyConsumptionChart extends StatelessWidget {
|
||||
List<LineChartBarData> get _lineBarsData {
|
||||
return [
|
||||
LineChartBarData(
|
||||
preventCurveOvershootingThreshold: 0.1,
|
||||
curveSmoothness: 0.55,
|
||||
preventCurveOverShooting: true,
|
||||
spots: chartData
|
||||
.asMap()
|
||||
.entries
|
||||
|
18
lib/pages/analytics/params/get_range_of_aqi_param.dart
Normal file
18
lib/pages/analytics/params/get_range_of_aqi_param.dart
Normal file
@ -0,0 +1,18 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:syncrow_web/pages/analytics/modules/air_quality/widgets/aqi_type_dropdown.dart';
|
||||
|
||||
class GetRangeOfAqiParam extends Equatable {
|
||||
final DateTime date;
|
||||
final String spaceUuid;
|
||||
final AqiType aqiType;
|
||||
|
||||
const GetRangeOfAqiParam(
|
||||
{
|
||||
required this.date,
|
||||
required this.spaceUuid,
|
||||
required this.aqiType,
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [date, spaceUuid];
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
import 'package:syncrow_web/pages/analytics/models/range_of_aqi.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(
|
||||
min: min,
|
||||
avg: avg,
|
||||
max: max,
|
||||
date: date,
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
import 'package:syncrow_web/pages/analytics/models/range_of_aqi.dart';
|
||||
import 'package:syncrow_web/pages/analytics/params/get_range_of_aqi_param.dart';
|
||||
|
||||
abstract interface class RangeOfAqiService {
|
||||
Future<List<RangeOfAqi>> load(GetRangeOfAqiParam param);
|
||||
}
|
@ -21,6 +21,7 @@ class DynamicTable extends StatefulWidget {
|
||||
final List<String>? initialSelectedIds;
|
||||
final int uuidIndex;
|
||||
final Function(dynamic selectedRows)? onSelectionChanged;
|
||||
final Function(int rowIndex)? onSettingsPressed;
|
||||
const DynamicTable({
|
||||
super.key,
|
||||
required this.headers,
|
||||
@ -37,6 +38,7 @@ class DynamicTable extends StatefulWidget {
|
||||
this.initialSelectedIds,
|
||||
required this.uuidIndex,
|
||||
this.onSelectionChanged,
|
||||
this.onSettingsPressed,
|
||||
});
|
||||
|
||||
@override
|
||||
@ -48,11 +50,20 @@ class _DynamicTableState extends State<DynamicTable> {
|
||||
bool _selectAll = false;
|
||||
final ScrollController _verticalScrollController = ScrollController();
|
||||
final ScrollController _horizontalScrollController = ScrollController();
|
||||
|
||||
late ScrollController _horizontalHeaderScrollController;
|
||||
late ScrollController _horizontalBodyScrollController;
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_initializeSelection();
|
||||
_horizontalHeaderScrollController = ScrollController();
|
||||
_horizontalBodyScrollController = ScrollController();
|
||||
|
||||
// Synchronize horizontal scrolling
|
||||
_horizontalBodyScrollController.addListener(() {
|
||||
_horizontalHeaderScrollController
|
||||
.jumpTo(_horizontalBodyScrollController.offset);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@ -63,7 +74,8 @@ class _DynamicTableState extends State<DynamicTable> {
|
||||
}
|
||||
}
|
||||
|
||||
bool _compareListOfLists(List<List<dynamic>> oldList, List<List<dynamic>> newList) {
|
||||
bool _compareListOfLists(
|
||||
List<List<dynamic>> oldList, List<List<dynamic>> newList) {
|
||||
// Check if the old and new lists are the same
|
||||
if (oldList.length != newList.length) return false;
|
||||
|
||||
@ -101,88 +113,88 @@ class _DynamicTableState extends State<DynamicTable> {
|
||||
context.read<DeviceManagementBloc>().add(UpdateSelection(_selectedRows));
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_horizontalHeaderScrollController.dispose();
|
||||
_horizontalBodyScrollController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
decoration: widget.cellDecoration,
|
||||
child: Scrollbar(
|
||||
controller: _verticalScrollController,
|
||||
thumbVisibility: true,
|
||||
trackVisibility: true,
|
||||
child: Scrollbar(
|
||||
controller: _horizontalScrollController,
|
||||
thumbVisibility: false,
|
||||
trackVisibility: false,
|
||||
notificationPredicate: (notif) => notif.depth == 1,
|
||||
child: SingleChildScrollView(
|
||||
controller: _verticalScrollController,
|
||||
child: SingleChildScrollView(
|
||||
controller: _horizontalScrollController,
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: SizedBox(
|
||||
width: widget.size.width,
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
decoration: widget.headerDecoration ??
|
||||
const BoxDecoration(
|
||||
color: ColorsManager.boxColor,
|
||||
),
|
||||
const BoxDecoration(color: ColorsManager.boxColor),
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
controller: _horizontalHeaderScrollController,
|
||||
child: SizedBox(
|
||||
width: widget.size.width,
|
||||
child: Row(
|
||||
children: [
|
||||
if (widget.withCheckBox) _buildSelectAllCheckbox(),
|
||||
...List.generate(widget.headers.length, (index) {
|
||||
return _buildTableHeaderCell(widget.headers[index], index);
|
||||
})
|
||||
//...widget.headers.map((header) => _buildTableHeaderCell(header)),
|
||||
return _buildTableHeaderCell(
|
||||
widget.headers[index], index);
|
||||
}),
|
||||
],
|
||||
),
|
||||
),
|
||||
widget.isEmpty
|
||||
? Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
SvgPicture.asset(Assets.emptyTable),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Text(
|
||||
widget.tableName == 'AccessManagement' ? 'No Password ' : 'No Devices',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodySmall!
|
||||
.copyWith(color: ColorsManager.grayColor),
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
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: SizedBox(
|
||||
width: widget.size.width,
|
||||
child: widget.isEmpty
|
||||
? _buildEmptyState()
|
||||
: Column(
|
||||
children: List.generate(widget.data.length, (index) {
|
||||
final row = widget.data[index];
|
||||
children:
|
||||
List.generate(widget.data.length, (rowIndex) {
|
||||
final row = widget.data[rowIndex];
|
||||
return Row(
|
||||
children: [
|
||||
if (widget.withCheckBox) _buildRowCheckbox(index, widget.size.height * 0.08),
|
||||
...row.map((cell) => _buildTableCell(cell.toString(), widget.size.height * 0.08)),
|
||||
if (widget.withCheckBox)
|
||||
_buildRowCheckbox(
|
||||
rowIndex, widget.size.height * 0.08),
|
||||
...row.asMap().entries.map((entry) {
|
||||
return _buildTableCell(
|
||||
entry.value.toString(),
|
||||
widget.size.height * 0.08,
|
||||
rowIndex: rowIndex,
|
||||
columnIndex: entry.key,
|
||||
);
|
||||
}).toList(),
|
||||
],
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -196,11 +208,39 @@ class _DynamicTableState extends State<DynamicTable> {
|
||||
),
|
||||
child: Checkbox(
|
||||
value: _selectAll,
|
||||
onChanged: widget.withSelectAll && widget.data.isNotEmpty ? _toggleSelectAll : null,
|
||||
onChanged: widget.withSelectAll && widget.data.isNotEmpty
|
||||
? _toggleSelectAll
|
||||
: null,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildEmptyState() => Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
SvgPicture.asset(Assets.emptyTable),
|
||||
const SizedBox(height: 15),
|
||||
Text(
|
||||
widget.tableName == 'AccessManagement'
|
||||
? 'No Password '
|
||||
: 'No Devices',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodySmall!
|
||||
.copyWith(color: ColorsManager.grayColor),
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
Widget _buildRowCheckbox(int index, double size) {
|
||||
return Container(
|
||||
width: 50,
|
||||
@ -238,7 +278,9 @@ class _DynamicTableState extends State<DynamicTable> {
|
||||
constraints: const BoxConstraints.expand(height: 40),
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: index == widget.headers.length - 1 ? 12 : 8.0, vertical: 4),
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: index == widget.headers.length - 1 ? 12 : 8.0,
|
||||
vertical: 4),
|
||||
child: Text(
|
||||
title,
|
||||
style: context.textTheme.titleSmall!.copyWith(
|
||||
@ -253,13 +295,23 @@ class _DynamicTableState extends State<DynamicTable> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTableCell(String content, double size) {
|
||||
Widget _buildTableCell(
|
||||
String content,
|
||||
double size, {
|
||||
required int rowIndex,
|
||||
required int columnIndex,
|
||||
}) {
|
||||
bool isBatteryLevel = content.endsWith('%');
|
||||
double? batteryLevel;
|
||||
|
||||
if (isBatteryLevel) {
|
||||
batteryLevel = double.tryParse(content.replaceAll('%', '').trim());
|
||||
}
|
||||
bool isSettingsColumn = widget.headers[columnIndex] == 'Settings';
|
||||
|
||||
if (isSettingsColumn) {
|
||||
return _buildSettingsIcon(rowIndex, size);
|
||||
}
|
||||
|
||||
Color? statusColor;
|
||||
switch (content) {
|
||||
@ -311,4 +363,23 @@ class _DynamicTableState extends State<DynamicTable> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSettingsIcon(int rowIndex, double size) {
|
||||
return Container(
|
||||
height: size,
|
||||
width: 120,
|
||||
padding: const EdgeInsets.all(5.0),
|
||||
decoration: const BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(color: ColorsManager.boxDivider, width: 1.0),
|
||||
),
|
||||
color: Colors.white,
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: IconButton(
|
||||
icon: SvgPicture.asset(Assets.settings),
|
||||
onPressed: () => widget.onSettingsPressed?.call(rowIndex),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import 'package:syncrow_web/pages/routines/models/gang_switches/one_gang_switch/
|
||||
import 'package:syncrow_web/pages/routines/models/gang_switches/three_gang_switch/three_gang_switch.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/gang_switches/two_gang_switch/two_gang_switch.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/gateway.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/pc/energy_clamp_functions.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/water_heater/water_heater_functions.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/wps/wps_functions.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/ceiling_sensor/ceiling_sensor_helper.dart';
|
||||
@ -248,6 +249,8 @@ SOS
|
||||
tempIcon = Assets.waterLeakNormal;
|
||||
} else if (type == DeviceType.NCPS) {
|
||||
tempIcon = Assets.sensors;
|
||||
} else if (type == DeviceType.PC) {
|
||||
tempIcon = Assets.powerClamp;
|
||||
} else {
|
||||
tempIcon = Assets.logoHorizontal;
|
||||
}
|
||||
@ -393,6 +396,59 @@ SOS
|
||||
BacklightFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||
];
|
||||
case 'PC':
|
||||
return [
|
||||
TotalEnergyConsumedStatusFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||
TotalActivePowerConsumedStatusFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||
VoltagePhaseSequenceDetectionFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||
TotalCurrentStatusFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||
FrequencyStatusFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||
|
||||
// Phase A
|
||||
EnergyConsumedAStatusFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||
ActivePowerAStatusFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||
VoltageAStatusFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||
PowerFactorAStatusFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||
CurrentAStatusFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||
|
||||
// Phase B
|
||||
EnergyConsumedBStatusFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||
ActivePowerBStatusFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||
VoltageBStatusFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||
CurrentBStatusFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||
PowerFactorBStatusFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||
|
||||
// Phase C
|
||||
EnergyConsumedCStatusFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||
ActivePowerCStatusFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||
VoltageCStatusFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||
CurrentCStatusFunction(
|
||||
deviceId: uuid ?? '',
|
||||
deviceName: name ?? '',
|
||||
type: 'IF'),
|
||||
PowerFactorCStatusFunction(
|
||||
deviceId: uuid ?? '',
|
||||
deviceName: name ?? '',
|
||||
type: 'IF'),
|
||||
];
|
||||
|
||||
default:
|
||||
return [];
|
||||
@ -526,5 +582,6 @@ SOS
|
||||
"GD": DeviceType.GarageDoor,
|
||||
"WL": DeviceType.WaterLeak,
|
||||
"NCPS": DeviceType.NCPS,
|
||||
"PC": DeviceType.PC,
|
||||
};
|
||||
}
|
||||
|
@ -97,7 +97,8 @@ class DeviceControlDialog extends StatelessWidget with RouteControlsBasedCode {
|
||||
children: [
|
||||
_buildInfoRow('Space Name:',
|
||||
device.spaces?.firstOrNull?.spaceName ?? 'N/A'),
|
||||
_buildInfoRow('Room:', device.subspace?.subspaceName ?? 'N/A'),
|
||||
_buildInfoRow(
|
||||
'Sub space:', device.subspace?.subspaceName ?? 'N/A'),
|
||||
],
|
||||
),
|
||||
TableRow(
|
||||
|
@ -11,16 +11,11 @@ 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_event.dart';
|
||||
import 'package:syncrow_web/services/home_api.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
import 'package:syncrow_web/utils/constants/routes_const.dart';
|
||||
import 'package:syncrow_web/utils/navigation_service.dart';
|
||||
|
||||
class HomeBloc extends Bloc<HomeEvent, HomeState> {
|
||||
// final Graph graph = Graph()..isTree = true;
|
||||
// final BuchheimWalkerConfiguration builder = BuchheimWalkerConfiguration();
|
||||
// List<Node> sourcesList = [];
|
||||
// List<Node> destinationsList = [];
|
||||
UserModel? user;
|
||||
String terms = '';
|
||||
String policy = '';
|
||||
@ -33,22 +28,6 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
|
||||
on<ConfirmUserAgreementEvent>(_confirmUserAgreement);
|
||||
}
|
||||
|
||||
// void _createNode(CreateNewNode event, Emitter<HomeState> emit) async {
|
||||
// emit(HomeInitial());
|
||||
// sourcesList.add(event.sourceNode);
|
||||
// destinationsList.add(event.destinationNode);
|
||||
// for (int i = 0; i < sourcesList.length; i++) {
|
||||
// graph.addEdge(sourcesList[i], destinationsList[i]);
|
||||
// }
|
||||
|
||||
// builder
|
||||
// ..siblingSeparation = (100)
|
||||
// ..levelSeparation = (150)
|
||||
// ..subtreeSeparation = (150)
|
||||
// ..orientation = (BuchheimWalkerConfiguration.ORIENTATION_TOP_BOTTOM);
|
||||
// emit(HomeUpdateTree(graph: graph, builder: builder));
|
||||
// }
|
||||
|
||||
Future _fetchUserInfo(FetchUserInfo event, Emitter<HomeState> emit) async {
|
||||
try {
|
||||
var uuid = await const FlutterSecureStorage().read(key: UserModel.userUuidKey);
|
||||
@ -99,16 +78,6 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
|
||||
}
|
||||
}
|
||||
|
||||
// static Future fetchUserInfo() async {
|
||||
// try {
|
||||
// var uuid =
|
||||
// await const FlutterSecureStorage().read(key: UserModel.userUuidKey);
|
||||
// user = await HomeApi().fetchUserInfo(uuid);
|
||||
// } catch (e) {
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
List<HomeItemModel> homeItems = [
|
||||
HomeItemModel(
|
||||
title: 'Access Management',
|
||||
@ -118,7 +87,7 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
|
||||
context.read<SpaceTreeBloc>().add(ClearCachedData());
|
||||
context.go(RoutesConst.accessManagementPage);
|
||||
},
|
||||
color: null,
|
||||
color: const Color(0xFF0036E6),
|
||||
),
|
||||
HomeItemModel(
|
||||
title: 'Space Management',
|
||||
@ -128,7 +97,7 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
|
||||
context.read<SpaceTreeBloc>().add(ClearCachedData());
|
||||
context.go(RoutesConst.spacesManagementPage);
|
||||
},
|
||||
color: ColorsManager.primaryColor,
|
||||
color: const Color(0xFF0026A2),
|
||||
),
|
||||
HomeItemModel(
|
||||
title: 'Devices Management',
|
||||
@ -140,12 +109,11 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
|
||||
.add(const TriggerSwitchTabsEvent(isRoutineTab: false));
|
||||
context.go(RoutesConst.deviceManagementPage);
|
||||
},
|
||||
color: ColorsManager.primaryColor,
|
||||
color: const Color(0xFF00165E),
|
||||
),
|
||||
|
||||
HomeItemModel(
|
||||
title: 'Syncrow Analytics',
|
||||
icon: Assets.devicesIcon,
|
||||
icon: Assets.analyticsIcon,
|
||||
active: true,
|
||||
onPress: (context) {
|
||||
context.read<SpaceTreeBloc>().add(ClearCachedData());
|
||||
@ -153,43 +121,7 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
|
||||
.add(const TriggerSwitchTabsEvent(isRoutineTab: false));
|
||||
context.go(RoutesConst.analytics);
|
||||
},
|
||||
color: ColorsManager.primaryColor,
|
||||
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),
|
||||
// ),
|
||||
];
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
|
||||
class HomeCard extends StatelessWidget {
|
||||
final bool active;
|
||||
@ -8,6 +7,7 @@ class HomeCard extends StatelessWidget {
|
||||
final int index;
|
||||
final String name;
|
||||
final Function()? onTap;
|
||||
final Color? color;
|
||||
const HomeCard({
|
||||
super.key,
|
||||
required this.name,
|
||||
@ -15,28 +15,16 @@ class HomeCard extends StatelessWidget {
|
||||
this.active = false,
|
||||
required this.img,
|
||||
required this.onTap,
|
||||
required this.color,
|
||||
});
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// bool evenNumbers = index % 2 == 0;
|
||||
return InkWell(
|
||||
onTap: active ? onTap : null,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.only(left: 10, right: 10, bottom: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: index == 0 && active
|
||||
? ColorsManager.blue1.withOpacity(0.9)
|
||||
: index == 1 && active
|
||||
? ColorsManager.blue2.withOpacity(0.9)
|
||||
: index == 2 && active
|
||||
? ColorsManager.blue3
|
||||
: index == 4 && active == false
|
||||
? ColorsManager.blue4.withOpacity(0.2)
|
||||
: index == 7 && active == false
|
||||
? ColorsManager.blue4.withOpacity(0.2)
|
||||
: ColorsManager.blueColor.withOpacity(0.2),
|
||||
// (active ?ColorsManager.blueColor
|
||||
// : ColorsManager.blueColor.withOpacity(0.2)),
|
||||
color: color,
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
),
|
||||
child: Column(
|
||||
@ -64,15 +52,9 @@ class HomeCard extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Expanded(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
SizedBox(
|
||||
child: SvgPicture.asset(
|
||||
img,
|
||||
),
|
||||
),
|
||||
],
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional.bottomEnd,
|
||||
child: SvgPicture.asset(img),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
@ -50,7 +50,7 @@ class HomeMobilePage extends StatelessWidget {
|
||||
height: size.height * 0.6,
|
||||
width: size.width * 0.68,
|
||||
child: GridView.builder(
|
||||
itemCount: homeItems.length,
|
||||
itemCount: homeBloc.homeItems.length,
|
||||
gridDelegate:
|
||||
const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
@ -61,7 +61,8 @@ class HomeMobilePage extends StatelessWidget {
|
||||
itemBuilder: (context, index) {
|
||||
return HomeCard(
|
||||
index: index,
|
||||
active: homeBloc.homeItems[index].active!,
|
||||
active: true,
|
||||
color: homeBloc.homeItems[index].color,
|
||||
name: homeBloc.homeItems[index].title!,
|
||||
img: homeBloc.homeItems[index].icon!,
|
||||
onTap: () =>
|
||||
@ -78,56 +79,4 @@ class HomeMobilePage extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
final dynamic homeItems = [
|
||||
{
|
||||
'title': 'Access',
|
||||
'icon': Assets.accessIcon,
|
||||
'active': true,
|
||||
},
|
||||
{
|
||||
'title': 'Space\nManagement',
|
||||
'icon': Assets.spaseManagementIcon,
|
||||
'color': ColorsManager.primaryColor,
|
||||
'active': true,
|
||||
},
|
||||
{
|
||||
'title': 'Devices',
|
||||
'icon': Assets.devicesIcon,
|
||||
'active': true,
|
||||
},
|
||||
{
|
||||
'title': 'Syncrow Analytics',
|
||||
'icon': Assets.iconEdit,
|
||||
'active': true,
|
||||
},
|
||||
// {
|
||||
// 'title': 'Move in',
|
||||
// 'icon': Assets.moveinIcon,
|
||||
// 'active': false,
|
||||
// },
|
||||
// {
|
||||
// 'title': 'Construction',
|
||||
// 'icon': Assets.constructionIcon,
|
||||
// 'active': false,
|
||||
// },
|
||||
// {
|
||||
// 'title': 'Energy',
|
||||
// 'icon': Assets.energyIcon,
|
||||
// 'color': ColorsManager.slidingBlueColor.withOpacity(0.2),
|
||||
// 'active': false,
|
||||
// },
|
||||
// {
|
||||
// 'title': 'Integrations',
|
||||
// 'icon': Assets.integrationsIcon,
|
||||
// 'color': ColorsManager.slidingBlueColor.withOpacity(0.2),
|
||||
// 'active': false,
|
||||
// },
|
||||
// {
|
||||
// 'title': 'Asset',
|
||||
// 'icon': Assets.assetIcon,
|
||||
// 'color': ColorsManager.slidingBlueColor.withOpacity(0.2),
|
||||
// 'active': false,
|
||||
// },
|
||||
];
|
||||
}
|
||||
|
@ -106,6 +106,7 @@ class _HomeWebPageState extends State<HomeWebPage> {
|
||||
),
|
||||
itemBuilder: (context, index) {
|
||||
return HomeCard(
|
||||
color: homeBloc.homeItems[index].color,
|
||||
index: index,
|
||||
active: homeBloc.homeItems[index].active!,
|
||||
name: homeBloc.homeItems[index].title!,
|
||||
|
@ -5,7 +5,7 @@ import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
Future<void> showNameMenu({
|
||||
required BuildContext context,
|
||||
Function()? aToZTap,
|
||||
Function()? zToaTap,
|
||||
Function()? zToATap,
|
||||
String? isSelected,
|
||||
}) async {
|
||||
final RenderBox overlay =
|
||||
@ -46,7 +46,7 @@ Future<void> showNameMenu({
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
onTap: zToaTap,
|
||||
onTap: zToATap,
|
||||
child: ListTile(
|
||||
leading: Image.asset(
|
||||
Assets.ZtoAIcon,
|
||||
|
@ -95,7 +95,7 @@ class _TableRow extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
if (!isLast)
|
||||
Divider(
|
||||
const Divider(
|
||||
height: 1,
|
||||
thickness: 1,
|
||||
color: ColorsManager.boxDivider,
|
||||
@ -110,12 +110,14 @@ class DynamicTableScreen extends StatefulWidget {
|
||||
final List<String> titles;
|
||||
final List<List<Widget>> rows;
|
||||
final void Function(int columnIndex)? onFilter;
|
||||
final double tableSize;
|
||||
|
||||
const DynamicTableScreen({
|
||||
required this.titles,
|
||||
required this.rows,
|
||||
required this.onFilter,
|
||||
Key? key,
|
||||
required this.tableSize,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
@ -205,7 +207,8 @@ class _DynamicTableScreenState extends State<DynamicTableScreen> {
|
||||
bottomRight: Radius.circular(15),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
child: ListView(
|
||||
shrinkWrap: true,
|
||||
children: [
|
||||
for (int rowIndex = 0; rowIndex < widget.rows.length; rowIndex++)
|
||||
_TableRow(
|
||||
@ -253,7 +256,7 @@ class _DynamicTableScreenState extends State<DynamicTableScreen> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildHeader(),
|
||||
_buildBody(),
|
||||
Container(height: widget.tableSize - 37, child: _buildBody()),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@ -27,7 +27,8 @@ class UsersPage extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final TextEditingController searchController = TextEditingController();
|
||||
|
||||
Widget actionButton({bool isActive = false, required String title, Function()? onTap}) {
|
||||
Widget actionButton(
|
||||
{bool isActive = false, required String title, Function()? onTap}) {
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
child: Padding(
|
||||
@ -60,7 +61,8 @@ class UsersPage extends StatelessWidget {
|
||||
: ColorsManager.disabledPink.withOpacity(0.5),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 10, right: 10, bottom: 5, top: 5),
|
||||
padding:
|
||||
const EdgeInsets.only(left: 10, right: 10, bottom: 5, top: 5),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
@ -84,12 +86,15 @@ class UsersPage extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget changeIconStatus(
|
||||
{required String userId, required String status, required Function()? onTap}) {
|
||||
{required String userId,
|
||||
required String status,
|
||||
required Function()? onTap}) {
|
||||
return Center(
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 5, right: 5, bottom: 5, top: 5),
|
||||
padding:
|
||||
const EdgeInsets.only(left: 5, right: 5, bottom: 5, top: 5),
|
||||
child: SvgPicture.asset(
|
||||
status == "invited"
|
||||
? Assets.invitedIcon
|
||||
@ -114,8 +119,7 @@ class UsersPage extends StatelessWidget {
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: ListView(
|
||||
shrinkWrap: true,
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
@ -188,18 +192,25 @@ class UsersPage extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
DynamicTableScreen(
|
||||
const SizedBox(height: 20),
|
||||
Container(
|
||||
height: screenSize.height * 0.65,
|
||||
child: DynamicTableScreen(
|
||||
tableSize: screenSize.height * 0.65,
|
||||
onFilter: (columnIndex) {
|
||||
if (columnIndex == 0) {
|
||||
showNameMenu(
|
||||
context: context,
|
||||
isSelected: _blocRole.currentSortOrder,
|
||||
aToZTap: () {
|
||||
context.read<UserTableBloc>().add(const SortUsersByNameAsc());
|
||||
context
|
||||
.read<UserTableBloc>()
|
||||
.add(const SortUsersByNameAsc());
|
||||
},
|
||||
zToaTap: () {
|
||||
context.read<UserTableBloc>().add(const SortUsersByNameDesc());
|
||||
zToATap: () {
|
||||
context
|
||||
.read<UserTableBloc>()
|
||||
.add(const SortUsersByNameDesc());
|
||||
},
|
||||
);
|
||||
}
|
||||
@ -208,8 +219,9 @@ class UsersPage extends StatelessWidget {
|
||||
for (var item in _blocRole.jobTitle)
|
||||
item: _blocRole.selectedJobTitles.contains(item),
|
||||
};
|
||||
final RenderBox overlay =
|
||||
Overlay.of(context).context.findRenderObject() as RenderBox;
|
||||
final RenderBox overlay = Overlay.of(context)
|
||||
.context
|
||||
.findRenderObject() as RenderBox;
|
||||
|
||||
showPopUpFilterMenu(
|
||||
position: RelativeRect.fromLTRB(
|
||||
@ -249,8 +261,9 @@ class UsersPage extends StatelessWidget {
|
||||
for (var item in _blocRole.roleTypes)
|
||||
item: _blocRole.selectedRoles.contains(item),
|
||||
};
|
||||
final RenderBox overlay =
|
||||
Overlay.of(context).context.findRenderObject() as RenderBox;
|
||||
final RenderBox overlay = Overlay.of(context)
|
||||
.context
|
||||
.findRenderObject() as RenderBox;
|
||||
showPopUpFilterMenu(
|
||||
position: RelativeRect.fromLTRB(
|
||||
overlay.size.width / 4,
|
||||
@ -270,7 +283,8 @@ class UsersPage extends StatelessWidget {
|
||||
.map((entry) => entry.key)
|
||||
.toList();
|
||||
Navigator.of(context).pop();
|
||||
context.read<UserTableBloc>().add(FilterUsersByRoleEvent(
|
||||
context.read<UserTableBloc>().add(
|
||||
FilterUsersByRoleEvent(
|
||||
selectedRoles: selectedItems,
|
||||
sortOrder: _blocRole.currentSortRole));
|
||||
},
|
||||
@ -287,10 +301,14 @@ class UsersPage extends StatelessWidget {
|
||||
context: context,
|
||||
isSelected: _blocRole.currentSortOrder,
|
||||
aToZTap: () {
|
||||
context.read<UserTableBloc>().add(const DateNewestToOldestEvent());
|
||||
context
|
||||
.read<UserTableBloc>()
|
||||
.add(const DateNewestToOldestEvent());
|
||||
},
|
||||
zToaTap: () {
|
||||
context.read<UserTableBloc>().add(const DateOldestToNewestEvent());
|
||||
context
|
||||
.read<UserTableBloc>()
|
||||
.add(const DateOldestToNewestEvent());
|
||||
},
|
||||
);
|
||||
}
|
||||
@ -299,8 +317,9 @@ class UsersPage extends StatelessWidget {
|
||||
for (var item in _blocRole.createdBy)
|
||||
item: _blocRole.selectedCreatedBy.contains(item),
|
||||
};
|
||||
final RenderBox overlay =
|
||||
Overlay.of(context).context.findRenderObject() as RenderBox;
|
||||
final RenderBox overlay = Overlay.of(context)
|
||||
.context
|
||||
.findRenderObject() as RenderBox;
|
||||
showPopUpFilterMenu(
|
||||
position: RelativeRect.fromLTRB(
|
||||
overlay.size.width / 1,
|
||||
@ -338,8 +357,9 @@ class UsersPage extends StatelessWidget {
|
||||
item: _blocRole.selectedStatuses.contains(item),
|
||||
};
|
||||
|
||||
final RenderBox overlay =
|
||||
Overlay.of(context).context.findRenderObject() as RenderBox;
|
||||
final RenderBox overlay = Overlay.of(context)
|
||||
.context
|
||||
.findRenderObject() as RenderBox;
|
||||
showPopUpFilterMenu(
|
||||
position: RelativeRect.fromLTRB(
|
||||
overlay.size.width / 0,
|
||||
@ -376,10 +396,14 @@ class UsersPage extends StatelessWidget {
|
||||
context: context,
|
||||
isSelected: _blocRole.currentSortOrderDate,
|
||||
aToZTap: () {
|
||||
context.read<UserTableBloc>().add(const DateNewestToOldestEvent());
|
||||
context
|
||||
.read<UserTableBloc>()
|
||||
.add(const DateNewestToOldestEvent());
|
||||
},
|
||||
zToaTap: () {
|
||||
context.read<UserTableBloc>().add(const DateOldestToNewestEvent());
|
||||
context
|
||||
.read<UserTableBloc>()
|
||||
.add(const DateOldestToNewestEvent());
|
||||
},
|
||||
);
|
||||
}
|
||||
@ -406,17 +430,23 @@ class UsersPage extends StatelessWidget {
|
||||
Text(user.createdTime ?? ''),
|
||||
Text(user.invitedBy),
|
||||
status(
|
||||
status: user.isEnabled == false ? 'disabled' : user.status,
|
||||
status: user.isEnabled == false
|
||||
? 'disabled'
|
||||
: user.status,
|
||||
),
|
||||
changeIconStatus(
|
||||
status: user.isEnabled == false ? 'disabled' : user.status,
|
||||
status: user.isEnabled == false
|
||||
? 'disabled'
|
||||
: user.status,
|
||||
userId: user.uuid,
|
||||
onTap: user.status != "invited"
|
||||
? () {
|
||||
context.read<UserTableBloc>().add(ChangeUserStatus(
|
||||
context.read<UserTableBloc>().add(
|
||||
ChangeUserStatus(
|
||||
userId: user.uuid,
|
||||
newStatus:
|
||||
user.isEnabled == false ? 'disabled' : user.status));
|
||||
newStatus: user.isEnabled == false
|
||||
? 'disabled'
|
||||
: user.status));
|
||||
}
|
||||
: null,
|
||||
),
|
||||
@ -427,12 +457,15 @@ class UsersPage extends StatelessWidget {
|
||||
isActive: true,
|
||||
title: "Edit",
|
||||
onTap: () {
|
||||
context.read<SpaceTreeBloc>().add(ClearCachedData());
|
||||
context
|
||||
.read<SpaceTreeBloc>()
|
||||
.add(ClearCachedData());
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (BuildContext context) {
|
||||
return EditUserDialog(userId: user.uuid);
|
||||
return EditUserDialog(
|
||||
userId: user.uuid);
|
||||
},
|
||||
).then((v) {
|
||||
if (v != null) {
|
||||
@ -453,10 +486,13 @@ class UsersPage extends StatelessWidget {
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (BuildContext context) {
|
||||
return DeleteUserDialog(onTapDelete: () async {
|
||||
return DeleteUserDialog(
|
||||
onTapDelete: () async {
|
||||
try {
|
||||
_blocRole.add(DeleteUserEvent(user.uuid, context));
|
||||
await Future.delayed(const Duration(seconds: 2));
|
||||
_blocRole.add(DeleteUserEvent(
|
||||
user.uuid, context));
|
||||
await Future.delayed(
|
||||
const Duration(seconds: 2));
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
@ -475,6 +511,7 @@ class UsersPage extends StatelessWidget {
|
||||
];
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
@ -486,14 +523,20 @@ class UsersPage extends StatelessWidget {
|
||||
visiblePagesCount: 4,
|
||||
buttonRadius: 10,
|
||||
selectedButtonColor: ColorsManager.secondaryColor,
|
||||
buttonUnSelectedBorderColor: ColorsManager.grayBorder,
|
||||
lastPageIcon: const Icon(Icons.keyboard_double_arrow_right),
|
||||
firstPageIcon: const Icon(Icons.keyboard_double_arrow_left),
|
||||
totalPages:
|
||||
(_blocRole.totalUsersCount.length / _blocRole.itemsPerPage).ceil(),
|
||||
buttonUnSelectedBorderColor:
|
||||
ColorsManager.grayBorder,
|
||||
lastPageIcon:
|
||||
const Icon(Icons.keyboard_double_arrow_right),
|
||||
firstPageIcon:
|
||||
const Icon(Icons.keyboard_double_arrow_left),
|
||||
totalPages: (_blocRole.totalUsersCount.length /
|
||||
_blocRole.itemsPerPage)
|
||||
.ceil(),
|
||||
currentPage: _blocRole.currentPage,
|
||||
onPageChanged: (int pageNumber) {
|
||||
context.read<UserTableBloc>().add(ChangePage(pageNumber));
|
||||
context
|
||||
.read<UserTableBloc>()
|
||||
.add(ChangePage(pageNumber));
|
||||
},
|
||||
),
|
||||
),
|
||||
|
@ -7,6 +7,7 @@ import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/ceiling_senso
|
||||
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/one_gang_switch_dialog.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/power_clamp_enargy/energy_clamp_dialog.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/three_gang_switch_dialog.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/two_gang_switch_dialog.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/wall_sensor/wall_presence_sensor.dart';
|
||||
@ -137,6 +138,16 @@ class DeviceDialogHelper {
|
||||
device: data['device'],
|
||||
);
|
||||
|
||||
case 'PC':
|
||||
return EnergyClampDialog.showEnergyClampFunctionsDialog(
|
||||
context: context,
|
||||
functions: functions,
|
||||
uniqueCustomId: data['uniqueCustomId'],
|
||||
deviceSelectedFunctions: deviceSelectedFunctions,
|
||||
dialogType: dialogType,
|
||||
device: data['device'],
|
||||
);
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ abstract class DeviceFunction<T> {
|
||||
final double? max;
|
||||
final double? min;
|
||||
|
||||
|
||||
DeviceFunction({
|
||||
required this.deviceId,
|
||||
required this.deviceName,
|
||||
@ -114,4 +113,28 @@ class DeviceFunctionData {
|
||||
max.hashCode ^
|
||||
min.hashCode;
|
||||
}
|
||||
|
||||
DeviceFunctionData copyWith({
|
||||
String? entityId,
|
||||
String? functionCode,
|
||||
String? operationName,
|
||||
String? condition,
|
||||
dynamic value,
|
||||
double? step,
|
||||
String? unit,
|
||||
double? max,
|
||||
double? min,
|
||||
}) {
|
||||
return DeviceFunctionData(
|
||||
entityId: entityId ?? this.entityId,
|
||||
functionCode: functionCode ?? this.functionCode,
|
||||
operationName: operationName ?? this.operationName,
|
||||
condition: condition ?? this.condition,
|
||||
value: value ?? this.value,
|
||||
step: step ?? this.step,
|
||||
unit: unit ?? this.unit,
|
||||
max: max ?? this.max,
|
||||
min: min ?? this.min,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
416
lib/pages/routines/models/pc/energy_clamp_functions.dart
Normal file
416
lib/pages/routines/models/pc/energy_clamp_functions.dart
Normal file
@ -0,0 +1,416 @@
|
||||
import 'package:syncrow_web/pages/device_managment/power_clamp/models/power_clamp_batch_model.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/pc/enrgy_clamp_operational_value.dart';
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
|
||||
abstract class EnergyClampFunctions extends DeviceFunction<PowerClampModel1> {
|
||||
final String type;
|
||||
|
||||
EnergyClampFunctions({
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.code,
|
||||
required super.operationName,
|
||||
required super.icon,
|
||||
required this.type,
|
||||
super.step,
|
||||
super.unit,
|
||||
super.max,
|
||||
super.min,
|
||||
});
|
||||
|
||||
List<EnergyClampOperationalValue> getOperationalValues();
|
||||
}
|
||||
|
||||
// General & shared
|
||||
class TotalEnergyConsumedStatusFunction extends EnergyClampFunctions {
|
||||
TotalEnergyConsumedStatusFunction({
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: 'EnergyConsumed',
|
||||
operationName: 'Total Energy Consumed',
|
||||
icon: Assets.energyConsumedIcon,
|
||||
min: 0.00,
|
||||
max: 20000000.00,
|
||||
step: 1,
|
||||
unit: "kWh",
|
||||
);
|
||||
|
||||
@override
|
||||
List<EnergyClampOperationalValue> getOperationalValues() => [];
|
||||
}
|
||||
|
||||
class TotalActivePowerConsumedStatusFunction extends EnergyClampFunctions {
|
||||
TotalActivePowerConsumedStatusFunction({
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: 'ActivePower',
|
||||
operationName: 'Total Active Power',
|
||||
icon: Assets.powerActiveIcon,
|
||||
min: -19800000,
|
||||
max: 19800000,
|
||||
step: 0.1,
|
||||
unit: "kW",
|
||||
);
|
||||
|
||||
@override
|
||||
List<EnergyClampOperationalValue> getOperationalValues() => [];
|
||||
}
|
||||
|
||||
class VoltagePhaseSequenceDetectionFunction extends EnergyClampFunctions {
|
||||
VoltagePhaseSequenceDetectionFunction({
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: 'voltage_phase_seq',
|
||||
operationName: 'Voltage phase sequence detection',
|
||||
icon: Assets.voltageIcon,
|
||||
);
|
||||
|
||||
@override
|
||||
List<EnergyClampOperationalValue> getOperationalValues() => [
|
||||
EnergyClampOperationalValue(
|
||||
icon: Assets.voltageIcon, description: '0', value: '0'),
|
||||
EnergyClampOperationalValue(
|
||||
icon: Assets.voltageIcon, description: '1', value: '1'),
|
||||
EnergyClampOperationalValue(
|
||||
icon: Assets.voltageIcon, description: '2', value: '2'),
|
||||
EnergyClampOperationalValue(
|
||||
icon: Assets.voltageIcon, description: '3', value: '3'),
|
||||
EnergyClampOperationalValue(
|
||||
icon: Assets.voltageIcon, description: '4', value: '4'),
|
||||
EnergyClampOperationalValue(
|
||||
icon: Assets.voltageIcon, description: '5', value: '5'),
|
||||
];
|
||||
}
|
||||
|
||||
class TotalCurrentStatusFunction extends EnergyClampFunctions {
|
||||
TotalCurrentStatusFunction({
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: 'Current',
|
||||
operationName: 'Total Current',
|
||||
icon: Assets.voltMeterIcon,
|
||||
min: 0.000,
|
||||
max: 9000.000,
|
||||
step: 1,
|
||||
unit: "A",
|
||||
);
|
||||
|
||||
@override
|
||||
List<EnergyClampOperationalValue> getOperationalValues() => [];
|
||||
}
|
||||
|
||||
class FrequencyStatusFunction extends EnergyClampFunctions {
|
||||
FrequencyStatusFunction({
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: 'Frequency',
|
||||
operationName: 'Frequency',
|
||||
icon: Assets.frequencyIcon,
|
||||
min: 0,
|
||||
max: 80,
|
||||
step: 1,
|
||||
unit: "Hz",
|
||||
);
|
||||
|
||||
@override
|
||||
List<EnergyClampOperationalValue> getOperationalValues() => [];
|
||||
}
|
||||
|
||||
// Phase A
|
||||
class EnergyConsumedAStatusFunction extends EnergyClampFunctions {
|
||||
EnergyConsumedAStatusFunction({
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: 'EnergyConsumedA',
|
||||
operationName: 'Energy Consumed A',
|
||||
icon: Assets.energyConsumedIcon,
|
||||
min: 0.00,
|
||||
max: 20000000.00,
|
||||
step: 1,
|
||||
unit: "kWh",
|
||||
);
|
||||
|
||||
@override
|
||||
List<EnergyClampOperationalValue> getOperationalValues() => [];
|
||||
}
|
||||
|
||||
class ActivePowerAStatusFunction extends EnergyClampFunctions {
|
||||
ActivePowerAStatusFunction({
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: 'ActivePowerA',
|
||||
operationName: 'Active Power A',
|
||||
icon: Assets.powerActiveIcon,
|
||||
min: 200,
|
||||
max: 300,
|
||||
step: 1,
|
||||
unit: "kW",
|
||||
);
|
||||
|
||||
@override
|
||||
List<EnergyClampOperationalValue> getOperationalValues() => [];
|
||||
}
|
||||
|
||||
class VoltageAStatusFunction extends EnergyClampFunctions {
|
||||
VoltageAStatusFunction({
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: 'VoltageA',
|
||||
operationName: 'Voltage A',
|
||||
icon: Assets.voltageIcon,
|
||||
min: 0.0,
|
||||
max: 500,
|
||||
step: 1,
|
||||
unit: "V",
|
||||
);
|
||||
|
||||
@override
|
||||
List<EnergyClampOperationalValue> getOperationalValues() => [];
|
||||
}
|
||||
|
||||
class PowerFactorAStatusFunction extends EnergyClampFunctions {
|
||||
PowerFactorAStatusFunction({
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: 'PowerFactorA',
|
||||
operationName: 'Power Factor A',
|
||||
icon: Assets.speedoMeter,
|
||||
min: 0.00,
|
||||
max: 1.00,
|
||||
step: 0.1,
|
||||
unit: "",
|
||||
);
|
||||
|
||||
@override
|
||||
List<EnergyClampOperationalValue> getOperationalValues() => [];
|
||||
}
|
||||
|
||||
class CurrentAStatusFunction extends EnergyClampFunctions {
|
||||
CurrentAStatusFunction({
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: 'CurrentA',
|
||||
operationName: 'Current A',
|
||||
icon: Assets.voltMeterIcon,
|
||||
min: 0.000,
|
||||
max: 3000.000,
|
||||
step: 1,
|
||||
unit: "A",
|
||||
);
|
||||
|
||||
@override
|
||||
List<EnergyClampOperationalValue> getOperationalValues() => [];
|
||||
}
|
||||
|
||||
// Phase B
|
||||
class EnergyConsumedBStatusFunction extends EnergyClampFunctions {
|
||||
EnergyConsumedBStatusFunction({
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: 'EnergyConsumedB',
|
||||
operationName: 'Energy Consumed B',
|
||||
icon: Assets.energyConsumedIcon,
|
||||
min: 0.00,
|
||||
max: 20000000.00,
|
||||
step: 1,
|
||||
unit: "kWh",
|
||||
);
|
||||
|
||||
@override
|
||||
List<EnergyClampOperationalValue> getOperationalValues() => [];
|
||||
}
|
||||
|
||||
class ActivePowerBStatusFunction extends EnergyClampFunctions {
|
||||
ActivePowerBStatusFunction({
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: 'ActivePowerB',
|
||||
operationName: 'Active Power B',
|
||||
icon: Assets.powerActiveIcon,
|
||||
min: -6600000,
|
||||
max: 6600000,
|
||||
step: 1,
|
||||
unit: "kW",
|
||||
);
|
||||
|
||||
@override
|
||||
List<EnergyClampOperationalValue> getOperationalValues() => [];
|
||||
}
|
||||
|
||||
class VoltageBStatusFunction extends EnergyClampFunctions {
|
||||
VoltageBStatusFunction({
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: 'VoltageB',
|
||||
operationName: 'Voltage B',
|
||||
icon: Assets.voltageIcon,
|
||||
min: 0.0,
|
||||
max: 500,
|
||||
step: 1,
|
||||
unit: "V",
|
||||
);
|
||||
|
||||
@override
|
||||
List<EnergyClampOperationalValue> getOperationalValues() => [];
|
||||
}
|
||||
|
||||
class CurrentBStatusFunction extends EnergyClampFunctions {
|
||||
CurrentBStatusFunction({
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: 'CurrentB',
|
||||
operationName: 'Current B',
|
||||
icon: Assets.voltMeterIcon,
|
||||
min: 0.000,
|
||||
max: 3000.000,
|
||||
step: 1,
|
||||
unit: "A",
|
||||
);
|
||||
|
||||
@override
|
||||
List<EnergyClampOperationalValue> getOperationalValues() => [];
|
||||
}
|
||||
|
||||
class PowerFactorBStatusFunction extends EnergyClampFunctions {
|
||||
PowerFactorBStatusFunction({
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: 'PowerFactorB',
|
||||
operationName: 'Power Factor B',
|
||||
icon: Assets.speedoMeter,
|
||||
min: 0.0,
|
||||
max: 1.0,
|
||||
step: 0.1,
|
||||
unit: "",
|
||||
);
|
||||
|
||||
@override
|
||||
List<EnergyClampOperationalValue> getOperationalValues() => [];
|
||||
}
|
||||
|
||||
// Phase C
|
||||
class EnergyConsumedCStatusFunction extends EnergyClampFunctions {
|
||||
EnergyConsumedCStatusFunction({
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: 'EnergyConsumedC',
|
||||
operationName: 'Energy Consumed C',
|
||||
icon: Assets.energyConsumedIcon,
|
||||
min: 0.00,
|
||||
max: 20000000.00,
|
||||
step: 1,
|
||||
unit: "kWh",
|
||||
);
|
||||
|
||||
@override
|
||||
List<EnergyClampOperationalValue> getOperationalValues() => [];
|
||||
}
|
||||
|
||||
class ActivePowerCStatusFunction extends EnergyClampFunctions {
|
||||
ActivePowerCStatusFunction({
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: 'ActivePowerC',
|
||||
operationName: 'Active Power C',
|
||||
icon: Assets.powerActiveIcon,
|
||||
min: -6600000,
|
||||
max: 6600000,
|
||||
step: 1,
|
||||
unit: "kW",
|
||||
);
|
||||
|
||||
@override
|
||||
List<EnergyClampOperationalValue> getOperationalValues() => [];
|
||||
}
|
||||
|
||||
class VoltageCStatusFunction extends EnergyClampFunctions {
|
||||
VoltageCStatusFunction({
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: 'VoltageC',
|
||||
operationName: 'Voltage C',
|
||||
icon: Assets.voltageIcon,
|
||||
min: 0.00,
|
||||
max: 500,
|
||||
step: 0.1,
|
||||
unit: "V",
|
||||
);
|
||||
|
||||
@override
|
||||
List<EnergyClampOperationalValue> getOperationalValues() => [];
|
||||
}
|
||||
|
||||
class CurrentCStatusFunction extends EnergyClampFunctions {
|
||||
CurrentCStatusFunction({
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: 'CurrentC',
|
||||
operationName: 'Current C',
|
||||
icon: Assets.voltMeterIcon,
|
||||
min: 0.000,
|
||||
max: 3000.000,
|
||||
step: 0.1,
|
||||
unit: "A",
|
||||
);
|
||||
|
||||
@override
|
||||
List<EnergyClampOperationalValue> getOperationalValues() => [];
|
||||
}
|
||||
|
||||
class PowerFactorCStatusFunction extends EnergyClampFunctions {
|
||||
PowerFactorCStatusFunction({
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: 'PowerFactorC',
|
||||
operationName: 'Power Factor C',
|
||||
icon: Assets.speedoMeter,
|
||||
min: 0.00,
|
||||
max: 1.00,
|
||||
step: 0.1,
|
||||
unit: "",
|
||||
);
|
||||
|
||||
@override
|
||||
List<EnergyClampOperationalValue> getOperationalValues() => [];
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
class EnergyClampOperationalValue {
|
||||
final String icon;
|
||||
final String description;
|
||||
final dynamic value;
|
||||
|
||||
EnergyClampOperationalValue({
|
||||
required this.icon,
|
||||
required this.description,
|
||||
required this.value,
|
||||
});
|
||||
}
|
@ -12,22 +12,53 @@ class ConditionToggle extends StatelessWidget {
|
||||
});
|
||||
|
||||
static const _conditions = ["<", "==", ">"];
|
||||
static const _icons = [
|
||||
Icons.chevron_left,
|
||||
Icons.drag_handle,
|
||||
Icons.chevron_right
|
||||
];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ToggleButtons(
|
||||
onPressed: (index) => onChanged(_conditions[index]),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
selectedBorderColor: ColorsManager.primaryColorWithOpacity,
|
||||
selectedColor: Colors.white,
|
||||
fillColor: ColorsManager.primaryColorWithOpacity,
|
||||
color: ColorsManager.primaryColorWithOpacity,
|
||||
constraints: const BoxConstraints(
|
||||
minHeight: 40.0,
|
||||
minWidth: 40.0,
|
||||
final selectedIndex = _conditions.indexOf(currentCondition ?? "==");
|
||||
|
||||
return Container(
|
||||
height: 30,
|
||||
width: MediaQuery.of(context).size.width * 0.1,
|
||||
decoration: BoxDecoration(
|
||||
color: ColorsManager.softGray.withOpacity(0.5),
|
||||
borderRadius: BorderRadius.circular(50),
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: List.generate(_conditions.length, (index) {
|
||||
final isSelected = index == selectedIndex;
|
||||
return Expanded(
|
||||
child: InkWell(
|
||||
onTap: () => onChanged(_conditions[index]),
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 180),
|
||||
curve: Curves.ease,
|
||||
decoration: BoxDecoration(
|
||||
color:
|
||||
isSelected ? ColorsManager.vividBlue : Colors.transparent,
|
||||
),
|
||||
child: Center(
|
||||
child: Icon(
|
||||
_icons[index],
|
||||
size: 20,
|
||||
color: isSelected
|
||||
? ColorsManager.whiteColors
|
||||
: ColorsManager.blackColor,
|
||||
weight: isSelected ? 700 : 500,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
isSelected: _conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
||||
children: _conditions.map((c) => Text(c)).toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ class CustomRoutinesTextbox extends StatefulWidget {
|
||||
|
||||
class _CustomRoutinesTextboxState extends State<CustomRoutinesTextbox> {
|
||||
late final TextEditingController _controller;
|
||||
|
||||
bool hasError = false;
|
||||
String? errorMessage;
|
||||
|
||||
@ -55,29 +56,63 @@ class _CustomRoutinesTextboxState extends State<CustomRoutinesTextbox> {
|
||||
}
|
||||
}
|
||||
|
||||
bool _isInitialized = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
int decimalPlaces = getDecimalPlaces(widget.stepIncreaseAmount);
|
||||
double initialValue;
|
||||
if (widget.initialValue != null &&
|
||||
widget.initialValue is num &&
|
||||
(widget.initialValue as num) == 0) {
|
||||
initialValue = 0.0;
|
||||
} else {
|
||||
initialValue = double.tryParse(widget.displayedValue) ?? 0.0;
|
||||
_initializeController();
|
||||
}
|
||||
|
||||
void _initializeController() {
|
||||
final decimalPlaces = getDecimalPlaces(widget.stepIncreaseAmount);
|
||||
final dynamic initialValue = widget.initialValue;
|
||||
double parsedValue;
|
||||
|
||||
if (initialValue is num) {
|
||||
parsedValue = initialValue.toDouble();
|
||||
} else if (initialValue is String) {
|
||||
parsedValue = double.tryParse(initialValue) ?? widget.sliderRange.$1;
|
||||
} else {
|
||||
parsedValue = widget.sliderRange.$1;
|
||||
}
|
||||
|
||||
_controller = TextEditingController(
|
||||
text: initialValue.toStringAsFixed(decimalPlaces),
|
||||
text: parsedValue.toStringAsFixed(decimalPlaces),
|
||||
);
|
||||
_isInitialized = true;
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
void didUpdateWidget(CustomRoutinesTextbox oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
|
||||
if (widget.initialValue != oldWidget.initialValue && _isInitialized) {
|
||||
final decimalPlaces = getDecimalPlaces(widget.stepIncreaseAmount);
|
||||
final dynamic initialValue = widget.initialValue;
|
||||
double newValue;
|
||||
|
||||
if (initialValue is num) {
|
||||
newValue = initialValue.toDouble();
|
||||
} else if (initialValue is String) {
|
||||
newValue = double.tryParse(initialValue) ?? widget.sliderRange.$1;
|
||||
} else {
|
||||
newValue = widget.sliderRange.$1;
|
||||
}
|
||||
|
||||
final newValueText = newValue.toStringAsFixed(decimalPlaces);
|
||||
if (_controller.text != newValueText) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_controller.text = newValueText;
|
||||
_controller.selection =
|
||||
TextSelection.collapsed(offset: _controller.text.length);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void _validateInput(String value) {
|
||||
final doubleValue = double.tryParse(value);
|
||||
if (doubleValue == null) {
|
||||
@ -121,18 +156,6 @@ class _CustomRoutinesTextboxState extends State<CustomRoutinesTextbox> {
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(CustomRoutinesTextbox oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (widget.initialValue != oldWidget.initialValue) {
|
||||
if (widget.initialValue != null &&
|
||||
widget.initialValue is num &&
|
||||
(widget.initialValue as num) == 0) {
|
||||
int decimalPlaces = getDecimalPlaces(widget.stepIncreaseAmount);
|
||||
_controller.text = 0.0.toStringAsFixed(decimalPlaces);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _correctAndUpdateValue(String value) {
|
||||
final doubleValue = double.tryParse(value) ?? 0.0;
|
||||
@ -227,9 +250,15 @@ class _CustomRoutinesTextboxState extends State<CustomRoutinesTextbox> {
|
||||
color: ColorsManager.blackColor,
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: widget.withSpecialChar == true
|
||||
? [FilteringTextInputFormatter.digitsOnly]
|
||||
: null,
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow(
|
||||
widget.withSpecialChar
|
||||
? RegExp(r'^-?\d*\.?\d{0,' +
|
||||
decimalPlaces.toString() +
|
||||
r'}$')
|
||||
: RegExp(r'\d+'),
|
||||
),
|
||||
],
|
||||
decoration: const InputDecoration(
|
||||
border: InputBorder.none,
|
||||
isDense: true,
|
||||
@ -268,8 +297,9 @@ class _CustomRoutinesTextboxState extends State<CustomRoutinesTextbox> {
|
||||
const SizedBox(height: 16),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 32),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
child: Wrap(
|
||||
alignment: WrapAlignment.spaceBetween,
|
||||
direction: Axis.horizontal,
|
||||
children: [
|
||||
Text(
|
||||
'Min. ${widget.sliderRange.$1.toInt()}${widget.unit}',
|
||||
@ -279,6 +309,9 @@ class _CustomRoutinesTextboxState extends State<CustomRoutinesTextbox> {
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 50,
|
||||
),
|
||||
Text(
|
||||
'Max. ${widget.sliderRange.$2.toInt()}${widget.unit}',
|
||||
style: context.textTheme.bodySmall?.copyWith(
|
||||
|
@ -78,9 +78,9 @@ class IfContainer extends StatelessWidget {
|
||||
'CPS',
|
||||
'NCPS',
|
||||
'WH',
|
||||
'PC',
|
||||
].contains(state.ifItems[index]
|
||||
['productType'])) {
|
||||
|
||||
context.read<RoutineBloc>().add(
|
||||
AddToIfContainer(
|
||||
state.ifItems[index], false));
|
||||
@ -137,8 +137,18 @@ class IfContainer extends StatelessWidget {
|
||||
context
|
||||
.read<RoutineBloc>()
|
||||
.add(AddToIfContainer(mutableData, false));
|
||||
} else if (!['AC', '1G', '2G', '3G', 'WPS', 'GW', 'CPS', 'NCPS','WH']
|
||||
.contains(mutableData['productType'])) {
|
||||
} else if (![
|
||||
'AC',
|
||||
'1G',
|
||||
'2G',
|
||||
'3G',
|
||||
'WPS',
|
||||
'GW',
|
||||
'CPS',
|
||||
'NCPS',
|
||||
'WH',
|
||||
'PC',
|
||||
].contains(mutableData['productType'])) {
|
||||
context
|
||||
.read<RoutineBloc>()
|
||||
.add(AddToIfContainer(mutableData, false));
|
||||
|
@ -27,6 +27,7 @@ class _RoutineDevicesState extends State<RoutineDevices> {
|
||||
'CPS',
|
||||
'NCPS',
|
||||
'WH',
|
||||
'PC',
|
||||
};
|
||||
|
||||
@override
|
||||
|
@ -76,7 +76,6 @@ class ACHelper {
|
||||
child: _buildFunctionsList(
|
||||
context: context,
|
||||
acFunctions: acFunctions,
|
||||
device: device,
|
||||
onFunctionSelected:
|
||||
(functionCode, operationName) {
|
||||
RoutineTapFunctionHelper.onTapFunction(
|
||||
@ -84,15 +83,15 @@ class ACHelper {
|
||||
functionCode: functionCode,
|
||||
functionOperationName: operationName,
|
||||
functionValueDescription:
|
||||
selectedFunctionData.valueDescription,
|
||||
selectedFunctionData
|
||||
.valueDescription,
|
||||
deviceUuid: device?.uuid,
|
||||
codesToAddIntoFunctionsWithDefaultValue: [
|
||||
'temp_set',
|
||||
'temp_current',
|
||||
],
|
||||
defaultValue: 0);
|
||||
},
|
||||
),
|
||||
}),
|
||||
),
|
||||
// Value selector
|
||||
if (selectedFunction != null)
|
||||
@ -150,7 +149,6 @@ class ACHelper {
|
||||
required BuildContext context,
|
||||
required List<ACFunction> acFunctions,
|
||||
required Function(String, String) onFunctionSelected,
|
||||
required AllDevicesModel? device,
|
||||
}) {
|
||||
return ListView.separated(
|
||||
shrinkWrap: false,
|
||||
@ -193,7 +191,6 @@ class ACHelper {
|
||||
);
|
||||
}
|
||||
|
||||
/// Build value selector for AC functions dialog
|
||||
static Widget _buildValueSelector({
|
||||
required BuildContext context,
|
||||
required String selectedFunction,
|
||||
@ -207,19 +204,19 @@ class ACHelper {
|
||||
acFunctions.firstWhere((f) => f.code == selectedFunction);
|
||||
|
||||
if (selectedFunction == 'temp_set' || selectedFunction == 'temp_current') {
|
||||
// Convert stored integer value to display value
|
||||
final displayValue =
|
||||
(selectedFunctionData?.value ?? selectedFn.min ?? 0) / 10;
|
||||
(selectedFunctionData?.value ?? selectedFn.min!) / 10;
|
||||
final minValue = selectedFn.min! / 10;
|
||||
final maxValue = selectedFn.max! / 10;
|
||||
|
||||
return CustomRoutinesTextbox(
|
||||
withSpecialChar: true,
|
||||
dividendOfRange: maxValue,
|
||||
currentCondition: selectedFunctionData?.condition,
|
||||
dialogType: selectedFn.type,
|
||||
sliderRange: (minValue, maxValue),
|
||||
displayedValue: displayValue.toStringAsFixed(1),
|
||||
initialValue: displayValue.toDouble(),
|
||||
displayedValue: displayValue.toString(),
|
||||
initialValue: displayValue,
|
||||
unit: selectedFn.unit!,
|
||||
onConditionChanged: (condition) => context.read<FunctionBloc>().add(
|
||||
AddFunction(
|
||||
@ -228,7 +225,7 @@ class ACHelper {
|
||||
functionCode: selectedFunction,
|
||||
operationName: selectedFn.operationName,
|
||||
condition: condition,
|
||||
value: 0,
|
||||
value: (displayValue * 10).round(),
|
||||
step: selectedFn.step,
|
||||
unit: selectedFn.unit,
|
||||
max: selectedFn.max,
|
||||
@ -236,13 +233,15 @@ class ACHelper {
|
||||
),
|
||||
),
|
||||
),
|
||||
onTextChanged: (value) => context.read<FunctionBloc>().add(
|
||||
onTextChanged: (value) {
|
||||
final numericValue = double.tryParse(value.toString()) ?? minValue;
|
||||
context.read<FunctionBloc>().add(
|
||||
AddFunction(
|
||||
functionData: DeviceFunctionData(
|
||||
entityId: device?.uuid ?? '',
|
||||
functionCode: selectedFunction,
|
||||
operationName: selectedFn.operationName,
|
||||
value: (value * 10).round(), // Store as integer
|
||||
value: (numericValue * 10).round(),
|
||||
condition: selectedFunctionData?.condition,
|
||||
step: selectedFn.step,
|
||||
unit: selectedFn.unit,
|
||||
@ -250,14 +249,17 @@ class ACHelper {
|
||||
min: selectedFn.min,
|
||||
),
|
||||
),
|
||||
),
|
||||
stepIncreaseAmount: selectedFn.step! / 10, // Convert step for display
|
||||
);
|
||||
},
|
||||
stepIncreaseAmount: selectedFn.step! / 10,
|
||||
);
|
||||
}
|
||||
|
||||
// Rest of your existing code for other value selectors
|
||||
final values = selectedFn.getOperationalValues();
|
||||
return _buildOperationalValuesList(
|
||||
context: context,
|
||||
values: selectedFn.getOperationalValues(),
|
||||
values: values,
|
||||
selectedValue: selectedFunctionData?.value,
|
||||
device: device,
|
||||
operationName: operationName,
|
||||
@ -311,7 +313,7 @@ class ACHelper {
|
||||
// );
|
||||
// }
|
||||
|
||||
// /// Build condition toggle for AC functions dialog
|
||||
/// Build condition toggle for AC functions dialog
|
||||
// static Widget _buildConditionToggle(
|
||||
// BuildContext context,
|
||||
// String? currentCondition,
|
||||
|
@ -6,7 +6,6 @@ import 'package:syncrow_web/pages/routines/models/ceiling_presence_sensor_functi
|
||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/custom_routines_textbox.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/ceiling_sensor/cps_slider_helpers.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/slider_value_selector.dart';
|
||||
|
||||
class CpsDialogSliderSelector extends StatelessWidget {
|
||||
const CpsDialogSliderSelector({
|
||||
@ -33,7 +32,7 @@ class CpsDialogSliderSelector extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CustomRoutinesTextbox(
|
||||
withSpecialChar: false,
|
||||
withSpecialChar: true,
|
||||
currentCondition: selectedFunctionData.condition,
|
||||
dialogType: dialogType,
|
||||
sliderRange:
|
||||
|
@ -0,0 +1,86 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/functions_bloc/functions_bloc_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/pc/enrgy_clamp_operational_value.dart';
|
||||
|
||||
class EnergyOperationalValuesList extends StatelessWidget {
|
||||
final List<EnergyClampOperationalValue> values;
|
||||
final dynamic selectedValue;
|
||||
final AllDevicesModel? device;
|
||||
final String operationName;
|
||||
final String selectCode;
|
||||
|
||||
const EnergyOperationalValuesList({
|
||||
required this.values,
|
||||
required this.selectedValue,
|
||||
required this.device,
|
||||
required this.operationName,
|
||||
required this.selectCode,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.all(20),
|
||||
itemCount: values.length,
|
||||
itemBuilder: (context, index) => _buildValueItem(context, values[index]),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildValueItem(
|
||||
BuildContext context, EnergyClampOperationalValue value) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
_buildValueIcon(context, value),
|
||||
Expanded(child: _buildValueDescription(value)),
|
||||
_buildValueRadio(context, value),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildValueIcon(context, EnergyClampOperationalValue value) {
|
||||
return Column(
|
||||
children: [
|
||||
SvgPicture.asset(value.icon, width: 25, height: 25),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildValueDescription(EnergyClampOperationalValue value) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: Text(value.description),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildValueRadio(context, EnergyClampOperationalValue value) {
|
||||
return Radio<dynamic>(
|
||||
value: value.value,
|
||||
groupValue: selectedValue,
|
||||
onChanged: (_) => _selectValue(context, value.value),
|
||||
);
|
||||
}
|
||||
|
||||
void _selectValue(BuildContext context, dynamic value) {
|
||||
context.read<FunctionBloc>().add(
|
||||
AddFunction(
|
||||
functionData: DeviceFunctionData(
|
||||
entityId: device?.uuid ?? '',
|
||||
functionCode: selectCode,
|
||||
operationName: operationName,
|
||||
value: value,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,246 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
||||
import 'package:syncrow_web/pages/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/device_functions.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/pc/energy_clamp_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/pages/routines/widgets/routine_dialogs/power_clamp_enargy/energy_value_selector_widget.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||
|
||||
class EnergyClampDialog extends StatefulWidget {
|
||||
final List<DeviceFunction> functions;
|
||||
final AllDevicesModel? device;
|
||||
final List<DeviceFunctionData>? deviceSelectedFunctions;
|
||||
final String? uniqueCustomId;
|
||||
final String? dialogType;
|
||||
final bool removeComparetors;
|
||||
|
||||
const EnergyClampDialog({
|
||||
super.key,
|
||||
required this.functions,
|
||||
this.device,
|
||||
this.deviceSelectedFunctions,
|
||||
this.uniqueCustomId,
|
||||
this.dialogType,
|
||||
this.removeComparetors = false,
|
||||
});
|
||||
|
||||
static Future<Map<String, dynamic>?> showEnergyClampFunctionsDialog({
|
||||
required BuildContext context,
|
||||
required List<DeviceFunction> functions,
|
||||
AllDevicesModel? device,
|
||||
List<DeviceFunctionData>? deviceSelectedFunctions,
|
||||
String? uniqueCustomId,
|
||||
String? dialogType,
|
||||
bool removeComparetors = false,
|
||||
}) async {
|
||||
return showDialog<Map<String, dynamic>?>(
|
||||
context: context,
|
||||
builder: (context) => EnergyClampDialog(
|
||||
functions: functions,
|
||||
device: device,
|
||||
deviceSelectedFunctions: deviceSelectedFunctions,
|
||||
uniqueCustomId: uniqueCustomId,
|
||||
removeComparetors: removeComparetors,
|
||||
dialogType: dialogType,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
State<EnergyClampDialog> createState() => _EnergyClampDialogState();
|
||||
}
|
||||
|
||||
class _EnergyClampDialogState extends State<EnergyClampDialog> {
|
||||
late final List<EnergyClampFunctions> _functions;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_functions =
|
||||
widget.functions.whereType<EnergyClampFunctions>().where((function) {
|
||||
if (widget.dialogType == 'THEN') {
|
||||
return function.type == 'THEN' || function.type == 'BOTH';
|
||||
}
|
||||
return function.type == 'IF' || function.type == 'BOTH';
|
||||
}).toList();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (_) => FunctionBloc()
|
||||
..add(InitializeFunctions(widget.deviceSelectedFunctions ?? [])),
|
||||
child: _buildDialogContent(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDialogContent() {
|
||||
return AlertDialog(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
content: BlocBuilder<FunctionBloc, FunctionBlocState>(
|
||||
builder: (context, state) {
|
||||
final selectedFunction = state.selectedFunction;
|
||||
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('Energy Clamp Conditions'),
|
||||
Expanded(child: _buildMainContent(context, state)),
|
||||
_buildDialogFooter(context, state),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMainContent(BuildContext context, FunctionBlocState state) {
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
_buildFunctionList(context, state),
|
||||
if (state.selectedFunction != null) _buildValueSelector(context, state),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildFunctionList(BuildContext context, FunctionBlocState state) {
|
||||
final selectedFunction = state.selectedFunction;
|
||||
final selectedFunctionData = state.addedFunctions.firstWhere(
|
||||
(f) => f.functionCode == selectedFunction,
|
||||
orElse: () => DeviceFunctionData(
|
||||
entityId: '',
|
||||
functionCode: selectedFunction ?? '',
|
||||
operationName: '',
|
||||
value: null,
|
||||
),
|
||||
);
|
||||
return SizedBox(
|
||||
width: 360,
|
||||
child: ListView.separated(
|
||||
shrinkWrap: false,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
itemCount: _functions.length,
|
||||
separatorBuilder: (context, index) => const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 40.0),
|
||||
child: Divider(color: ColorsManager.dividerColor),
|
||||
),
|
||||
itemBuilder: (context, index) {
|
||||
final function = _functions[index];
|
||||
return ListTile(
|
||||
leading: SvgPicture.asset(
|
||||
function.icon,
|
||||
width: 24,
|
||||
height: 24,
|
||||
placeholderBuilder: (context) => const SizedBox(
|
||||
width: 24,
|
||||
height: 24,
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
function.operationName,
|
||||
style: context.textTheme.bodyMedium,
|
||||
),
|
||||
trailing: const Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
size: 16,
|
||||
color: ColorsManager.textGray,
|
||||
),
|
||||
onTap: () => RoutineTapFunctionHelper.onTapFunction(
|
||||
context,
|
||||
functionCode: function.code,
|
||||
functionOperationName: function.operationName,
|
||||
functionValueDescription: selectedFunctionData.valueDescription,
|
||||
deviceUuid: widget.device?.uuid,
|
||||
codesToAddIntoFunctionsWithDefaultValue: [
|
||||
'VoltageA',
|
||||
'CurrentA',
|
||||
'ActivePowerA',
|
||||
'PowerFactorA',
|
||||
'ReactivePowerA',
|
||||
'EnergyConsumedA',
|
||||
'VoltageB',
|
||||
'CurrentB',
|
||||
'ActivePowerB',
|
||||
'PowerFactorB',
|
||||
'ReactivePowerB',
|
||||
'EnergyConsumedB',
|
||||
'VoltageC',
|
||||
'CurrentC',
|
||||
'ActivePowerC',
|
||||
'PowerFactorC',
|
||||
'ReactivePowerC',
|
||||
'EnergyConsumedC',
|
||||
'EnergyConsumed',
|
||||
'Current',
|
||||
'ActivePower',
|
||||
'ReactivePower',
|
||||
'Frequency',
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildValueSelector(BuildContext context, FunctionBlocState state) {
|
||||
final selectedFunction = state.selectedFunction!;
|
||||
final functionData = state.addedFunctions.firstWhere(
|
||||
(f) => f.functionCode == selectedFunction,
|
||||
orElse: () => DeviceFunctionData(
|
||||
entityId: '',
|
||||
functionCode: selectedFunction,
|
||||
operationName: state.selectedOperationName ?? '',
|
||||
value: null,
|
||||
),
|
||||
);
|
||||
|
||||
return Expanded(
|
||||
child: EnergyValueSelectorWidget(
|
||||
selectedFunction: selectedFunction,
|
||||
functionData: functionData,
|
||||
functions: _functions,
|
||||
device: widget.device,
|
||||
dialogType: widget.dialogType!,
|
||||
removeComparators: widget.removeComparetors,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDialogFooter(BuildContext context, FunctionBlocState state) {
|
||||
return DialogFooter(
|
||||
onCancel: () => Navigator.pop(context),
|
||||
onConfirm: state.addedFunctions.isNotEmpty
|
||||
? () {
|
||||
context.read<RoutineBloc>().add(
|
||||
AddFunctionToRoutine(
|
||||
state.addedFunctions,
|
||||
widget.uniqueCustomId!,
|
||||
),
|
||||
);
|
||||
Navigator.pop(
|
||||
context,
|
||||
{'deviceId': widget.functions.first.deviceId},
|
||||
);
|
||||
}
|
||||
: null,
|
||||
isConfirmEnabled: state.selectedFunction != null,
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
import 'package:flutter/material.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/routines/bloc/functions_bloc/functions_bloc_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/pc/energy_clamp_functions.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/custom_routines_textbox.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/power_clamp_enargy/enargy_operational_values_list.dart';
|
||||
|
||||
class EnergyValueSelectorWidget extends StatelessWidget {
|
||||
final String selectedFunction;
|
||||
final DeviceFunctionData functionData;
|
||||
final List<EnergyClampFunctions> functions;
|
||||
final AllDevicesModel? device;
|
||||
final String dialogType;
|
||||
final bool removeComparators;
|
||||
|
||||
const EnergyValueSelectorWidget({
|
||||
required this.selectedFunction,
|
||||
required this.functionData,
|
||||
required this.functions,
|
||||
required this.device,
|
||||
required this.dialogType,
|
||||
required this.removeComparators,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final selectedFn =
|
||||
functions.firstWhere((f) => f.code == selectedFunction);
|
||||
final values = selectedFn.getOperationalValues();
|
||||
final step = selectedFn.step ?? 1.0;
|
||||
final _unit = selectedFn.unit ?? '';
|
||||
final (double, double) sliderRange =
|
||||
(selectedFn.min ?? 0.0, selectedFn.max ?? 100.0);
|
||||
|
||||
if (_isSliderFunction(selectedFunction)) {
|
||||
return CustomRoutinesTextbox(
|
||||
withSpecialChar: false,
|
||||
currentCondition: functionData.condition,
|
||||
dialogType: dialogType,
|
||||
sliderRange: sliderRange,
|
||||
displayedValue: functionData.value,
|
||||
initialValue: functionData.value ?? 0.0,
|
||||
onConditionChanged: (condition) => context.read<FunctionBloc>().add(
|
||||
AddFunction(
|
||||
functionData: DeviceFunctionData(
|
||||
entityId: device?.uuid ?? '',
|
||||
functionCode: selectedFunction,
|
||||
operationName: functionData.operationName,
|
||||
condition: condition,
|
||||
value: functionData.value ?? 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
onTextChanged: (value) => context.read<FunctionBloc>().add(
|
||||
AddFunction(
|
||||
functionData: DeviceFunctionData(
|
||||
entityId: device?.uuid ?? '',
|
||||
functionCode: selectedFunction,
|
||||
operationName: functionData.operationName,
|
||||
value: value.toInt(),
|
||||
condition: functionData.condition,
|
||||
),
|
||||
),
|
||||
),
|
||||
unit: _unit,
|
||||
dividendOfRange: 1,
|
||||
stepIncreaseAmount: step,
|
||||
);
|
||||
}
|
||||
|
||||
return EnergyOperationalValuesList(
|
||||
values: values,
|
||||
selectedValue: functionData.value,
|
||||
device: device,
|
||||
operationName: selectedFn.operationName,
|
||||
selectCode: selectedFunction,
|
||||
);
|
||||
}
|
||||
|
||||
bool _isSliderFunction(String function) =>
|
||||
!['voltage_phase_seq'].contains(function);
|
||||
}
|
@ -33,7 +33,7 @@ class WpsValueSelectorWidget extends StatelessWidget {
|
||||
|
||||
if (_isSliderFunction(selectedFunction)) {
|
||||
return CustomRoutinesTextbox(
|
||||
withSpecialChar: false,
|
||||
withSpecialChar: true,
|
||||
currentCondition: functionData.condition,
|
||||
dialogType: dialogType,
|
||||
sliderRange: sliderRange,
|
||||
|
@ -242,7 +242,8 @@ class ThenContainer extends StatelessWidget {
|
||||
'GW',
|
||||
'CPS',
|
||||
"NCPS",
|
||||
"WH"
|
||||
"WH",
|
||||
'PC',
|
||||
].contains(mutableData['productType'])) {
|
||||
context.read<RoutineBloc>().add(AddToThenContainer(mutableData));
|
||||
}
|
||||
|
@ -32,13 +32,13 @@ class VisitorPasswordDialog extends StatelessWidget {
|
||||
.stateDialog(
|
||||
context: context,
|
||||
message: 'Password Created Successfully',
|
||||
title: 'Send Success',
|
||||
title: 'Sent Successfully',
|
||||
widgeta: Column(
|
||||
children: [
|
||||
if (visitorBloc.passwordStatus!.failedOperations.isNotEmpty)
|
||||
Column(
|
||||
children: [
|
||||
const Text('Failed Devises'),
|
||||
const Text('Failed Devices'),
|
||||
SizedBox(
|
||||
width: 200,
|
||||
height: 50,
|
||||
@ -63,7 +63,7 @@ class VisitorPasswordDialog extends StatelessWidget {
|
||||
if (visitorBloc.passwordStatus!.successOperations.isNotEmpty)
|
||||
Column(
|
||||
children: [
|
||||
const Text('Success Devises'),
|
||||
const Text('Success Devices'),
|
||||
SizedBox(
|
||||
width: 200,
|
||||
height: 50,
|
||||
@ -95,7 +95,7 @@ class VisitorPasswordDialog extends StatelessWidget {
|
||||
visitorBloc.stateDialog(
|
||||
context: context,
|
||||
message: state.message,
|
||||
title: 'Something Wrong',
|
||||
title: 'Something went wrong',
|
||||
);
|
||||
}
|
||||
},
|
||||
|
@ -73,4 +73,14 @@ abstract class ColorsManager {
|
||||
static const Color vividBlue = Color(0xFF023DFE);
|
||||
static const Color semiTransparentRed = Color(0x99FF0000);
|
||||
static const Color grey700 = Color(0xFF2D3748);
|
||||
static const Color goodGreen = Color(0xFF0CEC16);
|
||||
static const Color moderateYellow = Color(0xFFFAC96C);
|
||||
static const Color poorOrange = Color(0xFFEC7400);
|
||||
static const Color unhealthyRed = Color(0xFFD40000);
|
||||
static const Color severePink = Color(0xFFD40094);
|
||||
static const Color hazardousPurple = Color(0xFFBA01FD);
|
||||
static const Color maxPurple = Color(0xFF962DFF);
|
||||
static const Color maxPurpleDot = Color(0xFF5F00BD);
|
||||
static const Color minBlue = Color(0xFF93AAFD);
|
||||
static const Color minBlueDot = Color(0xFF023DFE);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ class Assets {
|
||||
Assets._();
|
||||
static const String background = "assets/images/Background.png";
|
||||
static const String webBackground = "assets/images/web_Background.svg";
|
||||
static const String webBackgroundPng = "assets/images/web_Background.png";
|
||||
static const String blackLogo = "assets/images/black-logo.png";
|
||||
static const String logo = "assets/images/Logo.svg";
|
||||
static const String logoHorizontal = "assets/images/logo_horizontal.png";
|
||||
@ -13,13 +14,14 @@ class Assets {
|
||||
static const String rightLine = "assets/images/right_line.png";
|
||||
static const String google = "assets/images/google.svg";
|
||||
static const String facebook = "assets/images/facebook.svg";
|
||||
static const String invisiblePassword =
|
||||
"assets/images/Password_invisible.svg";
|
||||
static const String invisiblePassword = "assets/images/Password_invisible.svg";
|
||||
static const String visiblePassword = "assets/images/password_visible.svg";
|
||||
static const String accessIcon = "assets/images/access_icon.svg";
|
||||
static const String spaseManagementIcon =
|
||||
"assets/images/spase_management_icon.svg";
|
||||
static const String devicesIcon = "assets/images/devices_icon.svg";
|
||||
static const String analyticsIcon = "assets/icons/landing_analytics.svg";
|
||||
|
||||
static const String moveinIcon = "assets/images/movein_icon.svg";
|
||||
static const String constructionIcon = "assets/images/construction_icon.svg";
|
||||
static const String energyIcon = "assets/images/energy_icon.svg";
|
||||
@ -31,8 +33,7 @@ class Assets {
|
||||
static const String emptyTable = "assets/images/empty_table.svg";
|
||||
|
||||
// General assets
|
||||
static const String motionlessDetection =
|
||||
"assets/icons/motionless_detection.svg";
|
||||
static const String motionlessDetection = "assets/icons/motionless_detection.svg";
|
||||
static const String acHeating = "assets/icons/ac_heating.svg";
|
||||
static const String acPowerOff = "assets/icons/ac_power_off.svg";
|
||||
static const String acFanMiddle = "assets/icons/ac_fan_middle.svg";
|
||||
@ -69,22 +70,19 @@ class Assets {
|
||||
"assets/icons/automation_functions/temp_password_unlock.svg";
|
||||
static const String doorlockNormalOpen =
|
||||
"assets/icons/automation_functions/doorlock_normal_open.svg";
|
||||
static const String doorbell =
|
||||
"assets/icons/automation_functions/doorbell.svg";
|
||||
static const String doorbell = "assets/icons/automation_functions/doorbell.svg";
|
||||
static const String remoteUnlockViaApp =
|
||||
"assets/icons/automation_functions/remote_unlock_via_app.svg";
|
||||
static const String doubleLock =
|
||||
"assets/icons/automation_functions/double_lock.svg";
|
||||
static const String selfTestResult =
|
||||
"assets/icons/automation_functions/self_test_result.svg";
|
||||
static const String lockAlarm =
|
||||
"assets/icons/automation_functions/lock_alarm.svg";
|
||||
static const String lockAlarm = "assets/icons/automation_functions/lock_alarm.svg";
|
||||
static const String presenceState =
|
||||
"assets/icons/automation_functions/presence_state.svg";
|
||||
static const String currentTemp =
|
||||
"assets/icons/automation_functions/current_temp.svg";
|
||||
static const String presence =
|
||||
"assets/icons/automation_functions/presence.svg";
|
||||
static const String presence = "assets/icons/automation_functions/presence.svg";
|
||||
static const String residualElectricity =
|
||||
"assets/icons/automation_functions/residual_electricity.svg";
|
||||
static const String hijackAlarm =
|
||||
@ -101,15 +99,12 @@ class Assets {
|
||||
|
||||
// Presence Sensor Assets
|
||||
static const String sensorMotionIcon = "assets/icons/sensor_motion_ic.svg";
|
||||
static const String sensorPresenceIcon =
|
||||
"assets/icons/sensor_presence_ic.svg";
|
||||
static const String sensorPresenceIcon = "assets/icons/sensor_presence_ic.svg";
|
||||
static const String sensorVacantIcon = "assets/icons/sensor_vacant_ic.svg";
|
||||
static const String illuminanceRecordIcon =
|
||||
"assets/icons/illuminance_record_ic.svg";
|
||||
static const String presenceRecordIcon =
|
||||
"assets/icons/presence_record_ic.svg";
|
||||
static const String helpDescriptionIcon =
|
||||
"assets/icons/help_description_ic.svg";
|
||||
static const String presenceRecordIcon = "assets/icons/presence_record_ic.svg";
|
||||
static const String helpDescriptionIcon = "assets/icons/help_description_ic.svg";
|
||||
|
||||
static const String lightPulp = "assets/icons/light_pulb.svg";
|
||||
static const String acDevice = "assets/icons/ac_device.svg";
|
||||
@ -159,12 +154,10 @@ class Assets {
|
||||
static const String unit = 'assets/icons/unit_icon.svg';
|
||||
static const String villa = 'assets/icons/villa_icon.svg';
|
||||
static const String iconEdit = 'assets/icons/icon_edit_icon.svg';
|
||||
static const String textFieldSearch =
|
||||
'assets/icons/textfield_search_icon.svg';
|
||||
static const String textFieldSearch = 'assets/icons/textfield_search_icon.svg';
|
||||
static const String roundedAddIcon = 'assets/icons/rounded_add_icon.svg';
|
||||
static const String addIcon = 'assets/icons/add_icon.svg';
|
||||
static const String smartThermostatIcon =
|
||||
'assets/icons/smart_thermostat_icon.svg';
|
||||
static const String smartThermostatIcon = 'assets/icons/smart_thermostat_icon.svg';
|
||||
static const String smartLightIcon = 'assets/icons/smart_light_icon.svg';
|
||||
static const String presenceSensor = 'assets/icons/presence_sensor.svg';
|
||||
static const String Gang3SwitchIcon = 'assets/icons/3_Gang_switch_icon.svg';
|
||||
@ -212,8 +205,7 @@ class Assets {
|
||||
//assets/icons/water_leak_normal.svg
|
||||
static const String waterLeakNormal = 'assets/icons/water_leak_normal.svg';
|
||||
//assets/icons/water_leak_detected.svg
|
||||
static const String waterLeakDetected =
|
||||
'assets/icons/water_leak_detected.svg';
|
||||
static const String waterLeakDetected = 'assets/icons/water_leak_detected.svg';
|
||||
|
||||
//assets/icons/automation_records.svg
|
||||
static const String automationRecords = 'assets/icons/automation_records.svg';
|
||||
@ -284,16 +276,13 @@ class Assets {
|
||||
"assets/icons/functions_icons/sensitivity.svg";
|
||||
static const String assetsSensitivityOperationIcon =
|
||||
"assets/icons/functions_icons/sesitivity_operation_icon.svg";
|
||||
static const String assetsAcPower =
|
||||
"assets/icons/functions_icons/ac_power.svg";
|
||||
static const String assetsAcPower = "assets/icons/functions_icons/ac_power.svg";
|
||||
static const String assetsAcPowerOFF =
|
||||
"assets/icons/functions_icons/ac_power_off.svg";
|
||||
static const String assetsChildLock =
|
||||
"assets/icons/functions_icons/child_lock.svg";
|
||||
static const String assetsFreezing =
|
||||
"assets/icons/functions_icons/freezing.svg";
|
||||
static const String assetsFanSpeed =
|
||||
"assets/icons/functions_icons/fan_speed.svg";
|
||||
static const String assetsFreezing = "assets/icons/functions_icons/freezing.svg";
|
||||
static const String assetsFanSpeed = "assets/icons/functions_icons/fan_speed.svg";
|
||||
static const String assetsAcCooling =
|
||||
"assets/icons/functions_icons/ac_cooling.svg";
|
||||
static const String assetsAcHeating =
|
||||
@ -302,8 +291,7 @@ class Assets {
|
||||
"assets/icons/functions_icons/celsius_degrees.svg";
|
||||
static const String assetsTempreture =
|
||||
"assets/icons/functions_icons/tempreture.svg";
|
||||
static const String assetsAcFanLow =
|
||||
"assets/icons/functions_icons/ac_fan_low.svg";
|
||||
static const String assetsAcFanLow = "assets/icons/functions_icons/ac_fan_low.svg";
|
||||
static const String assetsAcFanMiddle =
|
||||
"assets/icons/functions_icons/ac_fan_middle.svg";
|
||||
static const String assetsAcFanHigh =
|
||||
@ -322,8 +310,7 @@ class Assets {
|
||||
"assets/icons/functions_icons/far_detection.svg";
|
||||
static const String assetsFarDetectionFunction =
|
||||
"assets/icons/functions_icons/far_detection_function.svg";
|
||||
static const String assetsIndicator =
|
||||
"assets/icons/functions_icons/indicator.svg";
|
||||
static const String assetsIndicator = "assets/icons/functions_icons/indicator.svg";
|
||||
static const String assetsMotionDetection =
|
||||
"assets/icons/functions_icons/motion_detection.svg";
|
||||
static const String assetsMotionlessDetection =
|
||||
@ -336,8 +323,7 @@ class Assets {
|
||||
"assets/icons/functions_icons/master_state.svg";
|
||||
static const String assetsSwitchAlarmSound =
|
||||
"assets/icons/functions_icons/switch_alarm_sound.svg";
|
||||
static const String assetsResetOff =
|
||||
"assets/icons/functions_icons/reset_off.svg";
|
||||
static const String assetsResetOff = "assets/icons/functions_icons/reset_off.svg";
|
||||
|
||||
// Assets for automation_functions
|
||||
static const String assetsCardUnlock =
|
||||
@ -381,14 +367,12 @@ class Assets {
|
||||
static const String activeUser = 'assets/icons/active_user.svg';
|
||||
static const String deActiveUser = 'assets/icons/deactive_user.svg';
|
||||
static const String invitedIcon = 'assets/icons/invited_icon.svg';
|
||||
static const String rectangleCheckBox =
|
||||
'assets/icons/rectangle_check_box.png';
|
||||
static const String rectangleCheckBox = 'assets/icons/rectangle_check_box.png';
|
||||
static const String CheckBoxChecked = 'assets/icons/box_checked.png';
|
||||
static const String emptyBox = 'assets/icons/empty_box.png';
|
||||
static const String completeProcessIcon =
|
||||
'assets/icons/compleate_process_icon.svg';
|
||||
static const String currentProcessIcon =
|
||||
'assets/icons/current_process_icon.svg';
|
||||
static const String currentProcessIcon = 'assets/icons/current_process_icon.svg';
|
||||
static const String uncomplete_ProcessIcon =
|
||||
'assets/icons/uncompleate_process_icon.svg';
|
||||
static const String wrongProcessIcon = 'assets/icons/wrong_process_icon.svg';
|
||||
@ -409,11 +393,9 @@ class Assets {
|
||||
static const String successIcon = 'assets/icons/success_icon.svg';
|
||||
static const String spaceLocationIcon = 'assets/icons/spaseLocationIcon.svg';
|
||||
static const String scenesPlayIcon = 'assets/icons/scenesPlayIcon.png';
|
||||
static const String scenesPlayIconCheck =
|
||||
'assets/icons/scenesPlayIconCheck.png';
|
||||
static const String scenesPlayIconCheck = 'assets/icons/scenesPlayIconCheck.png';
|
||||
static const String presenceStateIcon = 'assets/icons/presence_state.svg';
|
||||
static const String currentDistanceIcon =
|
||||
'assets/icons/current_distance_icon.svg';
|
||||
static const String currentDistanceIcon = 'assets/icons/current_distance_icon.svg';
|
||||
|
||||
static const String farDetectionIcon = 'assets/icons/far_detection_icon.svg';
|
||||
static const String motionDetectionSensitivityIcon =
|
||||
@ -436,44 +418,29 @@ class Assets {
|
||||
static const String cpsMode4 = 'assets/icons/cps_mode4.svg';
|
||||
static const String closeToMotion = 'assets/icons/close_to_motion.svg';
|
||||
static const String farAwayMotion = 'assets/icons/far_away_motion.svg';
|
||||
static const String communicationFault =
|
||||
'assets/icons/communication_fault.svg';
|
||||
static const String communicationFault = 'assets/icons/communication_fault.svg';
|
||||
static const String radarFault = 'assets/icons/radar_fault.svg';
|
||||
static const String selfTestingSuccess =
|
||||
'assets/icons/self_testing_success.svg';
|
||||
static const String selfTestingFailure =
|
||||
'assets/icons/self_testing_failure.svg';
|
||||
static const String selfTestingTimeout =
|
||||
'assets/icons/self_testing_timeout.svg';
|
||||
static const String selfTestingSuccess = 'assets/icons/self_testing_success.svg';
|
||||
static const String selfTestingFailure = 'assets/icons/self_testing_failure.svg';
|
||||
static const String selfTestingTimeout = 'assets/icons/self_testing_timeout.svg';
|
||||
static const String movingSpeed = 'assets/icons/moving_speed.svg';
|
||||
static const String boundary = 'assets/icons/boundary.svg';
|
||||
static const String motionMeter = 'assets/icons/motion_meter.svg';
|
||||
static const String spatialStaticValue =
|
||||
'assets/icons/spatial_static_value.svg';
|
||||
static const String spatialMotionValue =
|
||||
'assets/icons/spatial_motion_value.svg';
|
||||
static const String spatialStaticValue = 'assets/icons/spatial_static_value.svg';
|
||||
static const String spatialMotionValue = 'assets/icons/spatial_motion_value.svg';
|
||||
static const String presenceJudgementThrshold =
|
||||
'assets/icons/presence_judgement_threshold.svg';
|
||||
static const String spaceType = 'assets/icons/space_type.svg';
|
||||
static const String sportsPara = 'assets/icons/sports_para.svg';
|
||||
static const String sensitivityFeature1 =
|
||||
'assets/icons/sensitivity_feature_1.svg';
|
||||
static const String sensitivityFeature2 =
|
||||
'assets/icons/sensitivity_feature_2.svg';
|
||||
static const String sensitivityFeature3 =
|
||||
'assets/icons/sensitivity_feature_3.svg';
|
||||
static const String sensitivityFeature4 =
|
||||
'assets/icons/sensitivity_feature_4.svg';
|
||||
static const String sensitivityFeature5 =
|
||||
'assets/icons/sensitivity_feature_5.svg';
|
||||
static const String sensitivityFeature6 =
|
||||
'assets/icons/sensitivity_feature_6.svg';
|
||||
static const String sensitivityFeature7 =
|
||||
'assets/icons/sensitivity_feature_7.svg';
|
||||
static const String sensitivityFeature8 =
|
||||
'assets/icons/sensitivity_feature_8.svg';
|
||||
static const String sensitivityFeature9 =
|
||||
'assets/icons/sensitivity_feature_9.svg';
|
||||
static const String sensitivityFeature1 = 'assets/icons/sensitivity_feature_1.svg';
|
||||
static const String sensitivityFeature2 = 'assets/icons/sensitivity_feature_2.svg';
|
||||
static const String sensitivityFeature3 = 'assets/icons/sensitivity_feature_3.svg';
|
||||
static const String sensitivityFeature4 = 'assets/icons/sensitivity_feature_4.svg';
|
||||
static const String sensitivityFeature5 = 'assets/icons/sensitivity_feature_5.svg';
|
||||
static const String sensitivityFeature6 = 'assets/icons/sensitivity_feature_6.svg';
|
||||
static const String sensitivityFeature7 = 'assets/icons/sensitivity_feature_7.svg';
|
||||
static const String sensitivityFeature8 = 'assets/icons/sensitivity_feature_8.svg';
|
||||
static const String sensitivityFeature9 = 'assets/icons/sensitivity_feature_9.svg';
|
||||
static const String deviceTagIcon = 'assets/icons/device_tag_ic.svg';
|
||||
static const String targetConfirmTimeIcon =
|
||||
'assets/icons/target_confirm_time_icon.svg';
|
||||
@ -481,5 +448,8 @@ class Assets {
|
||||
static const String indentLevelIcon = 'assets/icons/indent_level_icon.svg';
|
||||
static const String triggerLevelIcon = 'assets/icons/trigger_level_icon.svg';
|
||||
static const String blankCalendar = 'assets/icons/blank_calendar.svg';
|
||||
static const String refreshStatusIcon = 'assets/icons/refresh_status_icon.svg';
|
||||
static const String refreshStatusIcon =
|
||||
'assets/icons/refresh_status_icon.svg';
|
||||
static const String energyConsumedIcon =
|
||||
'assets/icons/energy_consumed_icon.svg';
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ enum DeviceType {
|
||||
WaterLeak,
|
||||
NCPS,
|
||||
DoorSensor,
|
||||
PC,
|
||||
Other,
|
||||
}
|
||||
/*
|
||||
@ -59,4 +60,5 @@ Map<String, DeviceType> devicesTypesMap = {
|
||||
'GD': DeviceType.GarageDoor,
|
||||
'WL': DeviceType.WaterLeak,
|
||||
'NCPS': DeviceType.NCPS,
|
||||
'PC': DeviceType.PC,
|
||||
};
|
||||
|
@ -41,7 +41,16 @@ class _UserDropdownMenuState extends State<UserDropdownMenu> {
|
||||
_isDropdownOpen = false;
|
||||
});
|
||||
},
|
||||
child: Transform.rotate(
|
||||
child: Row(
|
||||
children: [
|
||||
const SizedBox(width: 12),
|
||||
if (widget.user != null)
|
||||
Text(
|
||||
'${widget.user!.firstName} ${widget.user!.lastName}',
|
||||
style: Theme.of(context).textTheme.bodyLarge,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Transform.rotate(
|
||||
angle: _isDropdownOpen ? -1.5708 : 1.5708,
|
||||
child: const Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
@ -49,6 +58,8 @@ class _UserDropdownMenuState extends State<UserDropdownMenu> {
|
||||
size: 16,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
@ -92,13 +92,6 @@ class DesktopAppBar extends StatelessWidget {
|
||||
if (rightBody != null) rightBody!,
|
||||
const SizedBox(width: 24),
|
||||
_UserAvatar(),
|
||||
const SizedBox(width: 12),
|
||||
if (user != null)
|
||||
Text(
|
||||
'${user.firstName} ${user.lastName}',
|
||||
style: Theme.of(context).textTheme.bodyLarge,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
UserDropdownMenu(user: user),
|
||||
],
|
||||
);
|
||||
@ -146,14 +139,6 @@ class TabletAppBar extends StatelessWidget {
|
||||
if (rightBody != null) rightBody!,
|
||||
const SizedBox(width: 16),
|
||||
_UserAvatar(),
|
||||
if (user != null) ...[
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'${user.firstName} ${user.lastName}',
|
||||
style:
|
||||
Theme.of(context).textTheme.bodyLarge?.copyWith(fontSize: 14),
|
||||
),
|
||||
],
|
||||
UserDropdownMenu(user: user),
|
||||
],
|
||||
);
|
||||
@ -215,14 +200,6 @@ class MobileAppBar extends StatelessWidget {
|
||||
return Row(
|
||||
children: [
|
||||
_UserAvatar(),
|
||||
if (user != null) ...[
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'${user.firstName} ${user.lastName}',
|
||||
style:
|
||||
Theme.of(context).textTheme.bodyLarge?.copyWith(fontSize: 14),
|
||||
),
|
||||
],
|
||||
UserDropdownMenu(user: user),
|
||||
],
|
||||
);
|
||||
|
@ -1,8 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
||||
import 'package:syncrow_web/web_layout/web_app_bar.dart';
|
||||
|
||||
import 'menu_sidebar.dart';
|
||||
|
||||
class WebScaffold extends StatelessWidget with HelperResponsiveLayout {
|
||||
@ -28,14 +28,11 @@ class WebScaffold extends StatelessWidget with HelperResponsiveLayout {
|
||||
SizedBox(
|
||||
width: MediaQuery.sizeOf(context).width,
|
||||
height: MediaQuery.sizeOf(context).height,
|
||||
child: SvgPicture.asset(
|
||||
Assets.webBackground,
|
||||
child: Image.asset(
|
||||
Assets.webBackgroundPng,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
color: Colors.white.withOpacity(0.7),
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
|
Reference in New Issue
Block a user