selfprivacy.org.app/lib/logic/models/provider.dart

39 lines
858 B
Dart
Raw Normal View History

2020-12-06 07:28:31 +00:00
import 'package:equatable/equatable.dart';
import 'package:flutter/widgets.dart';
2020-12-10 20:33:19 +00:00
import 'package:selfprivacy/logic/models/state_types.dart';
2020-12-06 07:28:31 +00:00
import 'package:selfprivacy/ui/components/brand_icons/brand_icons.dart';
2020-12-10 20:33:19 +00:00
enum ProviderType {
2020-12-06 07:28:31 +00:00
server,
domain,
backup,
}
class ProviderModel extends Equatable {
2021-03-15 15:39:44 +00:00
const ProviderModel({required this.state, required this.type});
2020-12-06 07:28:31 +00:00
2020-12-10 20:33:19 +00:00
final StateType state;
final ProviderType type;
2020-12-06 07:28:31 +00:00
2020-12-10 20:33:19 +00:00
ProviderModel updateState(StateType newState) => ProviderModel(
2020-12-06 07:28:31 +00:00
state: newState,
type: type,
);
@override
2021-03-15 15:39:44 +00:00
List<Object?> get props => [state, type];
2020-12-06 07:28:31 +00:00
IconData get icon {
switch (type) {
2020-12-10 20:33:19 +00:00
case ProviderType.server:
2020-12-06 07:28:31 +00:00
return BrandIcons.server;
2020-12-10 20:33:19 +00:00
case ProviderType.domain:
2020-12-06 07:28:31 +00:00
return BrandIcons.globe;
2020-12-10 20:33:19 +00:00
case ProviderType.backup:
2020-12-06 07:28:31 +00:00
return BrandIcons.save;
}
}
}