Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Settings panel #73

Merged
merged 38 commits into from
Nov 22, 2020
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
7742b98
New sliverbar asset & app icon
Nov 6, 2020
89994fd
Removed old file
Nov 9, 2020
71ad1ef
Added loading indicator helper
Nov 9, 2020
898efab
Added settings route, page, bloc
Nov 9, 2020
06fb34b
Handle empty settings & Acquisition board
Nov 10, 2020
cc47c91
Fixes to import structure
Nov 10, 2020
76a9ae9
Fixes to import structure part 2
Nov 10, 2020
d2e926b
Merge remote-tracking branch 'origin/master' into mobile/app-user-set…
Nov 10, 2020
62a0670
Minor changes to settings text
Nov 10, 2020
d8a45ad
Removed unnecessary imports after adding part of ''
Nov 10, 2020
b953667
Update mobile/lib/src/application/settings/settings_cubit.dart
mateobelanger Nov 10, 2020
c230e63
Update mobile/lib/src/application/settings/settings_cubit.dart
mateobelanger Nov 10, 2020
b652929
Update mobile/lib/src/application/settings/settings_cubit.dart
mateobelanger Nov 10, 2020
2eb2058
Update mobile/lib/src/application/settings/settings_cubit.dart
mateobelanger Nov 10, 2020
ee6c3b8
Added Sharedpreference property to cubit
Nov 10, 2020
85c9a7c
Merge remote-tracking branch 'origin/mobile/app-user-settings' into m…
Nov 10, 2020
40186af
Added genericity to Settings backbone
Nov 10, 2020
97094ca
Nit fix for formating
Nov 10, 2020
15ed171
Settings in Map<String, dynamic> and added Infrastructure layer
Nov 11, 2020
94437cc
Generic is the new fun
Nov 12, 2020
b24beef
Removed obsolete Acquisition board setting
Nov 12, 2020
a5bd02b
Added server url setting option
Nov 12, 2020
771d012
Merge remote-tracking branch 'origin/master' into mobile/app-user-set…
Nov 12, 2020
abf70be
Infrastructure getter gets only 1 setting at a time
Nov 13, 2020
35739d9
Renamed interface methods
Nov 13, 2020
8b200c7
more genericity
Nov 13, 2020
24c461d
Added URL server setting field, added infrastructure layer
Nov 21, 2020
2e75bb6
Renamed infrastructure getters & setters
Nov 21, 2020
3f665f9
Fixed rebase conflicts
Nov 21, 2020
d5c554a
Merge master into mobile/app-user-settings
Nov 21, 2020
6184dea
Added validation on Settings model
Nov 22, 2020
c3bd6d7
Library for infrastructure storage keys, Settings tile functions generic
Nov 22, 2020
2657711
added constants for max & min Age
Nov 22, 2020
e3e6cb8
Factory settings constructor with exceptions
Nov 22, 2020
ea3df86
Added validation on server address
Nov 22, 2020
45c94b1
Added validation and constants to age setting
Nov 22, 2020
445000e
Fixes
Nov 22, 2020
75bd04e
nit fix for launch config
Nov 22, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mobile/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@
android:value="2" />
</application>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
</manifest>
</manifest>
Binary file modified mobile/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified mobile/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified mobile/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified mobile/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified mobile/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mobile/common/assets/img/Dodo4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
233 changes: 233 additions & 0 deletions mobile/common/assets/img/Dodo4.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mobile/common/assets/img/Objets.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 0 additions & 10 deletions mobile/lib/src/application/navdrawer/navdrawer_state.dart

This file was deleted.

50 changes: 50 additions & 0 deletions mobile/lib/src/application/settings/settings_cubit.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:polydodo/src/domain/settings/settings.dart';
import 'package:shared_preferences/shared_preferences.dart';

part 'settings_state.dart';

