refactor : base page
This commit is contained in:
@@ -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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -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: [
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user