new UI + new targets.
This commit is contained in:
+84
-185
@@ -1,183 +1,47 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
import 'ui.dart';
|
||||
|
||||
/// Bottom sheet used by every menu on the camera stream: the live image stays
|
||||
/// 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}) {
|
||||
return showModalBottomSheet<T>(
|
||||
context: context,
|
||||
barrierColor: Colors.transparent,
|
||||
backgroundColor: Colors.grey[900],
|
||||
isScrollControlled:
|
||||
true, // tall content (timer) may use more than half the screen
|
||||
builder: (sheet) => SafeArea(
|
||||
child: ConstrainedBox(
|
||||
constraints:
|
||||
BoxConstraints(maxHeight: MediaQuery.sizeOf(sheet).height * 0.75),
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.fromLTRB(20, 0, 20, 16),
|
||||
child: builder(sheet),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
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 IconData? icon;
|
||||
final Color? iconColor;
|
||||
final Widget? trailing;
|
||||
|
||||
const CameraSheetHeader({
|
||||
super.key,
|
||||
required this.title,
|
||||
this.subtitle,
|
||||
this.icon,
|
||||
this.iconColor,
|
||||
this.trailing,
|
||||
});
|
||||
const CameraSheetHeader({super.key, required this.title, this.subtitle, this.trailing});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 14),
|
||||
child: Row(
|
||||
children: [
|
||||
if (icon != null) ...[
|
||||
Icon(icon, color: iconColor ?? Colors.white, size: 22),
|
||||
const SizedBox(width: 8),
|
||||
],
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(title,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold)),
|
||||
if (subtitle != null)
|
||||
Text(subtitle!,
|
||||
style:
|
||||
const TextStyle(color: Colors.white54, fontSize: 12)),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (trailing != null) trailing!,
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
Widget build(BuildContext context) => SheetTitle(title, subtitle: subtitle, trailing: trailing);
|
||||
}
|
||||
|
||||
/// Icon, label, slider and current value in one row.
|
||||
class SheetSlider extends StatelessWidget {
|
||||
final IconData icon;
|
||||
/// "Ponastavi" pill in a sheet header.
|
||||
class ResetPill extends StatelessWidget {
|
||||
final String label;
|
||||
final String valueText;
|
||||
final double value;
|
||||
final double min;
|
||||
final double max;
|
||||
final Color accent;
|
||||
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.accent,
|
||||
required this.onChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
Icon(icon, color: Colors.white54, size: 20),
|
||||
const SizedBox(width: 8),
|
||||
SizedBox(
|
||||
width: 72,
|
||||
child: Text(label,
|
||||
style: const TextStyle(color: Colors.white, fontSize: 13)),
|
||||
),
|
||||
Expanded(
|
||||
child: Slider(
|
||||
value: value.clamp(min, max),
|
||||
min: min,
|
||||
max: max,
|
||||
activeColor: accent,
|
||||
inactiveColor: Colors.white24,
|
||||
onChanged: onChanged,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 46,
|
||||
child: Text(
|
||||
valueText,
|
||||
textAlign: TextAlign.right,
|
||||
style: const TextStyle(
|
||||
color: Colors.white70,
|
||||
fontSize: 13,
|
||||
fontFeatures: [FontFeature.tabularFigures()]),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Wide button that shows an on/off state with the accent color.
|
||||
class SheetToggle extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final String label;
|
||||
final bool active;
|
||||
final Color accent;
|
||||
final VoidCallback onTap;
|
||||
|
||||
const SheetToggle({super.key,
|
||||
required this.icon,
|
||||
required this.label,
|
||||
required this.active,
|
||||
required this.accent,
|
||||
required this.onTap,
|
||||
});
|
||||
const ResetPill({super.key, required this.label, required this.onTap});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final c = Palette.current;
|
||||
return Material(
|
||||
color: active
|
||||
? accent.withValues(alpha: 0.18)
|
||||
: Colors.white.withValues(alpha: 0.06),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
side:
|
||||
BorderSide(color: active ? accent : Colors.transparent, width: 1.5),
|
||||
),
|
||||
color: c.tile,
|
||||
shape: const StadiumBorder(),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
onTap: onTap,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 10),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(icon, size: 18, color: active ? accent : Colors.white70),
|
||||
Icon(Icons.refresh_rounded, size: 16, color: c.ink),
|
||||
const SizedBox(width: 6),
|
||||
Flexible(
|
||||
child: Text(
|
||||
label,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: active ? Colors.white : Colors.white70),
|
||||
),
|
||||
),
|
||||
Text(label, style: TextStyle(fontSize: 13, fontWeight: FontWeight.w600, color: c.ink)),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -186,50 +50,85 @@ class SheetToggle extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
/// Big number with − / + buttons, used for the bullet count.
|
||||
class SheetStepper extends StatelessWidget {
|
||||
final int value;
|
||||
final int min;
|
||||
final int max;
|
||||
final Color accent;
|
||||
final ValueChanged<int> onChanged;
|
||||
/// 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 SheetStepper({
|
||||
const SheetSlider({
|
||||
super.key,
|
||||
required this.icon,
|
||||
required this.label,
|
||||
required this.valueText,
|
||||
required this.value,
|
||||
required this.min,
|
||||
required this.max,
|
||||
required this.accent,
|
||||
required this.onChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget button(IconData icon, bool enabled, int next) => IconButton(
|
||||
onPressed: enabled ? () => onChanged(next) : null,
|
||||
icon: Icon(icon, color: Colors.white, size: 28),
|
||||
style: IconButton.styleFrom(
|
||||
backgroundColor:
|
||||
Colors.white.withValues(alpha: enabled ? 0.12 : 0.04),
|
||||
shape: const CircleBorder(),
|
||||
minimumSize: const Size(56, 56),
|
||||
),
|
||||
);
|
||||
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(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
button(Icons.remove, value > min, value - 1),
|
||||
SizedBox(
|
||||
width: 120,
|
||||
child: Text(
|
||||
'$value',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 56, fontWeight: FontWeight.bold, color: accent),
|
||||
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,
|
||||
)),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
button(Icons.add, value < max, value + 1),
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user