Added animation to 'Add' button in 'Add location' screen

This commit is contained in:
ashilkn 2023-04-07 13:07:47 +05:30
parent cb2d791472
commit 3875d5befb
2 changed files with 18 additions and 15 deletions

View file

@ -125,17 +125,21 @@ class _AddLocationSheetState extends State<AddLocationSheet> {
ValueListenableBuilder(
valueListenable: _isEmptyNotifier,
builder: (context, bool value, _) {
return ButtonWidget(
buttonType: ButtonType.secondary,
buttonSize: ButtonSize.small,
labelText: "Add",
isDisabled: value,
onTap: () async {
_focusNode.unfocus();
await _addLocationTag(
_textEditingController.text.trim(),
);
},
return AnimatedSwitcher(
duration: const Duration(milliseconds: 250),
switchInCurve: Curves.easeInOut,
switchOutCurve: Curves.easeInOut,
child: ButtonWidget(
key: ValueKey(value),
buttonType: ButtonType.secondary,
buttonSize: ButtonSize.small,
labelText: "Add",
isDisabled: value,
onTap: () async {
_focusNode.unfocus();
await _addLocationTag();
},
),
);
},
)
@ -221,16 +225,15 @@ class _AddLocationSheetState extends State<AddLocationSheet> {
);
}
Future<void> _addLocationTag(String locationName) async {
Future<void> _addLocationTag() async {
final locationData = InheritedLocationTagData.of(context);
final coordinates = locationData.centerPoint;
final radius = radiusValues[locationData.selectedRadiusIndex];
await LocationService.instance.addLocation(
locationName,
_textEditingController.text.trim(),
coordinates,
radius,
);
Navigator.pop(context);
}
void _focusNodeListener() {

View file

@ -240,7 +240,7 @@ class _EditLocationSheetState extends State<EditLocationSheet> {
LocationService.instance.updateLocationTag(
locationTagEntity: locationTagState.locationTagEntity!,
newRadius: radiusValues[locationTagState.selectedRadiusIndex],
newName: _textEditingController.text,
newName: _textEditingController.text.trim(),
);
Navigator.of(context).pop();
}