class SettingsCubit extends Cubit<SettingsState> {
SettingsCubit() : super(SettingsLoadInProgress()) {
getSettings();
}
mateobelanger marked this conversation as resolved.
Show resolved Hide resolved

void getSettings() async {
mateobelanger marked this conversation as resolved.
Show resolved Hide resolved
var prefs = (await SharedPreferences.getInstance());
mateobelanger marked this conversation as resolved.
Show resolved Hide resolved
mateobelanger marked this conversation as resolved.
Show resolved Hide resolved

var settings = Settings(
age: prefs.getInt('age'),
board: AcquisitionBoard
.values[(prefs.getInt('board')) ?? AcquisitionBoard.Empty.index],
sex: Sex.values[(prefs.getInt('sex')) ?? Sex.Empty.index],
);

emit(SettingsLoadSuccess(settings));
}

void setSex(Sex newSex) async {
mateobelanger marked this conversation as resolved.
Show resolved Hide resolved
if (state is SettingsLoadSuccess) {
emit(SettingsLoadSuccess(
(state as SettingsLoadSuccess).settings.copyWith(sex: newSex)));
await (await SharedPreferences.getInstance()).setInt('sex', newSex.index);
mateobelanger marked this conversation as resolved.
Show resolved Hide resolved
}
}

void setAge(int newAge) async {
mateobelanger marked this conversation as resolved.
Show resolved Hide resolved
if (state is SettingsLoadSuccess) {
mateobelanger marked this conversation as resolved.
Show resolved Hide resolved
emit(SettingsLoadSuccess(
(state as SettingsLoadSuccess).settings.copyWith(age: newAge)));
await (await SharedPreferences.getInstance()).setInt('age', newAge);
mateobelanger marked this conversation as resolved.
Show resolved Hide resolved
}
}

void setBoard(AcquisitionBoard newBoard) async {
mateobelanger marked this conversation as resolved.
Show resolved Hide resolved
if (state is SettingsLoadSuccess) {
emit(SettingsLoadSuccess(
(state as SettingsLoadSuccess).settings.copyWith(board: newBoard)));
await (await SharedPreferences.getInstance())
.setInt('board', newBoard.index);
mateobelanger marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
24 changes: 24 additions & 0 deletions mobile/lib/src/application/settings/settings_state.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
part of 'settings_cubit.dart';

abstract class SettingsState extends Equatable {
const SettingsState();

@override
List<Object> get props => [];
}

class SettingsLoadInProgress extends SettingsState {}

class SettingsLoadSuccess extends SettingsState {
final Settings settings;

const SettingsLoadSuccess(this.settings);

@override
List<Object> get props => [settings];

@override
String toString() => 'SettingsLoadSuccess { settings: $settings }';
}

class SettingsLoadFailure extends SettingsState {}
3 changes: 3 additions & 0 deletions mobile/lib/src/domain/settings/acquisition_board.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
part of 'settings.dart';

enum AcquisitionBoard { Empty, Cython, Ganglion }
mateobelanger marked this conversation as resolved.
Show resolved Hide resolved
20 changes: 20 additions & 0 deletions mobile/lib/src/domain/settings/settings.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import 'package:equatable/equatable.dart';

part 'sex.dart';
part 'acquisition_board.dart';

class Settings extends Equatable {
final int age;
final AcquisitionBoard board;
final Sex sex;

Settings({this.age, this.board, this.sex});

@override
List<Object> get props => [age, board, sex];

Settings copyWith({int age, AcquisitionBoard board, Sex sex}) {
return Settings(
age: age ?? this.age, board: board ?? this.board, sex: sex ?? this.sex);
}
}
3 changes: 3 additions & 0 deletions mobile/lib/src/domain/settings/sex.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
part of 'settings.dart';

enum Sex { Empty, Male, Female }
4 changes: 4 additions & 0 deletions mobile/lib/src/locator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:get_it/get_it.dart';
import 'package:polydodo/src/application/device/device_selector_cubit.dart';
import 'package:polydodo/src/application/eeg_data/data_cubit.dart';
import 'package:polydodo/src/application/night_stats/night_stats_cubit.dart';
import 'package:polydodo/src/application/settings/settings_cubit.dart';
import 'package:polydodo/src/application/sleep_history/sleep_history_cubit.dart';
import 'package:polydodo/src/domain/acquisition_device/i_acquisition_device_repository.dart';
import 'package:polydodo/src/domain/eeg_data/i_eeg_data_repository.dart';
Expand Down Expand Up @@ -35,6 +36,9 @@ List<BlocProvider> createBlocProviders() => [
_serviceLocator.get<IEEGDataRepository>(),
),
),
BlocProvider<SettingsCubit>(
create: (context) => SettingsCubit(),
),
BlocProvider<SleepHistoryCubit>(
create: (context) => SleepHistoryCubit(
_serviceLocator.get<ISleepHistoryRepository>())),
Expand Down
9 changes: 6 additions & 3 deletions mobile/lib/src/presentation/navigation/navdrawer_tabs.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
part of 'navdrawer_widget.dart';

enum NavdrawerTab {
BluetoothSelector,
Dashboard,
NightStats,
RecordSleep,
BluetoothSelector,
History,
NightStats
Settings,
SleepHistory,
}
15 changes: 12 additions & 3 deletions mobile/lib/src/presentation/navigation/navdrawer_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:polydodo/src/presentation/navigation/routes/router.gr.dart';

import 'navdrawer_tabs.dart';
part 'navdrawer_tabs.dart';

class NavDrawer extends StatelessWidget {
static const name = 'appDrawerRoute';
Expand All @@ -24,24 +24,35 @@ class NavDrawer extends StatelessWidget {
icon: Icons.dashboard,
text: 'Dashboard',
route: Routes.dashboardPage,
tab: NavdrawerTab.Dashboard,
context: context,
),
_createDrawerItem(
icon: Icons.bluetooth,
text: 'Bluetooth selector',
route: Routes.bluetoothSelectorPage,
tab: NavdrawerTab.BluetoothSelector,
context: context,
),
_createDrawerItem(
icon: Icons.hotel,
text: 'Record Sleep sequence',
route: Routes.recordSleepGuidePage,
tab: NavdrawerTab.RecordSleep,
context: context,
),
_createDrawerItem(
icon: Icons.analytics,
text: 'History',
route: Routes.sleepHistoryPage,
tab: NavdrawerTab.SleepHistory,
context: context,
),
_createDrawerItem(
icon: Icons.settings,
text: 'Settings',
route: Routes.settingsPage,
tab: NavdrawerTab.Settings,
context: context,
),
],
Expand Down Expand Up @@ -86,9 +97,7 @@ class NavDrawer extends StatelessWidget {
],
),
onTap: () {
//context.bloc<NavdrawerBloc>().add(NavdrawerUpdated(state));
ExtendedNavigator.of(context).popAndPush(route);
// ExtendedNavigator.of(context).replace(route);
},
selected: activeTab == tab,
);
Expand Down
4 changes: 3 additions & 1 deletion mobile/lib/src/presentation/navigation/routes/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:polydodo/src/presentation/pages/dashboard/dashboard_page.dart';
import 'package:polydodo/src/presentation/pages/record_sleep/record_sleep_guide_page.dart';
import 'package:polydodo/src/presentation/pages/record_sleep/record_sleep_recording_page.dart';
import 'package:polydodo/src/presentation/pages/record_sleep/record_sleep_validate_page.dart';

