mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-10-19 14:50:40 +00:00
9cfffc3377
* wip * hide `DynamicColorListTile` if unavailable * added color animation for `AnimatedDialog` * adjusted some colors * sync `AnimatedDialog` insets with material * scroll to selected color
65 lines
1.7 KiB
Dart
65 lines
1.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:lightmeter/res/dimens.dart';
|
|
import 'package:lightmeter/screens/shared/filled_circle/widget_circle_filled.dart';
|
|
|
|
class MeteringMeasureButton extends StatefulWidget {
|
|
final double size;
|
|
final VoidCallback onTap;
|
|
|
|
const MeteringMeasureButton({
|
|
required this.onTap,
|
|
this.size = 72,
|
|
super.key,
|
|
});
|
|
|
|
@override
|
|
State<MeteringMeasureButton> createState() => _MeteringMeasureButtonState();
|
|
}
|
|
|
|
class _MeteringMeasureButtonState extends State<MeteringMeasureButton> {
|
|
bool _isPressed = false;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SizedBox.fromSize(
|
|
size: Size.square(widget.size),
|
|
child: GestureDetector(
|
|
onTap: widget.onTap,
|
|
onTapDown: (_) {
|
|
setState(() {
|
|
_isPressed = true;
|
|
});
|
|
},
|
|
onTapUp: (_) {
|
|
setState(() {
|
|
_isPressed = false;
|
|
});
|
|
},
|
|
onTapCancel: () {
|
|
setState(() {
|
|
_isPressed = false;
|
|
});
|
|
},
|
|
child: DecoratedBox(
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(widget.size / 2),
|
|
border: Border.all(
|
|
width: Dimens.grid4,
|
|
color: Theme.of(context).colorScheme.onSurface,
|
|
),
|
|
),
|
|
child: Center(
|
|
child: AnimatedScale(
|
|
duration: Dimens.durationS,
|
|
scale: _isPressed ? 0.9 : 1.0,
|
|
child: FilledCircle(
|
|
color: Theme.of(context).colorScheme.onSurface,
|
|
size: widget.size - Dimens.grid16,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|