selfprivacy.org.app/lib/logic/cubit/services/services_cubit.dart

29 lines
741 B
Dart
Raw Normal View History

2020-12-01 19:08:19 +00:00
import 'package:bloc/bloc.dart';
2020-12-10 20:33:19 +00:00
import 'package:equatable/equatable.dart';
2020-12-01 19:08:19 +00:00
import 'package:meta/meta.dart';
import 'package:selfprivacy/logic/models/service.dart';
2020-12-10 20:33:19 +00:00
import 'package:selfprivacy/logic/models/state_types.dart';
2020-12-01 19:08:19 +00:00
export 'package:provider/provider.dart';
2020-12-10 20:33:19 +00:00
export 'package:selfprivacy/logic/models/state_types.dart';
2020-12-01 19:08:19 +00:00
part 'services_state.dart';
class ServicesCubit extends Cubit<ServicesState> {
ServicesCubit() : super(ServicesState(all));
void connect(Service service) {
2020-12-10 20:33:19 +00:00
var newState = state.updateElement(service, StateType.stable);
2020-12-01 19:08:19 +00:00
emit(newState);
}
}
final all = ServiceTypes.values
.map(
(type) => Service(
2020-12-10 20:33:19 +00:00
state: StateType.uninitialized,
2020-12-01 19:08:19 +00:00
type: type,
),
)
.toList();