import 'package:polydodo/src/presentation/pages/settings/settings_page.dart';
import 'package:polydodo/src/presentation/pages/sleep_history_page/sleep_history_page.dart';
import 'package:polydodo/src/presentation/pages/night_stats_page/night_stats_page.dart';

Expand All @@ -31,6 +31,8 @@ import 'package:polydodo/src/presentation/pages/night_stats_page/night_stats_pag
CustomRoute(
page: SleepHistoryPage,
transitionsBuilder: TransitionsBuilders.fadeIn),
CustomRoute(
page: SettingsPage, transitionsBuilder: TransitionsBuilders.fadeIn),
CustomRoute(
page: NightStatsPage, transitionsBuilder: TransitionsBuilders.fadeIn),
])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:polydodo/src/application/device/device_selector_cubit.dart';
import 'package:polydodo/src/application/device/device_selector_state.dart';
import 'package:polydodo/src/presentation/navigation/navdrawer_tabs.dart';
import 'package:polydodo/src/presentation/navigation/navdrawer_widget.dart';
import 'package:polydodo/src/presentation/navigation/routes/router.gr.dart';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:polydodo/src/presentation/navigation/navdrawer_tabs.dart';
import 'package:polydodo/src/presentation/navigation/navdrawer_widget.dart';

class DashboardPage extends StatelessWidget {
Expand All @@ -16,14 +15,14 @@ class DashboardPage extends StatelessWidget {
floating: false,
pinned: true,
flexibleSpace: FlexibleSpaceBar(
centerTitle: false,
centerTitle: true,
title: Text('Polydodo',
style: TextStyle(
color: Colors.white,
fontSize: 16.0,
)),
background: Image.network(
'https://images.pexels.com/photos/396547/pexels-photo-396547.jpeg?auto=compress&cs=tinysrgb&h=350',
background: Image.asset(
'common/assets/img/Objets.png',
fit: BoxFit.cover,
)),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:polydodo/src/application/night_stats/night_stats_cubit.dart';
import 'package:polydodo/src/application/night_stats/night_stats_state.dart';
import 'package:polydodo/src/presentation/navigation/navdrawer_tabs.dart';
import 'package:polydodo/src/presentation/navigation/navdrawer_widget.dart';
import 'package:polydodo/src/presentation/pages/night_stats_page/metric_section.dart';
import 'package:polydodo/src/presentation/pages/night_stats_page/sleep_stages_section.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:polydodo/src/application/blocs.dart';
import 'package:polydodo/src/presentation/navigation/navdrawer_tabs.dart';
import 'package:polydodo/src/presentation/navigation/navdrawer_widget.dart';
import 'package:polydodo/src/presentation/navigation/routes/router.gr.dart';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:polydodo/src/application/eeg_data/data_cubit.dart';
import 'package:polydodo/src/application/eeg_data/data_states.dart';
import 'package:polydodo/src/presentation/navigation/navdrawer_tabs.dart';
import 'package:polydodo/src/presentation/navigation/navdrawer_widget.dart';

class RecordSleepRecordingPage extends StatelessWidget {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:polydodo/src/application/eeg_data/data_cubit.dart';
import 'package:polydodo/src/application/eeg_data/data_states.dart';
import 'package:polydodo/src/presentation/navigation/navdrawer_tabs.dart';
import 'package:polydodo/src/presentation/navigation/navdrawer_widget.dart';
import 'package:polydodo/src/presentation/navigation/routes/router.gr.dart';
import 'package:polydodo/src/presentation/pages/record_sleep/signal_section.dart';
Expand Down
Loading