feat : module page
This commit is contained in:
@@ -7,38 +7,53 @@ class CardIcon extends StatelessWidget {
|
||||
required this.title,
|
||||
required this.icon,
|
||||
this.onTap,
|
||||
this.titleColor = AppColor.blueNormal,
|
||||
this.titleStyle,
|
||||
this.borderColor = AppColor.blueNormal,
|
||||
this.backgroundColor = Colors.white,
|
||||
this.borderRadius = 8,
|
||||
this.width = 110,
|
||||
this.height = 110,
|
||||
this.borderWidth = 1,
|
||||
});
|
||||
|
||||
final String title;
|
||||
final String icon;
|
||||
final VoidCallback? onTap;
|
||||
final Color titleColor;
|
||||
final TextStyle? titleStyle;
|
||||
|
||||
final Color borderColor;
|
||||
final Color backgroundColor;
|
||||
final double borderRadius;
|
||||
final double borderWidth;
|
||||
|
||||
final double width;
|
||||
final double height;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
child: Card(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
side: const BorderSide(color: AppColor.blueNormal, width: 1),
|
||||
),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
color: Colors.white,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SvgGenImage(icon).svg(width: 50, height: 50),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
title,
|
||||
style: AppFonts.yekan16.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
],
|
||||
),
|
||||
return Container(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
padding: EdgeInsets.fromLTRB(17.w, 10.h, 17.w, 8.h),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(borderRadius.r),
|
||||
color: backgroundColor,
|
||||
border: Border.all(color: borderColor, width: borderWidth.w),
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(child: SvgGenImage(icon).svg(fit: BoxFit.fill)),
|
||||
SizedBox(height: 10.h),
|
||||
Text(
|
||||
title,
|
||||
textAlign: TextAlign.center,
|
||||
style: titleStyle ?? AppFonts.yekan16Bold.copyWith(color: titleColor, height: 1.20),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
45
packages/core/lib/presentation/widget/slider/logic.dart
Normal file
45
packages/core/lib/presentation/widget/slider/logic.dart
Normal file
@@ -0,0 +1,45 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
class SliderLogic extends GetxController with StateMixin<List<String>> {
|
||||
final PageController pageController = PageController(initialPage: 0, viewportFraction: .93);
|
||||
late Timer _timer;
|
||||
late Duration duration;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
|
||||
duration = Duration(seconds: randomInt(8, 18));
|
||||
}
|
||||
|
||||
void _startSliding(int itemCount) {
|
||||
_timer = Timer.periodic(duration, (timer) {
|
||||
if (pageController.hasClients) {
|
||||
int nextPage = pageController.page!.round() + 1;
|
||||
if (nextPage == itemCount) {
|
||||
nextPage = 0;
|
||||
}
|
||||
pageController.animateToPage(
|
||||
nextPage,
|
||||
duration: Duration(milliseconds: 300),
|
||||
curve: Curves.easeIn,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
_timer.cancel();
|
||||
pageController.dispose();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
void onSuccess(List<String> data) {
|
||||
change(data, status: RxStatus.success());
|
||||
_startSliding(data.length);
|
||||
}
|
||||
}
|
||||
2
packages/core/lib/presentation/widget/slider/slider.dart
Normal file
2
packages/core/lib/presentation/widget/slider/slider.dart
Normal file
@@ -0,0 +1,2 @@
|
||||
export 'logic.dart';
|
||||
export 'view.dart';
|
||||
80
packages/core/lib/presentation/widget/slider/view.dart
Normal file
80
packages/core/lib/presentation/widget/slider/view.dart
Normal file
@@ -0,0 +1,80 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
class SliderWidget extends GetView<SliderLogic> {
|
||||
const SliderWidget({super.key, this.height = 210, this.widgetTag});
|
||||
|
||||
final int height;
|
||||
final String? widgetTag;
|
||||
|
||||
@override
|
||||
String? get tag => widgetTag;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
height: height.h,
|
||||
child: controller.obx(
|
||||
(state) => Stack(
|
||||
alignment: AlignmentDirectional.bottomCenter,
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: PageView.builder(
|
||||
controller: controller.pageController,
|
||||
itemCount: state?.length ?? 0,
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemBuilder: (context, index) {
|
||||
String? image = state?[index];
|
||||
return Container(
|
||||
height: height.h,
|
||||
margin: EdgeInsets.symmetric(horizontal: 6.w),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(8.r),
|
||||
image: DecorationImage(fit: BoxFit.fill, image: NetworkImage(image ?? '')),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: (state?.length ?? 0) > 1,
|
||||
child: Positioned(
|
||||
bottom: 5,
|
||||
child: Container(
|
||||
height: 13.36,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
margin: const EdgeInsets.symmetric(vertical: 12),
|
||||
decoration: ShapeDecoration(
|
||||
color: Colors.white38,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(9999)),
|
||||
),
|
||||
child: SmoothPageIndicator(
|
||||
controller: controller.pageController, // PageController
|
||||
count: state?.length ?? 0,
|
||||
effect: const WormEffect(
|
||||
dotWidth: 6.0,
|
||||
dotHeight: 6.0,
|
||||
activeDotColor: Colors.white,
|
||||
dotColor: Colors.white38,
|
||||
), // your preferred effect
|
||||
onDotClicked: (index) {
|
||||
controller.pageController.animateToPage(
|
||||
index,
|
||||
duration: const Duration(milliseconds: 500),
|
||||
curve: Curves.easeIn,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
onLoading: const Center(child: CupertinoActivityIndicator(color: AppColor.blueNormal)),
|
||||
onError: (error) => Center(child: Text('خطا در بارگذاری اسلایدر: $error')),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -32,3 +32,4 @@ export 'tabs/new_tab.dart';
|
||||
export 'tabs/r_segment.dart';
|
||||
export 'tabs/tab.dart';
|
||||
export 'vec_widget.dart';
|
||||
export 'slider/slider.dart';
|
||||
Reference in New Issue
Block a user