RuStore Remote Config
This commit is contained in:
25
lib/application/dto/direction.dart
Normal file
25
lib/application/dto/direction.dart
Normal file
@@ -0,0 +1,25 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
enum Direction {
|
||||
@JsonValue('in_city') inCity,
|
||||
@JsonValue('change') change,
|
||||
@JsonValue('out_city') outCity;
|
||||
|
||||
String displayName() {
|
||||
switch(this) {
|
||||
case Direction.inCity: return 'В город';
|
||||
case Direction.change: return 'Переключение';
|
||||
case Direction.outCity: return 'Из города';
|
||||
}
|
||||
}
|
||||
|
||||
IconData icon() {
|
||||
switch(this) {
|
||||
case Direction.inCity: return Icons.input_outlined;
|
||||
case Direction.change: return Icons.change_circle_outlined;
|
||||
case Direction.outCity: return Icons.output_outlined;
|
||||
}
|
||||
}
|
||||
}
|
||||
15
lib/application/dto/rule.dart
Normal file
15
lib/application/dto/rule.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
import "package:json_annotation/json_annotation.dart" show FieldRename, JsonSerializable;
|
||||
|
||||
part 'rule.g.dart';
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake, explicitToJson: true)
|
||||
class Rule {
|
||||
final DateTime after;
|
||||
final DateTime? before;
|
||||
final Map<String, String> dataset;
|
||||
|
||||
Rule({required this.after, required this.before, required this.dataset});
|
||||
|
||||
factory Rule.fromJson(Map<String, dynamic> json) => _$RuleFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$RuleToJson(this);
|
||||
}
|
||||
21
lib/application/dto/rule.g.dart
Normal file
21
lib/application/dto/rule.g.dart
Normal file
@@ -0,0 +1,21 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'rule.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
Rule _$RuleFromJson(Map<String, dynamic> json) => Rule(
|
||||
after: DateTime.parse(json['after'] as String),
|
||||
before: json['before'] == null
|
||||
? null
|
||||
: DateTime.parse(json['before'] as String),
|
||||
dataset: Map<String, String>.from(json['dataset'] as Map),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$RuleToJson(Rule instance) => <String, dynamic>{
|
||||
'after': instance.after.toIso8601String(),
|
||||
'before': instance.before?.toIso8601String(),
|
||||
'dataset': instance.dataset,
|
||||
};
|
||||
41
lib/application/dto/schedule.dart
Normal file
41
lib/application/dto/schedule.dart
Normal file
@@ -0,0 +1,41 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:reverse_nn/application/dto/direction.dart';
|
||||
|
||||
part 'schedule.g.dart';
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake, explicitToJson: true)
|
||||
class ScheduleItem {
|
||||
final int duration;
|
||||
final Direction direction;
|
||||
|
||||
final DateTime? start;
|
||||
final DateTime? end;
|
||||
final bool? showStartDate;
|
||||
final bool? showEndDate;
|
||||
|
||||
ScheduleItem({
|
||||
required this.duration,
|
||||
required this.direction,
|
||||
this.start,
|
||||
this.end,
|
||||
this.showStartDate,
|
||||
this.showEndDate
|
||||
});
|
||||
|
||||
factory ScheduleItem.fromJson(Map<String, dynamic> json) => _$ScheduleItemFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$ScheduleItemToJson(this);
|
||||
|
||||
ScheduleItem fillAdditional({
|
||||
required DateTime start,
|
||||
required DateTime end,
|
||||
required bool showStartDate,
|
||||
required bool showEndDate
|
||||
}) => ScheduleItem(
|
||||
duration: duration,
|
||||
direction: direction,
|
||||
start: start,
|
||||
end: end,
|
||||
showStartDate: showStartDate,
|
||||
showEndDate: showEndDate,
|
||||
);
|
||||
}
|
||||
34
lib/application/dto/schedule.g.dart
Normal file
34
lib/application/dto/schedule.g.dart
Normal file
@@ -0,0 +1,34 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'schedule.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
ScheduleItem _$ScheduleItemFromJson(Map<String, dynamic> json) => ScheduleItem(
|
||||
duration: (json['duration'] as num).toInt(),
|
||||
direction: $enumDecode(_$DirectionEnumMap, json['direction']),
|
||||
start: json['start'] == null
|
||||
? null
|
||||
: DateTime.parse(json['start'] as String),
|
||||
end: json['end'] == null ? null : DateTime.parse(json['end'] as String),
|
||||
showStartDate: json['show_start_date'] as bool?,
|
||||
showEndDate: json['show_end_date'] as bool?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$ScheduleItemToJson(ScheduleItem instance) =>
|
||||
<String, dynamic>{
|
||||
'duration': instance.duration,
|
||||
'direction': _$DirectionEnumMap[instance.direction]!,
|
||||
'start': instance.start?.toIso8601String(),
|
||||
'end': instance.end?.toIso8601String(),
|
||||
'show_start_date': instance.showStartDate,
|
||||
'show_end_date': instance.showEndDate,
|
||||
};
|
||||
|
||||
const _$DirectionEnumMap = {
|
||||
Direction.inCity: 'in_city',
|
||||
Direction.change: 'change',
|
||||
Direction.outCity: 'out_city',
|
||||
};
|
||||
Reference in New Issue
Block a user