feat : home page chicken-Steward
This commit is contained in:
@@ -9,21 +9,24 @@ class WaveBottomNavigationItem {
|
||||
}
|
||||
|
||||
class WaveBottomNavigation extends StatefulWidget {
|
||||
const WaveBottomNavigation({
|
||||
super.key,
|
||||
required this.items,
|
||||
required this.onPageChanged,
|
||||
});
|
||||
const WaveBottomNavigation({super.key, this.initPage = 0, required this.items, required this.onPageChanged});
|
||||
|
||||
final List<WaveBottomNavigationItem> items;
|
||||
final Function(int) onPageChanged;
|
||||
final int initPage;
|
||||
|
||||
@override
|
||||
State<WaveBottomNavigation> createState() => _WaveBottomNavigationState();
|
||||
}
|
||||
|
||||
class _WaveBottomNavigationState extends State<WaveBottomNavigation> {
|
||||
final PageController _controller = PageController(viewportFraction: 0.3);
|
||||
late PageController _controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = PageController(viewportFraction: 0.3, initialPage: widget.initPage);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
@@ -85,19 +88,15 @@ class _WaveBottomNavigationState extends State<WaveBottomNavigation> {
|
||||
final WaveBottomNavigationItem item = widget.items[index];
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
_controller.animateToPage(
|
||||
index,
|
||||
duration: Duration(milliseconds: 500),
|
||||
curve: Curves.easeInOut,
|
||||
);
|
||||
_controller.animateToPage(index, duration: Duration(milliseconds: 500), curve: Curves.easeInOut);
|
||||
},
|
||||
child: Center(
|
||||
child: AnimatedBuilder(
|
||||
animation: _controller,
|
||||
builder: (context, child) {
|
||||
double value = 0.0;
|
||||
final scale = _calculateScale(_controller.page ?? 0, index);
|
||||
value = index - (_controller.page ?? 0);
|
||||
final scale = _calculateScale(_controller.page ?? _controller.initialPage.toDouble() ?? 0.0, index);
|
||||
value = index - (_controller.page ?? _controller.initialPage.toDouble() ?? 0.0);
|
||||
value = (value).clamp(-1, 1);
|
||||
double offset = value * 30;
|
||||
if (value.abs() < 0.2 || value.abs() > 0.2) {
|
||||
@@ -110,10 +109,7 @@ class _WaveBottomNavigationState extends State<WaveBottomNavigation> {
|
||||
offset: Offset(0, offset),
|
||||
child: Column(
|
||||
children: [
|
||||
Tooltip(
|
||||
message: item.title,
|
||||
child: item.icon
|
||||
),
|
||||
Tooltip(message: item.title, child: item.icon),
|
||||
|
||||
/* Visibility(
|
||||
visible: (_controller.page ?? 0) == index,
|
||||
|
||||
Reference in New Issue
Block a user