- introPage.dart: Convert fireItems to proper static function closure - mainDrawer.dart: Convert unreadCount int to String for Text widget
67 lines
1.9 KiB
Dart
67 lines
1.9 KiB
Dart
import 'package:comunes_flutter/comunes_flutter.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'colors.dart';
|
|
import 'generated/i18n.dart';
|
|
|
|
typedef SlideCallback = void Function(int distance);
|
|
|
|
class FireDistanceSlider extends StatefulWidget {
|
|
|
|
const FireDistanceSlider({super.key, required this.initialValue, required this.onSlide});
|
|
final int initialValue;
|
|
final SlideCallback onSlide;
|
|
|
|
@override
|
|
_FireDistanceSliderState createState() => _FireDistanceSliderState(
|
|
initialValue: initialValue, onSlide: onSlide);
|
|
}
|
|
|
|
class _FireDistanceSliderState extends State<FireDistanceSlider> {
|
|
|
|
_FireDistanceSliderState({int initialValue = 10, required this.onSlide}) {
|
|
_sliderValue = initialValue;
|
|
}
|
|
late int _sliderValue;
|
|
final SlideCallback onSlide;
|
|
|
|
Widget sizeText(int sliderValue) => Text(
|
|
S.of(context).subscribeToValueAroundThisArea(sliderValue.toString()),
|
|
style: const TextStyle(color: Colors.black87));
|
|
|
|
Widget warningText(int sliderValue) => _sliderValue >= 50
|
|
? Text(S.of(context).warningThisIsAVeryLargeArea,
|
|
style: const TextStyle(color: fires900))
|
|
: const Text('');
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final Slider slider = Slider(
|
|
value: _sliderValue + 0.0,
|
|
activeColor: fires900,
|
|
inactiveColor: Colors.black45,
|
|
min: 1.0,
|
|
max: 100.0,
|
|
divisions: 99,
|
|
label: '$_sliderValue',
|
|
onChanged: (double value) {
|
|
_sliderValue = value.round();
|
|
onSlide(_sliderValue);
|
|
setState(() {});
|
|
},
|
|
);
|
|
return Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: listWithoutNulls(<Widget>[
|
|
const SizedBox(height: 50.0),
|
|
Row(children: <Widget>[slider]),
|
|
// new SizedBox(height: 5.0),
|
|
Column(children: <Widget>[
|
|
sizeText(_sliderValue),
|
|
const SizedBox(height: 5.0),
|
|
warningText(_sliderValue)
|
|
])
|
|
]),
|
|
);
|
|
}
|
|
}
|