refactor : base page

This commit is contained in:
2025-09-25 17:25:55 +03:30
parent fd9de4f80c
commit 5ac8342bb3
30 changed files with 471 additions and 455 deletions

View File

@@ -1,3 +1,4 @@
description: This file stores settings for Dart & Flutter DevTools.
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
extensions:
- hive_ce: true

View File

@@ -13,7 +13,9 @@ class BasePage extends GetView<BaseLogic> {
this.floatingActionButton,
this.appBar,
this.backGroundWidget,
}) ;
this.onPopScopTaped,
this.backId,
});
final List<String>? routes;
final Breadcrumb? routesWidget;
@@ -24,6 +26,8 @@ class BasePage extends GetView<BaseLogic> {
final BackGroundWidget? backGroundWidget;
final FloatingActionButtonLocation? floatingActionButtonLocation;
final Widget? floatingActionButton;
final VoidCallback? onPopScopTaped;
final int? backId;
Widget _buildHeader() {
return Column(
@@ -36,7 +40,11 @@ class BasePage extends GetView<BaseLogic> {
}
Widget _buildBody() {
final content = [_buildHeader(), if (child != null) Expanded(child: child!), ...?widgets];
final content = [
if (routes != null || routesWidget != null) _buildHeader(),
if (child != null) Expanded(child: child!),
...?widgets,
];
if (scrollable) {
if (backGroundWidget != null) {
@@ -61,7 +69,7 @@ class BasePage extends GetView<BaseLogic> {
if (backGroundWidget != null) {
return Stack(
children: [
?backGroundWidget,
Positioned.fill(child: backGroundWidget!),
Column(children: content),
],
);
@@ -71,18 +79,12 @@ class BasePage extends GetView<BaseLogic> {
@override
Widget build(BuildContext context) {
return PopScope(
canPop: false,
onPopInvokedWithResult: (didPop, result) {
if (!didPop) appBar?.onBackTap?.call();
},
child: Scaffold(
backgroundColor: AppColor.bgLight,
appBar: appBar,
body: _buildBody(),
floatingActionButtonLocation: floatingActionButtonLocation,
floatingActionButton: floatingActionButton,
),
return Scaffold(
backgroundColor: AppColor.bgLight,
appBar: appBar,
body: _buildBody(),
floatingActionButtonLocation: floatingActionButtonLocation,
floatingActionButton: floatingActionButton,
);
}
}

View File

@@ -1,12 +1,9 @@
import 'package:flutter/material.dart';
import 'package:rasadyar_core/presentation/common/assets.gen.dart';
import '../../../../core.dart';
class BackGroundWidget extends StatelessWidget {
const BackGroundWidget({
super.key,
required this.gradient,
required this.vecPath,
});
const BackGroundWidget({super.key, required this.gradient, required this.vecPath});
final Gradient gradient;
final String vecPath;
@@ -14,10 +11,10 @@ class BackGroundWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
width: Get.width,
height: Get.height,
decoration: BoxDecoration(gradient: gradient),
child: SvgGenImage.vec(vecPath).svg(fit: BoxFit.cover),
);
}
}

View File

@@ -1,3 +1,5 @@
import 'dart:developer';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:rasadyar_core/core.dart';
@@ -65,8 +67,7 @@ class RAppBar extends StatelessWidget implements PreferredSizeWidget {
children: [
if (children != null) ...children!,
if (hasNews || hasBack || hasSearch || hasNotification || hasFilter)
const Spacer(),
if (hasNews || hasBack || hasSearch || hasNotification || hasFilter) const Spacer(),
if (hasNews)
GestureDetector(
@@ -79,26 +80,23 @@ class RAppBar extends StatelessWidget implements PreferredSizeWidget {
if (hasNews) SizedBox(width: 8.w),
if (hasNotification)
Badge.count(
count: 2,
child: Icon(CupertinoIcons.bell_fill, color: Colors.white),
),
Badge.count(count: 2, child: Icon(CupertinoIcons.bell_fill, color: Colors.white)),
if (hasNotification) SizedBox(width: 8.w),
if (hasFilter)
GestureDetector(
onTap: onFilterTap,
child: Assets.vec.filterSvg.svg(
width: 24.w,
height: 24.h,
colorFilter: ColorFilter.mode(Colors.white, BlendMode.srcIn),
if (!isBase) ...{
if (hasFilter)
GestureDetector(
onTap: onFilterTap,
child: Assets.vec.filterSvg.svg(
width: 24.w,
height: 24.h,
colorFilter: ColorFilter.mode(Colors.white, BlendMode.srcIn),
),
),
),
if (hasBack) SizedBox(width: 8.w),
if (hasSearch) SearchWidget(),
if (hasSearch) SizedBox(width: 8.w),
if (hasBack) SizedBox(width: 8.w),
if (hasSearch) SearchWidget(),
if (hasSearch) SizedBox(width: 8.w),
},
if (hasBack)
GestureDetector(
onTap: onBackTap ?? () => Get.back(id: backId),
@@ -120,8 +118,7 @@ class RAppBar extends StatelessWidget implements PreferredSizeWidget {
}
@override
Size get preferredSize =>
Size.fromHeight(kToolbarHeight + (bottom?.preferredSize.height ?? 0));
Size get preferredSize => Size.fromHeight(kToolbarHeight + (bottom?.preferredSize.height ?? 0));
MainAxisAlignment _getMainAxisAlignment() {
if (centerTitle) {
@@ -173,21 +170,15 @@ class RAppBar2 extends StatelessWidget implements PreferredSizeWidget {
excludeHeaderSemantics: true,
scrolledUnderElevation: 0,
centerTitle: centerTitle,
titleTextStyle:
titleTextStyle ?? AppFonts.yekan16.copyWith(color: Colors.white),
titleTextStyle: titleTextStyle ?? AppFonts.yekan16.copyWith(color: Colors.white),
title: Row(
children: [
if (leading != null) ...{
Padding(padding: const EdgeInsets.only(right: 6), child: leading),
},
if (title != null) ...[
Text(title!),
if (iconTitle != null) const SizedBox(width: 8),
],
if (title != null) ...[Text(title!), if (iconTitle != null) const SizedBox(width: 8)],
if (iconTitle != null) ...{const SizedBox(width: 8)},
if (iconTitle != null) ...{
SvgGenImage.vec(iconTitle!).svg(width: 24, height: 24),
},
if (iconTitle != null) ...{SvgGenImage.vec(iconTitle!).svg(width: 24, height: 24)},
],
),
titleSpacing: 8,
@@ -201,10 +192,7 @@ class RAppBar2 extends StatelessWidget implements PreferredSizeWidget {
child: Assets.vec.arrowLeftSvg.svg(
width: 24.w,
height: 24.h,
colorFilter: ColorFilter.mode(
iconColor ?? Colors.white,
BlendMode.srcIn,
),
colorFilter: ColorFilter.mode(iconColor ?? Colors.white, BlendMode.srcIn),
),
),
),

View File

@@ -130,7 +130,9 @@ class InformationTag extends StatelessWidget {
Widget build(BuildContext context) {
return Container(
height: (data.height ?? 82).h,
decoration: BoxDecoration(borderRadius: BorderRadius.circular(8)),
decoration: BoxDecoration(
border: Border.all(color: const Color(0xFFA9A9A9) ,width:0.50),
borderRadius: BorderRadius.circular(8)),
clipBehavior: Clip.hardEdge,
child: Row(
children: [

View File

@@ -2,23 +2,49 @@ import 'package:flutter/material.dart';
import 'package:rasadyar_core/core.dart';
class LogoWidget extends StatelessWidget {
const LogoWidget({super.key, this.title});
final String? title ;
const LogoWidget({
super.key,
this.title,
this.height,
this.width,
this.vecPath,
this.svgPath,
this.imagePath,
this.titleStyle,
});
final String? title;
final String? vecPath;
final String? svgPath;
final String? imagePath;
final num? width;
final num? height;
final TextStyle? titleStyle;
@override
Widget build(BuildContext context) {
return Column(
children: [
Row(),
Assets.images.innerSplash.image(
width: 120.w,
height: 120.h,
),
buildLogo(),
SizedBox(height: 8.h),
Text(
title??'سامانه رصدیار',
style: AppFonts.yekan16.copyWith(color: AppColor.darkGreyNormal),
title ?? 'سامانه رصدیار',
style:titleStyle?? AppFonts.yekan16.copyWith(color: AppColor.darkGreyNormal),
),
],
);
}
Widget buildLogo() {
if (vecPath != null) {
return SvgGenImage.vec(vecPath!).svg(width: width?.w ?? 120.w, height: height?.h ?? 120.h);
} else if (svgPath != null) {
return SvgGenImage(vecPath!).svg(width: width?.w ?? 120.w, height: height?.h ?? 120.h);
} else if (imagePath != null) {
return AssetGenImage(imagePath!).image(width: width?.w ?? 120.w, height: height?.h ?? 120.h);
} else {
return Assets.images.innerSplash.image(width: 120.w, height: 120.h);
}
}
}

View File

@@ -333,10 +333,10 @@ packages:
dependency: "direct main"
description:
name: device_preview_plus
sha256: "45f9154c3213e470df1aa54326757ccf3cc6fb1f04396bced6ad1a7bfc9d6400"
sha256: "2ebe9cf25ed46875c9c1b745d0438df9e4c49f7bcf9ea466c88efbcffcc73ab7"
url: "https://pub.dev"
source: hosted
version: "2.5.0"
version: "2.5.1"
dio:
dependency: "direct main"
description:
@@ -1852,4 +1852,4 @@ packages:
version: "2.1.0"
sdks:
dart: ">=3.9.2 <4.0.0"
flutter: ">=3.35.3"
flutter: ">=3.35.4"

View File

@@ -4,7 +4,7 @@ publish_to: none
version: 1.2.0+2
environment:
sdk: ^3.9.0
sdk: ^3.9.2
dependencies:
flutter: