feat : module page

This commit is contained in:
2025-08-27 11:56:29 +03:30
parent 5ffda97e54
commit d3e5ab7d61
31 changed files with 1313 additions and 93 deletions

View File

@@ -1,16 +1,18 @@
import 'package:flutter/material.dart';
import 'package:rasadyar_core/core.dart';
import 'package:rasadyar_core/data/model/local/user_local/user_local_model.dart';
import 'package:flutter/material.dart';
part 'module_model.freezed.dart';
@freezed
abstract class ModuleModel with _$ModuleModel{
const factory ModuleModel({
factory ModuleModel({
required String title,
required String icon,
required Module module,
required Color borderColor,
required Color backgroundColor,
required Color titleColor,
Module? module,
}) = _ModuleModel;
}

View File

@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
/// @nodoc
mixin _$ModuleModel {
String get title; String get icon; Module get module;
String get title; String get icon; Color get borderColor; Color get backgroundColor; Color get titleColor; Module? get module;
/// Create a copy of ModuleModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@@ -25,16 +25,16 @@ $ModuleModelCopyWith<ModuleModel> get copyWith => _$ModuleModelCopyWithImpl<Modu
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is ModuleModel&&(identical(other.title, title) || other.title == title)&&(identical(other.icon, icon) || other.icon == icon)&&(identical(other.module, module) || other.module == module));
return identical(this, other) || (other.runtimeType == runtimeType&&other is ModuleModel&&(identical(other.title, title) || other.title == title)&&(identical(other.icon, icon) || other.icon == icon)&&(identical(other.borderColor, borderColor) || other.borderColor == borderColor)&&(identical(other.backgroundColor, backgroundColor) || other.backgroundColor == backgroundColor)&&(identical(other.titleColor, titleColor) || other.titleColor == titleColor)&&(identical(other.module, module) || other.module == module));
}
@override
int get hashCode => Object.hash(runtimeType,title,icon,module);
int get hashCode => Object.hash(runtimeType,title,icon,borderColor,backgroundColor,titleColor,module);
@override
String toString() {
return 'ModuleModel(title: $title, icon: $icon, module: $module)';
return 'ModuleModel(title: $title, icon: $icon, borderColor: $borderColor, backgroundColor: $backgroundColor, titleColor: $titleColor, module: $module)';
}
@@ -45,7 +45,7 @@ abstract mixin class $ModuleModelCopyWith<$Res> {
factory $ModuleModelCopyWith(ModuleModel value, $Res Function(ModuleModel) _then) = _$ModuleModelCopyWithImpl;
@useResult
$Res call({
String title, String icon, Module module
String title, String icon, Color borderColor, Color backgroundColor, Color titleColor, Module? module
});
@@ -62,12 +62,15 @@ class _$ModuleModelCopyWithImpl<$Res>
/// Create a copy of ModuleModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? title = null,Object? icon = null,Object? module = null,}) {
@pragma('vm:prefer-inline') @override $Res call({Object? title = null,Object? icon = null,Object? borderColor = null,Object? backgroundColor = null,Object? titleColor = null,Object? module = freezed,}) {
return _then(_self.copyWith(
title: null == title ? _self.title : title // ignore: cast_nullable_to_non_nullable
as String,icon: null == icon ? _self.icon : icon // ignore: cast_nullable_to_non_nullable
as String,module: null == module ? _self.module : module // ignore: cast_nullable_to_non_nullable
as Module,
as String,borderColor: null == borderColor ? _self.borderColor : borderColor // ignore: cast_nullable_to_non_nullable
as Color,backgroundColor: null == backgroundColor ? _self.backgroundColor : backgroundColor // ignore: cast_nullable_to_non_nullable
as Color,titleColor: null == titleColor ? _self.titleColor : titleColor // ignore: cast_nullable_to_non_nullable
as Color,module: freezed == module ? _self.module : module // ignore: cast_nullable_to_non_nullable
as Module?,
));
}
@@ -152,10 +155,10 @@ return $default(_that);case _:
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String title, String icon, Module module)? $default,{required TResult orElse(),}) {final _that = this;
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String title, String icon, Color borderColor, Color backgroundColor, Color titleColor, Module? module)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _ModuleModel() when $default != null:
return $default(_that.title,_that.icon,_that.module);case _:
return $default(_that.title,_that.icon,_that.borderColor,_that.backgroundColor,_that.titleColor,_that.module);case _:
return orElse();
}
@@ -173,10 +176,10 @@ return $default(_that.title,_that.icon,_that.module);case _:
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String title, String icon, Module module) $default,) {final _that = this;
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String title, String icon, Color borderColor, Color backgroundColor, Color titleColor, Module? module) $default,) {final _that = this;
switch (_that) {
case _ModuleModel():
return $default(_that.title,_that.icon,_that.module);case _:
return $default(_that.title,_that.icon,_that.borderColor,_that.backgroundColor,_that.titleColor,_that.module);case _:
throw StateError('Unexpected subclass');
}
@@ -193,10 +196,10 @@ return $default(_that.title,_that.icon,_that.module);case _:
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String title, String icon, Module module)? $default,) {final _that = this;
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String title, String icon, Color borderColor, Color backgroundColor, Color titleColor, Module? module)? $default,) {final _that = this;
switch (_that) {
case _ModuleModel() when $default != null:
return $default(_that.title,_that.icon,_that.module);case _:
return $default(_that.title,_that.icon,_that.borderColor,_that.backgroundColor,_that.titleColor,_that.module);case _:
return null;
}
@@ -208,12 +211,15 @@ return $default(_that.title,_that.icon,_that.module);case _:
class _ModuleModel implements ModuleModel {
const _ModuleModel({required this.title, required this.icon, required this.module});
_ModuleModel({required this.title, required this.icon, required this.borderColor, required this.backgroundColor, required this.titleColor, this.module});
@override final String title;
@override final String icon;
@override final Module module;
@override final Color borderColor;
@override final Color backgroundColor;
@override final Color titleColor;
@override final Module? module;
/// Create a copy of ModuleModel
/// with the given fields replaced by the non-null parameter values.
@@ -225,16 +231,16 @@ _$ModuleModelCopyWith<_ModuleModel> get copyWith => __$ModuleModelCopyWithImpl<_
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ModuleModel&&(identical(other.title, title) || other.title == title)&&(identical(other.icon, icon) || other.icon == icon)&&(identical(other.module, module) || other.module == module));
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ModuleModel&&(identical(other.title, title) || other.title == title)&&(identical(other.icon, icon) || other.icon == icon)&&(identical(other.borderColor, borderColor) || other.borderColor == borderColor)&&(identical(other.backgroundColor, backgroundColor) || other.backgroundColor == backgroundColor)&&(identical(other.titleColor, titleColor) || other.titleColor == titleColor)&&(identical(other.module, module) || other.module == module));
}
@override
int get hashCode => Object.hash(runtimeType,title,icon,module);
int get hashCode => Object.hash(runtimeType,title,icon,borderColor,backgroundColor,titleColor,module);
@override
String toString() {
return 'ModuleModel(title: $title, icon: $icon, module: $module)';
return 'ModuleModel(title: $title, icon: $icon, borderColor: $borderColor, backgroundColor: $backgroundColor, titleColor: $titleColor, module: $module)';
}
@@ -245,7 +251,7 @@ abstract mixin class _$ModuleModelCopyWith<$Res> implements $ModuleModelCopyWith
factory _$ModuleModelCopyWith(_ModuleModel value, $Res Function(_ModuleModel) _then) = __$ModuleModelCopyWithImpl;
@override @useResult
$Res call({
String title, String icon, Module module
String title, String icon, Color borderColor, Color backgroundColor, Color titleColor, Module? module
});
@@ -262,12 +268,15 @@ class __$ModuleModelCopyWithImpl<$Res>
/// Create a copy of ModuleModel
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? title = null,Object? icon = null,Object? module = null,}) {
@override @pragma('vm:prefer-inline') $Res call({Object? title = null,Object? icon = null,Object? borderColor = null,Object? backgroundColor = null,Object? titleColor = null,Object? module = freezed,}) {
return _then(_ModuleModel(
title: null == title ? _self.title : title // ignore: cast_nullable_to_non_nullable
as String,icon: null == icon ? _self.icon : icon // ignore: cast_nullable_to_non_nullable
as String,module: null == module ? _self.module : module // ignore: cast_nullable_to_non_nullable
as Module,
as String,borderColor: null == borderColor ? _self.borderColor : borderColor // ignore: cast_nullable_to_non_nullable
as Color,backgroundColor: null == backgroundColor ? _self.backgroundColor : backgroundColor // ignore: cast_nullable_to_non_nullable
as Color,titleColor: null == titleColor ? _self.titleColor : titleColor // ignore: cast_nullable_to_non_nullable
as Color,module: freezed == module ? _self.module : module // ignore: cast_nullable_to_non_nullable
as Module?,
));
}

View File

@@ -11,9 +11,8 @@ Future<void> setupAllCoreProvider() async {
diCore.registerSingleton(NetworkStatus()..startListening());
//max 500MB Map Cashing
await diCore.registerSingleton(
FMTCObjectBoxBackend().initialise(maxDatabaseSize: 500 * 1024 * 1024),
);
await FMTCObjectBoxBackend().initialise();

View File

@@ -166,6 +166,15 @@ class AppFonts {
height: _height,
);
static TextStyle yekan18Bold = TextStyle(
fontFamily: yekan,
fontWeight: bold, // Use bold weight
fontSize: 18.sp,
height: _height,
);
static TextStyle yekan16Bold = TextStyle(
// Base size bold
fontFamily: yekan,

View File

@@ -211,6 +211,24 @@ class $AssetsIconsGen {
/// File path: assets/icons/profile_user.svg
SvgGenImage get profileUser => const SvgGenImage('assets/icons/profile_user.svg');
/// File path: assets/icons/rasad_ban.svg
SvgGenImage get rasadBan => const SvgGenImage('assets/icons/rasad_ban.svg');
/// File path: assets/icons/rasad_bar.svg
SvgGenImage get rasadBar => const SvgGenImage('assets/icons/rasad_bar.svg');
/// File path: assets/icons/rasad_bot.svg
SvgGenImage get rasadBot => const SvgGenImage('assets/icons/rasad_bot.svg');
/// File path: assets/icons/rasad_dam.svg
SvgGenImage get rasadDam => const SvgGenImage('assets/icons/rasad_dam.svg');
/// File path: assets/icons/rasad_nan.svg
SvgGenImage get rasadNan => const SvgGenImage('assets/icons/rasad_nan.svg');
/// File path: assets/icons/rasad_toyor.svg
SvgGenImage get rasadToyor => const SvgGenImage('assets/icons/rasad_toyor.svg');
/// File path: assets/icons/receipt_discount.svg
SvgGenImage get receiptDiscount => const SvgGenImage('assets/icons/receipt_discount.svg');
@@ -339,6 +357,12 @@ class $AssetsIconsGen {
profile2Outline,
profileCircle,
profileUser,
rasadBan,
rasadBar,
rasadBot,
rasadDam,
rasadNan,
rasadToyor,
receiptDiscount,
sale,
scan,
@@ -576,6 +600,24 @@ class $AssetsVecGen {
/// File path: assets/vec/profile_user.svg.vec
SvgGenImage get profileUserSvg => const SvgGenImage.vec('assets/vec/profile_user.svg.vec');
/// File path: assets/vec/rasad_ban.svg.vec
SvgGenImage get rasadBanSvg => const SvgGenImage.vec('assets/vec/rasad_ban.svg.vec');
/// File path: assets/vec/rasad_bar.svg.vec
SvgGenImage get rasadBarSvg => const SvgGenImage.vec('assets/vec/rasad_bar.svg.vec');
/// File path: assets/vec/rasad_bot.svg.vec
SvgGenImage get rasadBotSvg => const SvgGenImage.vec('assets/vec/rasad_bot.svg.vec');
/// File path: assets/vec/rasad_dam.svg.vec
SvgGenImage get rasadDamSvg => const SvgGenImage.vec('assets/vec/rasad_dam.svg.vec');
/// File path: assets/vec/rasad_nan.svg.vec
SvgGenImage get rasadNanSvg => const SvgGenImage.vec('assets/vec/rasad_nan.svg.vec');
/// File path: assets/vec/rasad_toyor.svg.vec
SvgGenImage get rasadToyorSvg => const SvgGenImage.vec('assets/vec/rasad_toyor.svg.vec');
/// File path: assets/vec/receipt_discount.svg.vec
SvgGenImage get receiptDiscountSvg => const SvgGenImage.vec('assets/vec/receipt_discount.svg.vec');
@@ -704,6 +746,12 @@ class $AssetsVecGen {
profile2OutlineSvg,
profileCircleSvg,
profileUserSvg,
rasadBanSvg,
rasadBarSvg,
rasadBotSvg,
rasadDamSvg,
rasadNanSvg,
rasadToyorSvg,
receiptDiscountSvg,
saleSvg,
scanSvg,

View File

@@ -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),
),
],
),
),
);

View 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);
}
}

View File

@@ -0,0 +1,2 @@
export 'logic.dart';
export 'view.dart';

View 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')),
),
);
}
}

View File

@@ -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';

View File

@@ -0,0 +1,13 @@
import 'dart:math';
final _random = Random();
int randomInt(int min, int max) {
return min + _random.nextInt(max - min + 1);
}
double randomDouble(double min, double max) {
return min + _random.nextDouble() * (max - min);
}

View File

@@ -11,3 +11,4 @@ export 'network/network.dart';
export 'parser.dart';
export 'route_utils.dart';
export 'separator_input_formatter.dart';
export 'number_utils.dart';