136 lines
4.1 KiB
Dart
136 lines
4.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../theme/app_theme.dart';
|
|
import 'ui.dart';
|
|
|
|
/// Bottom sheet used by every menu on a camera screen: the live image stays
|
|
/// visible and undimmed above it, so changes can be judged immediately.
|
|
Future<T?> showCameraSheet<T>(BuildContext context, {required WidgetBuilder builder}) =>
|
|
showAppSheet<T>(context, clearBarrier: true, maxHeightFactor: 0.75, builder: builder);
|
|
|
|
/// Title (+ optional subtitle) on the left, optional action on the right.
|
|
class CameraSheetHeader extends StatelessWidget {
|
|
final String title;
|
|
final String? subtitle;
|
|
final Widget? trailing;
|
|
|
|
const CameraSheetHeader({super.key, required this.title, this.subtitle, this.trailing});
|
|
|
|
@override
|
|
Widget build(BuildContext context) => SheetTitle(title, subtitle: subtitle, trailing: trailing);
|
|
}
|
|
|
|
/// "Ponastavi" pill in a sheet header.
|
|
class ResetPill extends StatelessWidget {
|
|
final String label;
|
|
final VoidCallback onTap;
|
|
const ResetPill({super.key, required this.label, required this.onTap});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final c = Palette.current;
|
|
return Material(
|
|
color: c.tile,
|
|
shape: const StadiumBorder(),
|
|
clipBehavior: Clip.antiAlias,
|
|
child: InkWell(
|
|
onTap: onTap,
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Icon(Icons.refresh_rounded, size: 16, color: c.ink),
|
|
const SizedBox(width: 6),
|
|
Text(label, style: TextStyle(fontSize: 13, fontWeight: FontWeight.w600, color: c.ink)),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Icon, label, value and a slider.
|
|
class SheetSlider extends StatelessWidget {
|
|
final IconData icon;
|
|
final String label;
|
|
final String valueText;
|
|
final double value;
|
|
final double min;
|
|
final double max;
|
|
final ValueChanged<double> onChanged;
|
|
|
|
const SheetSlider({
|
|
super.key,
|
|
required this.icon,
|
|
required this.label,
|
|
required this.valueText,
|
|
required this.value,
|
|
required this.min,
|
|
required this.max,
|
|
required this.onChanged,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) => LabeledSlider(
|
|
icon: icon, label: label, valueText: valueText, value: value, min: min, max: max, onChanged: onChanged);
|
|
}
|
|
|
|
/// On/off row with a switch (flashlight).
|
|
class SheetToggle extends StatelessWidget {
|
|
final IconData icon;
|
|
final String label;
|
|
final bool active;
|
|
final VoidCallback onTap;
|
|
|
|
const SheetToggle({super.key, required this.icon, required this.label, required this.active, required this.onTap});
|
|
|
|
@override
|
|
Widget build(BuildContext context) =>
|
|
ToggleRow(icon: icon, label: label, value: active, onChanged: (_) => onTap());
|
|
}
|
|
|
|
/// The numbers [min]..[max] as big square buttons; the chosen one in the accent.
|
|
class SheetStepper extends StatelessWidget {
|
|
final int value;
|
|
final int min;
|
|
final int max;
|
|
final ValueChanged<int> onChanged;
|
|
|
|
const SheetStepper({super.key, required this.value, required this.min, required this.max, required this.onChanged});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final c = Palette.current;
|
|
return Row(
|
|
children: [
|
|
for (int n = min; n <= max; n++) ...[
|
|
if (n > min) const SizedBox(width: 10),
|
|
Expanded(
|
|
child: AspectRatio(
|
|
aspectRatio: 1,
|
|
child: Material(
|
|
color: n == value ? c.accent : c.tile,
|
|
borderRadius: BorderRadius.circular(14),
|
|
clipBehavior: Clip.antiAlias,
|
|
child: InkWell(
|
|
onTap: () => onChanged(n),
|
|
child: Center(
|
|
child: Text('$n',
|
|
style: TextStyle(
|
|
fontSize: 22,
|
|
fontWeight: FontWeight.w700,
|
|
color: n == value ? c.onAccent : c.ink,
|
|
fontFeatures: AppTheme.tnum,
|
|
)),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
],
|
|
);
|
|
}
|
|
}
|