mirror of
https://github.com/FoggedLens/deflock-app.git
synced 2026-02-12 16:52:51 +00:00
130 lines
4.1 KiB
Dart
130 lines
4.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import '../app_state.dart';
|
|
import '../models/camera_profile.dart';
|
|
|
|
class AddCameraSheet extends StatelessWidget {
|
|
const AddCameraSheet({super.key, required this.session});
|
|
|
|
final AddCameraSession session;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final appState = context.watch<AppState>();
|
|
|
|
void _commit() {
|
|
appState.commitSession();
|
|
Navigator.pop(context);
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
const SnackBar(content: Text('Camera queued for upload')),
|
|
);
|
|
}
|
|
|
|
void _cancel() {
|
|
appState.cancelSession();
|
|
Navigator.pop(context);
|
|
}
|
|
|
|
final customProfiles = appState.enabledProfiles.where((p) => !p.builtin).toList();
|
|
final allowSubmit = customProfiles.isNotEmpty && !session.profile.builtin;
|
|
|
|
return Padding(
|
|
padding:
|
|
EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
const SizedBox(height: 12),
|
|
Container(
|
|
width: 40,
|
|
height: 4,
|
|
decoration: BoxDecoration(
|
|
color: Colors.grey.shade400,
|
|
borderRadius: BorderRadius.circular(2),
|
|
),
|
|
),
|
|
const SizedBox(height: 16),
|
|
ListTile(
|
|
title: const Text('Profile'),
|
|
trailing: DropdownButton<CameraProfile>(
|
|
value: session.profile,
|
|
items: appState.enabledProfiles
|
|
.map((p) => DropdownMenuItem(value: p, child: Text(p.name)))
|
|
.toList(),
|
|
onChanged: (p) =>
|
|
appState.updateSession(profile: p ?? session.profile),
|
|
),
|
|
),
|
|
ListTile(
|
|
title: Text('Direction ${session.directionDegrees.round()}°'),
|
|
subtitle: Slider(
|
|
min: 0,
|
|
max: 359,
|
|
divisions: 359,
|
|
value: session.directionDegrees,
|
|
label: session.directionDegrees.round().toString(),
|
|
onChanged: (v) => appState.updateSession(directionDeg: v),
|
|
),
|
|
),
|
|
if (customProfiles.isEmpty)
|
|
Padding(
|
|
padding: const EdgeInsets.fromLTRB(16, 0, 16, 12),
|
|
child: Row(
|
|
children: const [
|
|
Icon(Icons.info_outline, color: Colors.red, size: 20),
|
|
SizedBox(width: 6),
|
|
Expanded(
|
|
child: Text(
|
|
'Enable or create a custom profile in Settings to submit new cameras.',
|
|
style: TextStyle(color: Colors.red, fontSize: 13),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
)
|
|
else if (session.profile.builtin)
|
|
Padding(
|
|
padding: const EdgeInsets.fromLTRB(16, 0, 16, 12),
|
|
child: Row(
|
|
children: const [
|
|
Icon(Icons.info_outline, color: Colors.orange, size: 20),
|
|
SizedBox(width: 6),
|
|
Expanded(
|
|
child: Text(
|
|
'The built-in profile is for map viewing only. Please select a custom profile to submit new cameras.',
|
|
style: TextStyle(color: Colors.orange, fontSize: 13),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(height: 8),
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: OutlinedButton(
|
|
onPressed: _cancel,
|
|
child: const Text('Cancel'),
|
|
),
|
|
),
|
|
const SizedBox(width: 12),
|
|
Expanded(
|
|
child: ElevatedButton(
|
|
onPressed: allowSubmit ? _commit : null,
|
|
child: const Text('Submit'),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(height: 20),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|