2023-02-19 17:31:46 +01:00
|
|
|
import 'package:smoke_cess_app/service/json_service.dart';
|
|
|
|
|
2023-02-17 13:47:52 +01:00
|
|
|
class Settings {
|
|
|
|
final String group;
|
2023-02-19 17:31:46 +01:00
|
|
|
final List<String>? relapseCategories;
|
|
|
|
final QueryConfig moodQuery;
|
|
|
|
final QueryConfig sleepQuery;
|
|
|
|
final TimeConfig? chessTime;
|
2023-02-17 13:47:52 +01:00
|
|
|
|
2023-02-19 17:31:46 +01:00
|
|
|
Settings(this.group, this.relapseCategories, this.moodQuery, this.sleepQuery,
|
|
|
|
this.chessTime);
|
2023-02-17 13:47:52 +01:00
|
|
|
|
|
|
|
Settings.fromJson(Map<String, dynamic> json)
|
2023-02-19 17:31:46 +01:00
|
|
|
: group = json['group'] as String,
|
|
|
|
relapseCategories = jsonPropertyAsList(json['relapse_categories']),
|
|
|
|
moodQuery = QueryConfig.fromJson(json['mood_query']),
|
|
|
|
sleepQuery = QueryConfig.fromJson(json['sleep_query']),
|
|
|
|
chessTime =
|
|
|
|
json['chess_time'] ? TimeConfig.fromJson(json['chess_time']) : null;
|
|
|
|
}
|
|
|
|
|
|
|
|
class QueryConfig {
|
|
|
|
final int hours;
|
|
|
|
final int minutes;
|
|
|
|
final List<String>? days;
|
|
|
|
|
|
|
|
QueryConfig(this.hours, this.minutes, this.days);
|
|
|
|
|
|
|
|
QueryConfig.fromJson(Map<String, dynamic> json)
|
|
|
|
: hours = json['hours'] as int,
|
|
|
|
minutes = json['minutes'] as int,
|
|
|
|
days = jsonPropertyAsList(json['days']);
|
|
|
|
}
|
|
|
|
|
|
|
|
class TimeConfig {
|
|
|
|
final int hours;
|
|
|
|
final int minutes;
|
|
|
|
|
|
|
|
TimeConfig(this.hours, this.minutes);
|
|
|
|
|
|
|
|
TimeConfig.fromJson(Map<String, dynamic> json)
|
|
|
|
: hours = json['hours'] as int,
|
|
|
|
minutes = json['minutes'] as int;
|
2023-02-17 13:47:52 +01:00
|
|
|
}
|