maps/mobile/lib/features/map/presentation/widgets/map_controls.dart
2026-03-30 09:22:16 +02:00

47 lines
1.4 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../providers/map_provider.dart';
class MapControls extends ConsumerWidget {
const MapControls({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final isLocating = ref.watch(mapProvider.select((s) => s.isLocating));
return Positioned(
right: 16,
bottom: 120,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
FloatingActionButton.small(
heroTag: 'zoom_in',
onPressed: () => ref.read(mapProvider.notifier).zoomIn(),
child: const Icon(Icons.add),
),
const SizedBox(height: 8),
FloatingActionButton.small(
heroTag: 'zoom_out',
onPressed: () => ref.read(mapProvider.notifier).zoomOut(),
child: const Icon(Icons.remove),
),
const SizedBox(height: 16),
FloatingActionButton.small(
heroTag: 'locate_me',
onPressed: isLocating
? null
: () => ref.read(mapProvider.notifier).locateUser(),
child: isLocating
? const SizedBox(
width: 20,
height: 20,
child: CircularProgressIndicator(strokeWidth: 2),
)
: const Icon(Icons.my_location),
),
],
),
);
}
}