Merge branch 'feature/scrolled_bottom_navigation' into develop
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
import 'package:rasadyar_core/data/utils.dart';
|
||||
|
||||
import 'logic.dart';
|
||||
|
||||
@@ -11,48 +12,40 @@ class RootPage extends GetView<RootLogic> {
|
||||
return Scaffold(
|
||||
body: Stack(
|
||||
children: [
|
||||
ObxValue(
|
||||
(currentIndex) => IndexedStack(
|
||||
index: currentIndex.value,
|
||||
children: controller.pages,
|
||||
),
|
||||
controller.currentIndex,
|
||||
),
|
||||
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: ObxValue(
|
||||
(index) => BottomNavigation1(
|
||||
items: [
|
||||
BottomNavigation1Item(
|
||||
icon: Assets.vecMapSvg,
|
||||
label: 'نقشه',
|
||||
isSelected: controller.currentIndex.value == 0,
|
||||
onTap: () {
|
||||
controller.changePage(0);
|
||||
},
|
||||
),
|
||||
BottomNavigation1Item(
|
||||
icon: Assets.vecSettingSvg,
|
||||
label: 'اقدام',
|
||||
isSelected: controller.currentIndex.value == 1,
|
||||
onTap: () {
|
||||
controller.changePage(1);
|
||||
},
|
||||
),
|
||||
BottomNavigation1Item(
|
||||
icon: Assets.vecProfileCircleSvg,
|
||||
label: 'پروفایل',
|
||||
isSelected: controller.currentIndex.value == 2,
|
||||
onTap: () {
|
||||
controller.changePage(2);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
controller.currentIndex,
|
||||
Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: WaveBottomNavigation(
|
||||
items: [
|
||||
WaveBottomNavigationItem(
|
||||
title: 'خانه',
|
||||
icon:Assets.vecMapSvg,
|
||||
),
|
||||
WaveBottomNavigationItem(
|
||||
title: 'عملیات',
|
||||
icon:Assets.vecUserSvg,
|
||||
),
|
||||
WaveBottomNavigationItem(
|
||||
title: 'افزودن',
|
||||
icon:Assets.vecAddSvg,
|
||||
),
|
||||
WaveBottomNavigationItem(
|
||||
title: 'آمار',
|
||||
icon:Assets.vecDiagramSvg,
|
||||
), WaveBottomNavigationItem(
|
||||
title: 'تماس',
|
||||
icon:Assets.vecCallSvg,
|
||||
), WaveBottomNavigationItem(
|
||||
title: 'مکان ',
|
||||
icon:Assets.vecGpsSvg,
|
||||
), WaveBottomNavigationItem(
|
||||
title: 'تاریخ',
|
||||
icon:Assets.vecCalendarSvg,
|
||||
),
|
||||
],
|
||||
onPageChanged: (index) {
|
||||
controller.changePage(index);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
class WaveBottomNavigationItem {
|
||||
final String title;
|
||||
final String icon;
|
||||
|
||||
WaveBottomNavigationItem({required this.title, required this.icon});
|
||||
}
|
||||
|
||||
class WaveBottomNavigation extends StatefulWidget {
|
||||
const WaveBottomNavigation({
|
||||
super.key,
|
||||
required this.items,
|
||||
required this.onPageChanged,
|
||||
});
|
||||
|
||||
final List<WaveBottomNavigationItem> items;
|
||||
final Function(int) onPageChanged;
|
||||
|
||||
@override
|
||||
State<WaveBottomNavigation> createState() => _WaveBottomNavigationState();
|
||||
}
|
||||
|
||||
class _WaveBottomNavigationState extends State<WaveBottomNavigation> {
|
||||
final PageController _controller = PageController(viewportFraction: 0.3);
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
double _calculateScale(double currentPage, int index) {
|
||||
final double distance = (currentPage - index).abs();
|
||||
if (distance >= 1) {
|
||||
return 0.9;
|
||||
} else {
|
||||
return 1.50;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: 68,
|
||||
color: AppColor.blueNormal,
|
||||
clipBehavior: Clip.none,
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: Stack(
|
||||
clipBehavior: Clip.none,
|
||||
alignment: Alignment.center,
|
||||
children: [backgroundWidget(), waveScrolledLists()],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget backgroundWidget() {
|
||||
return Positioned(
|
||||
top: -43,
|
||||
child: Container(
|
||||
width: 90,
|
||||
height: 90,
|
||||
clipBehavior: Clip.none,
|
||||
decoration: ShapeDecoration(
|
||||
color: AppColor.greenNormal,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(200),
|
||||
side: BorderSide(width: 5, color: Colors.white),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget waveScrolledLists() {
|
||||
return PageView.builder(
|
||||
controller: _controller,
|
||||
clipBehavior: Clip.none,
|
||||
onPageChanged: widget.onPageChanged,
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: widget.items.length,
|
||||
physics: const ClampingScrollPhysics(),
|
||||
itemBuilder: (context, index) {
|
||||
final WaveBottomNavigationItem item = widget.items[index];
|
||||
return Center(
|
||||
child: AnimatedBuilder(
|
||||
animation: _controller,
|
||||
builder: (context, child) {
|
||||
double value = 0.0;
|
||||
final scale = _calculateScale(_controller.page ?? 0, index);
|
||||
value = index - (_controller.page ?? 0);
|
||||
value = (value).clamp(-1, 1);
|
||||
double offset = value * 30;
|
||||
if (value.abs() < 0.2 || value.abs() > 0.2) {
|
||||
offset = -7 * (1 - value.abs() * 2);
|
||||
}
|
||||
|
||||
return Transform.scale(
|
||||
scale: scale,
|
||||
child: Transform.translate(
|
||||
offset: Offset(0, offset),
|
||||
child: Column(
|
||||
children: [
|
||||
Tooltip(
|
||||
message: item.title,
|
||||
child: vecWidget(
|
||||
item.icon,
|
||||
color: Colors.white,
|
||||
width: 32,
|
||||
height: 32,
|
||||
),
|
||||
),
|
||||
|
||||
/* Visibility(
|
||||
visible: (_controller.page ?? 0) == index,
|
||||
child: Text(
|
||||
item.title,
|
||||
style: AppFonts.yekan10.copyWith(color: Colors.white),
|
||||
),
|
||||
),*/
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,16 @@
|
||||
export 'vec_widget.dart';
|
||||
export 'app_bar/r_app_bar.dart';
|
||||
export 'bottom_navigation/bottom_navigation_1.dart';
|
||||
export 'bottom_navigation/wave_bottom_navigation.dart';
|
||||
export 'buttons/elevated.dart';
|
||||
export 'buttons/outline_elevated.dart';
|
||||
export 'buttons/outline_elevated_icon.dart';
|
||||
export 'buttons/text_button.dart';
|
||||
export 'captcha/captcha_widget.dart';
|
||||
export 'draggable_bottom_sheet/draggable_bottom_sheet.dart';
|
||||
export 'draggable_bottom_sheet/draggable_bottom_sheet_controller.dart';
|
||||
export 'buttons/outline_elevated_icon.dart';
|
||||
export 'buttons/outline_elevated.dart';
|
||||
export 'buttons/text_button.dart';
|
||||
export 'app_bar/r_app_bar.dart';
|
||||
export 'captcha/captcha_widget.dart';
|
||||
export 'buttons/elevated.dart';
|
||||
export 'inputs/r_input.dart';
|
||||
export 'tabs/new_tab.dart';
|
||||
export 'tabs/tab.dart';
|
||||
export 'pagination/pagination_from_until.dart';
|
||||
export 'pagination/show_more.dart';
|
||||
|
||||
|
||||
|
||||
export 'tabs/new_tab.dart';
|
||||
export 'tabs/tab.dart';
|
||||
export 'vec_widget.dart';
|
||||
|
||||
9
tools/pubspecAll.sh
Normal file
9
tools/pubspecAll.sh
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Navigate to the project root (assuming tools is one level below root)
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
# Find all pubspec.yaml files, print their directories, and run flutter pub get
|
||||
#find . -name "pubspec.yaml" -exec sh -c 'echo "Running flutter pub get in $(dirname {}) 🙂🙂🙂🙂🙂"; cd $(dirname {}) ; flutter pub get' \;
|
||||
|
||||
find . -name "pubspec.yaml" -exec sh -c 'echo "Running flutter pub get in $(dirname {}) ⬆️🆙🆙🆙⬆️"; cd $(dirname {}) ; flutter pub upgrade' \;
|
||||
Reference in New Issue
Block a user