-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: replace state management library (#4)
- Loading branch information
Showing
61 changed files
with
2,051 additions
and
1,502 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// Copyright 2023 BBK Development. All rights reserved. | ||
// Use of this source code is governed by a GPL-style license that can be found | ||
// in the LICENSE file. | ||
|
||
import 'package:flutter/material.dart'; | ||
|
||
class AnimatedControlButtonController { | ||
late void Function() forward; | ||
late void Function() reverse; | ||
} | ||
|
||
class AnimatedControlButton extends StatefulWidget { | ||
const AnimatedControlButton({ | ||
required this.controller, | ||
this.onTap, | ||
this.size = 32.0, | ||
super.key, | ||
}); | ||
|
||
final AnimatedControlButtonController controller; | ||
final void Function()? onTap; | ||
final double size; | ||
|
||
@override | ||
State<AnimatedControlButton> createState() => _AnimatedControlButtonState(); | ||
} | ||
|
||
class _AnimatedControlButtonState extends State<AnimatedControlButton> | ||
with TickerProviderStateMixin { | ||
late final AnimationController controller; | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
controller = AnimationController( | ||
duration: const Duration(milliseconds: 500), | ||
vsync: this, | ||
); | ||
initController(); | ||
} | ||
|
||
@override | ||
void dispose() { | ||
controller.dispose(); | ||
super.dispose(); | ||
} | ||
|
||
void initController() { | ||
widget.controller.forward = () async { | ||
if (mounted) { | ||
await controller.forward(); | ||
} | ||
}; | ||
|
||
widget.controller.reverse = () async { | ||
if (mounted) { | ||
await controller.reverse(); | ||
} | ||
}; | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return GestureDetector( | ||
onTap: widget.onTap, | ||
child: Container( | ||
height: MediaQuery.of(context).size.width * 0.12, | ||
width: MediaQuery.of(context).size.width * 0.12, | ||
decoration: BoxDecoration( | ||
shape: BoxShape.circle, | ||
color: Theme.of(context).focusColor, | ||
), | ||
child: Center( | ||
child: AnimatedIcon( | ||
icon: AnimatedIcons.play_pause, | ||
progress: controller, | ||
size: widget.size, | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.