34 lines
1.1 KiB
Dart
34 lines
1.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:gps/blocs/bloc_provider.dart';
|
|
import 'package:gps/blocs/gps_bloc.dart';
|
|
|
|
class GpsButtonsWidgetBloc extends StatelessWidget {
|
|
const GpsButtonsWidgetBloc({
|
|
Key? key,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final GpsBloc bloc = BlocProvider.of<GpsBloc>(context);
|
|
return Row(
|
|
children: [
|
|
StreamBuilder<GpsBlocState>(
|
|
stream: bloc.stateOut,
|
|
initialData: GpsBlocState.notRecording,
|
|
builder: (BuildContext context,
|
|
AsyncSnapshot<GpsBlocState> snapshot) {
|
|
return IconButton(
|
|
onPressed: () => bloc.actionIn.add(GpsBlocAction.toggleRecording),
|
|
icon: Icon(snapshot.data == GpsBlocState.recording
|
|
? Icons.stop
|
|
: Icons.fiber_manual_record),
|
|
);
|
|
}),
|
|
IconButton(
|
|
onPressed: () => bloc.actionIn.add(GpsBlocAction.save),
|
|
icon: const Icon(Icons.save),
|
|
)
|
|
],
|
|
);
|
|
}
|
|
} |