Skip to content

Commit

Permalink
colors added to devices and services icons
Browse files Browse the repository at this point in the history
  • Loading branch information
bardram committed Jan 18, 2024
1 parent 6af9ea6 commit 2244333
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 32 deletions.
26 changes: 17 additions & 9 deletions lib/blocs/app_bloc.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
part of carp_study_app;

/// The state of the [StudyAppBLoC].
enum StudyAppState {
/// The BLOC is created (initial state)
/// The BLoC is created (initial state)
created,

/// The BLOC is initialized via the [initialized] method.
/// The BLoC is initialized via the [initialized] method.
initialized,

/// The BLOC is in the process of being configured.
/// The BLoC is in the process of being configured.
configuring,

/// The BLOC is configured and ready to use.
/// The BLoC is configured and ready to use.
configured,
}

Expand All @@ -19,11 +20,9 @@ class StudyAppBLoC {
final CarpBackend _backend = CarpBackend();
final CarpStudyAppViewModel _appViewModel = CarpStudyAppViewModel();
StudyDeploymentStatus? _status;
final StreamController<StudiesAppState> _stateStreamController =
final StreamController<StudyAppState> _stateStreamController =
StreamController.broadcast();

// Stream<StudiesAppState> get stateStream => _stateStreamController.stream;

List<ActiveParticipationInvitation> invitations = [];

List<Message> _messages = [];
Expand All @@ -35,7 +34,16 @@ class StudyAppBLoC {
/// The data send on the stream is the number of available messages.
Stream<int> get messageStream => _messageStreamController.stream;

/// The state of this BloC.
StudyAppState get state => _state;
set state(StudyAppState state) {
_state = state;
_stateStreamController.add(state);
}

/// A stream of state changes of this BloC.
Stream<StudyAppState> get stateStream => _stateStreamController.stream;

bool get isInitialized => _state.index >= 1;
bool get isConfiguring => _state.index >= 2;
bool get isConfigured => _state.index >= 3;
Expand Down Expand Up @@ -116,7 +124,7 @@ class StudyAppBLoC {

await backend.initialize();

_stateStreamController.add(StudiesAppState.initialized);
state = StudyAppState.initialized;
info('$runtimeType initialized.');
}

Expand Down Expand Up @@ -149,7 +157,7 @@ class StudyAppBLoC {
// early out if already configured
if (isConfiguring) return;

_stateStreamController.add(StudiesAppState.configuring);
state = StudyAppState.configuring;

// set up and initialize sensing
await Sensing().initialize();
Expand Down
21 changes: 12 additions & 9 deletions lib/blocs/common.dart
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
part of carp_study_app;

/// Enumeration of different types of deployments on the CARP Web Service (CAWS).
/// How to deploy a study.
enum DeploymentMode {
/// Use the CARP production server to get the study deployment and store data.
/// Use a local study protocol & deployment and store data locally on the phone.
local,

/// Use the CAWS production server to get the study deployment and store data.
production,

/// Use the CARP staging server to get the study deployment and store data.
/// Use the CAWS staging server to get the study deployment and store data.
staging,

/// Use the CARP testing server to get the study deployment and store data.
/// Use the CAWS test server to get the study deployment and store data.
test,

/// Use the CARP development server to get the study deployment and store data.
/// Use the CAWS development server to get the study deployment and store data.
dev,
}

Expand Down Expand Up @@ -49,10 +52,10 @@ enum StudiesAppState {
initialized,
authenticating,
accessTokenRetrieved,
configuring,
loading,
loaded,
error,
// configuring,
// loading,
// loaded,
// error,
}

extension StringExtension on String {
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions lib/data/carp_backend.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,19 @@ class CarpBackend {
}

Future<CarpUser> authenticate() async {
bloc._stateStreamController.add(StudiesAppState.authenticating);
// bloc._stateStreamController.add(StudiesAppState.authenticating);
user = await CarpService().authenticate();

bloc._stateStreamController.add(StudiesAppState.accessTokenRetrieved);
// bloc._stateStreamController.add(StudiesAppState.accessTokenRetrieved);

return user as CarpUser;
}

Future<CarpUser> refresh() async {
bloc._stateStreamController.add(StudiesAppState.authenticating);
// bloc._stateStreamController.add(StudiesAppState.authenticating);
user = await CarpService().refresh();

bloc._stateStreamController.add(StudiesAppState.accessTokenRetrieved);
// bloc._stateStreamController.add(StudiesAppState.accessTokenRetrieved);

return user as CarpUser;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ part 'blocs/common.dart';
part 'data/local_settings.dart';
part 'data/carp_backend.dart';
part 'data/localization_loader.dart';
part 'sensing/sensing.dart';
part 'blocs/sensing.dart';

part 'view_models/view_model.dart';
part 'view_models/tasklist_page_model.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/colors.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of carp_study_app;

class CACHET {
static const Color CACHET_BLUE = Color.fromRGBO(97, 195, 217, 1.0);
static const Color BLUE = Color.fromRGBO(97, 195, 217, 1.0);
static const Color RED = Color.fromRGBO(213, 11, 51, 1.0);
static const Color WHITE = Color.fromRGBO(255, 255, 255, 1.0);
static const Color BLACK = Color.fromRGBO(1, 1, 1, 1.0);
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/pages/task_list_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ class TaskListPageState extends State<TaskListPage> {
),
BackgroundSensingUserTask.SENSING_TYPE: const Icon(
Icons.settings_input_antenna,
color: CACHET.CACHET_BLUE,
color: CACHET.BLUE,
),
BackgroundSensingUserTask.ONE_TIME_SENSING_TYPE: const Icon(
Icons.settings_input_component,
Expand Down
39 changes: 32 additions & 7 deletions lib/view_models/devices_page_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,38 @@ class DeviceModel {
};

static Map<String, Icon> get deviceTypeIcon => {
Smartphone.DEVICE_TYPE: const Icon(Icons.phone_android, size: 30),
WeatherService.DEVICE_TYPE: const Icon(Icons.wb_cloudy),
AirQualityService.DEVICE_TYPE: const Icon(Icons.air),
LocationService.DEVICE_TYPE: const Icon(Icons.location_on),
ESenseDevice.DEVICE_TYPE: const Icon(Icons.headphones, size: 30),
PolarDevice.DEVICE_TYPE: const Icon(Icons.monitor_heart, size: 30),
HealthService.DEVICE_TYPE: const Icon(Icons.favorite_rounded, size: 30),
Smartphone.DEVICE_TYPE: const Icon(
Icons.phone_android,
size: 30,
color: CACHET.DARK_BLUE,
),
WeatherService.DEVICE_TYPE: const Icon(
Icons.wb_cloudy,
color: CACHET.WHITE,
),
AirQualityService.DEVICE_TYPE: const Icon(
Icons.air,
color: CACHET.GREY_1,
),
LocationService.DEVICE_TYPE: const Icon(
Icons.location_on,
color: CACHET.GREEN,
),
ESenseDevice.DEVICE_TYPE: const Icon(
Icons.headphones,
size: 30,
color: CACHET.BLACK,
),
PolarDevice.DEVICE_TYPE: const Icon(
Icons.monitor_heart,
size: 30,
color: CACHET.LIGHT_BLUE_2,
),
HealthService.DEVICE_TYPE: const Icon(
Icons.favorite_rounded,
size: 30,
color: CACHET.RED_1,
),
};

static Map<DeviceStatus, dynamic> get deviceStatusIcon => {
Expand Down

0 comments on commit 2244333

Please sign in to comment.