feat: actions and map page

This commit is contained in:
2025-05-21 14:43:26 +03:30
parent b5406a00a0
commit 1ed8e69262
19 changed files with 586 additions and 33 deletions

6
assets/icons/search.svg Normal file
View File

@@ -0,0 +1,6 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M7.33333 12.6667C10.2789 12.6667 12.6667 10.2789 12.6667 7.33333C12.6667 4.38781 10.2789 2 7.33333 2C4.38781 2 2 4.38781 2 7.33333C2 10.2789 4.38781 12.6667 7.33333 12.6667Z"
stroke="#FFFFFF" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M14.0001 13.9996L11.1001 11.0996" stroke="#FFFFFF" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 524 B

BIN
assets/vec/search.svg.vec Normal file

Binary file not shown.

View File

@@ -0,0 +1,43 @@
///This file is automatically generated. DO NOT EDIT, all your changes would be lost.
class Assets {
Assets._();
static const String iconsAdd = 'assets/icons/add.svg';
static const String iconsArrowLeft = 'assets/icons/arrow_left.svg';
static const String iconsArrowRight = 'assets/icons/arrow_right.svg';
static const String iconsBgHeaderUserProfile = 'assets/icons/bg_header_user_profile.svg';
static const String iconsCalendar = 'assets/icons/calendar.svg';
static const String iconsCalendarSearch = 'assets/icons/calendar_search.svg';
static const String iconsCall = 'assets/icons/call.svg';
static const String iconsDiagram = 'assets/icons/diagram.svg';
static const String iconsDownload = 'assets/icons/download.svg';
static const String iconsEdit = 'assets/icons/edit.svg';
static const String iconsExcelDownload = 'assets/icons/excel_download.svg';
static const String iconsFilter = 'assets/icons/filter.svg';
static const String iconsGps = 'assets/icons/gps.svg';
static const String iconsInformation = 'assets/icons/information.svg';
static const String iconsInspection = 'assets/icons/inspection.svg';
static const String iconsKey = 'assets/icons/key.svg';
static const String iconsLiveStock = 'assets/icons/liveStock.svg';
static const String iconsLogout = 'assets/icons/logout.svg';
static const String iconsMap = 'assets/icons/map.svg';
static const String iconsMapMarker = 'assets/icons/map_marker.svg';
static const String iconsMessageAdd = 'assets/icons/message_add.svg';
static const String iconsPdfDownload = 'assets/icons/pdf_download.svg';
static const String iconsPictureFrame = 'assets/icons/picture_frame.svg';
static const String iconsProfileCircle = 'assets/icons/profile_circle.svg';
static const String iconsProfileUser = 'assets/icons/profile_user.svg';
static const String iconsReceiptDiscount = 'assets/icons/receipt_discount.svg';
static const String iconsScan = 'assets/icons/scan.svg';
static const String iconsScanBarcode = 'assets/icons/scan_barcode.svg';
static const String iconsSearch = 'assets/icons/search.svg';
static const String iconsSecurityTime = 'assets/icons/security_time.svg';
static const String iconsSetting = 'assets/icons/setting.svg';
static const String iconsTagUser = 'assets/icons/tag_user.svg';
static const String iconsTrash = 'assets/icons/trash.svg';
static const String iconsUser = 'assets/icons/user.svg';
static const String iconsUserSquare = 'assets/icons/user_square.svg';
static const String imagesInnerSplash = 'assets/images/inner_splash.webp';
static const String imagesOutterSplash = 'assets/images/outter_splash.webp';
}

View File

@@ -26,7 +26,7 @@ export 'infrastructure/local/hive_local_storage.dart';
//export 'package:encrypt/encrypt.dart' show Encrypted;
//Map and location
export 'package:latlong2/latlong.dart';
export 'package:latlong2/latlong.dart' ;
export 'package:persian_datetime_picker/persian_datetime_picker.dart';
export 'package:rasadyar_core/presentation/common/common.dart';
export 'package:rasadyar_core/presentation/utils/utils.dart';

View File

@@ -107,6 +107,15 @@ class AppFonts {
height: _height,
);
static const TextStyle yekan8= TextStyle(
// Rounded from 10.24
fontFamily: yekan,
fontWeight: regular,
fontSize: 8,
height: _height,
);
static const TextStyle yekan61Bold = TextStyle(
fontFamily: yekan,
fontWeight: bold, // Use bold weight

View File

@@ -99,6 +99,9 @@ class $AssetsIconsGen {
/// File path: assets/icons/scan_barcode.svg
SvgGenImage get scanBarcode => const SvgGenImage('assets/icons/scan_barcode.svg');
/// File path: assets/icons/search.svg
SvgGenImage get search => const SvgGenImage('assets/icons/search.svg');
/// File path: assets/icons/security_time.svg
SvgGenImage get securityTime => const SvgGenImage('assets/icons/security_time.svg');
@@ -147,6 +150,7 @@ class $AssetsIconsGen {
receiptDiscount,
scan,
scanBarcode,
search,
securityTime,
setting,
tagUser,
@@ -256,6 +260,9 @@ class $AssetsVecGen {
/// File path: assets/vec/scan_barcode.svg.vec
SvgGenImage get scanBarcodeSvg => const SvgGenImage.vec('assets/vec/scan_barcode.svg.vec');
/// File path: assets/vec/search.svg.vec
SvgGenImage get searchSvg => const SvgGenImage.vec('assets/vec/search.svg.vec');
/// File path: assets/vec/security_time.svg.vec
SvgGenImage get securityTimeSvg => const SvgGenImage.vec('assets/vec/security_time.svg.vec');
@@ -304,6 +311,7 @@ class $AssetsVecGen {
receiptDiscountSvg,
scanSvg,
scanBarcodeSvg,
searchSvg,
securityTimeSvg,
settingSvg,
tagUserSvg,

View File

@@ -8,6 +8,8 @@ class RAppBar extends StatelessWidget implements PreferredSizeWidget {
final String title;
final Color backgroundColor;
final Color iconColor;
final bool hasBack;
final bool centerTitle;
final TextStyle? titleTextStyle;
final VoidCallback? onBackPressed;
final List<Widget>? additionalActions;
@@ -22,6 +24,8 @@ class RAppBar extends StatelessWidget implements PreferredSizeWidget {
this.onBackPressed,
this.additionalActions,
this.leading,
this.hasBack = false,
this.centerTitle = false,
});
@override
@@ -32,6 +36,7 @@ class RAppBar extends StatelessWidget implements PreferredSizeWidget {
elevation: 0,
excludeHeaderSemantics: true,
scrolledUnderElevation: 0,
centerTitle: centerTitle,
titleTextStyle:
titleTextStyle ??
AppFonts.yekan16.copyWith(color:Colors.white),
@@ -43,14 +48,18 @@ class RAppBar extends StatelessWidget implements PreferredSizeWidget {
) : null,
actions: [
if (additionalActions != null) ...additionalActions!,
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: IconButton(
onPressed: onBackPressed ?? () => Get.back(),
icon: const Icon(CupertinoIcons.chevron_back),
color: iconColor,
if(hasBack)...{
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: IconButton(
onPressed: onBackPressed ?? () => Get.back(),
icon: const Icon(CupertinoIcons.chevron_back),
color: iconColor,
),
),
),
}
],
);

View File

@@ -60,16 +60,17 @@ class BottomNavigation1Item extends StatelessWidget {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
vecWidget(
icon,
width: 32,
height: 32,
color: isSelected ? AppColor.blueNormal : Colors.white,
SvgGenImage.vec(icon).svg(
width: 32,
height: 32,
colorFilter: ColorFilter.mode(
isSelected ? AppColor.blueNormal : Colors.white,
BlendMode.srcIn)
),
const SizedBox(height: 5),
Text(
label,
style: AppFonts.yekan14.copyWith(
style: AppFonts.yekan10.copyWith(
color: isSelected ? AppColor.blueNormal : Colors.white,
),
),

View File

@@ -0,0 +1,85 @@
import 'package:flutter/material.dart';
import 'package:rasadyar_core/core.dart';
class CustomChip extends StatelessWidget {
final bool isSelected;
final String title;
final int index;
final Function(int) onTap;
final Color selectedColor;
final Color unSelectedColor;
const CustomChip({
super.key,
this.isSelected = false,
required this.title,
required this.index,
required this.onTap,
this.selectedColor = AppColor.blueNormal,
this.unSelectedColor = AppColor.whiteGreyNormal,
});
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () => onTap.call(index),
child: Container(
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 10),
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
color: isSelected ? selectedColor : unSelectedColor,
borderRadius: BorderRadius.circular(8),
border:
isSelected
? Border.fromBorderSide(BorderSide.none)
: Border.all(width: 0.25, color: const Color(0xFFB0B0B0)),
),
child: Text(
title,
textAlign: TextAlign.center,
style:
isSelected
? AppFonts.yekan10.copyWith(color: AppColor.whiteLight)
: AppFonts.yekan10,
),
),
);
}
}
class RFilterChips extends StatelessWidget {
const RFilterChips({
super.key,
this.isSelected = false,
required this.title,
required this.index,
required this.onTap,
this.selectedColor = AppColor.blueNormal,
this.unSelectedColor = AppColor.whiteGreyNormal,
});
final bool isSelected;
final String title;
final int index;
final Function(int) onTap;
final Color selectedColor;
final Color unSelectedColor;
@override
Widget build(BuildContext context) {
return FilterChip(
labelStyle: isSelected
? AppFonts.yekan10.copyWith(color: AppColor.mediumGreyDarkActive)
: AppFonts.yekan10,
label: Text(
title,
textAlign: TextAlign.center),
deleteIconColor: Colors.red,
selected: isSelected,
selectedColor: selectedColor,
onSelected: (bool selected) {
onTap.call(index);
},
);
}
}

View File

@@ -1,5 +1,83 @@
import 'dart:async';
import 'package:flutter/animation.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:flutter_map_animations/flutter_map_animations.dart';
import 'package:geolocator/geolocator.dart';
import 'package:get/get.dart';
import 'package:latlong2/latlong.dart';
class MapLogic extends GetxController {
class MapWidgetLogic extends GetxController with GetTickerProviderStateMixin {
Rx<LatLng> currentLocation = LatLng(35.824891, 50.948025).obs;
String tileType = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png';
RxList<LatLng> markers = <LatLng>[].obs;
RxList<LatLng> allMarkers = <LatLng>[].obs;
Rx<MapController> mapController = MapController().obs;
late final AnimatedMapController animatedMapController;
Timer? _debounceTimer;
RxBool isLoading = false.obs;
@override
void onInit() {
super.onInit();
animatedMapController = AnimatedMapController(
vsync: this,
duration: const Duration(milliseconds: 500),
curve: Curves.easeInOut,
cancelPreviousAnimations: true,
);
determineCurrentPosition();
}
@override
void onClose() {
super.onClose();
animatedMapController.dispose();
mapController.close();
}
Future<void> determineCurrentPosition() async {
final position = await Geolocator.getCurrentPosition(
locationSettings: AndroidSettings(accuracy: LocationAccuracy.best),
);
final latLng = LatLng(position.latitude, position.longitude);
currentLocation.value = latLng;
markers.add(latLng);
animatedMapController.animateTo(
dest: latLng,
zoom: 18,
curve: Curves.easeInOut,
duration: const Duration(milliseconds: 1500),
);
}
void debouncedUpdateVisibleMarkers({required LatLng center}) {
_debounceTimer?.cancel();
_debounceTimer = Timer(const Duration(milliseconds: 300), () {
final filtered = filterNearbyMarkers({
'markers': allMarkers,
'centerLat': center.latitude,
'centerLng': center.longitude,
'radius': 1000.0,
});
markers.addAll(filtered);
});
}
List<LatLng> filterNearbyMarkers(Map<String, dynamic> args) {
final List<LatLng> rawMarkers = args['markers'];
final double centerLat = args['centerLat'];
final double centerLng = args['centerLng'];
final double radiusInMeters = args['radius'];
final center = LatLng(centerLat, centerLng);
final distance = Distance();
return rawMarkers
.where((marker) => distance(center, marker) <= radiusInMeters)
.toList();
}
}

View File

@@ -1,13 +1,76 @@
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:get/get.dart';
import 'package:rasadyar_core/presentation/common/app_color.dart';
import 'package:rasadyar_core/presentation/common/assets.gen.dart';
import 'package:rasadyar_core/presentation/widget/buttons/fab.dart';
import 'logic.dart';
class MapPage extends GetView<MapLogic> {
const MapPage({super.key});
class MapWidget extends GetView<MapWidgetLogic> {
const MapWidget({super.key});
@override
Widget build(BuildContext context) {
return Container();
return Stack(
children: [_buildMap(), _buildGpsButton(), _buildFilterButton()],
);
}
Widget _buildMap() {
return ObxValue((currentLocation) {
return FlutterMap(
mapController: controller.animatedMapController.mapController,
options: MapOptions(
initialCenter: currentLocation.value,
initialZoom: 18,
onPositionChanged: (camera, hasGesture) {
controller.debouncedUpdateVisibleMarkers(center: camera.center);
},
),
children: [
TileLayer(urlTemplate: controller.tileType),
/* ObxValue((markers) {
return MarkerLayer(
markers:
markers
.map((e) => markerWidget(marker: e, onTap: () {}))
.toList(),
);
}, controller.markers),*/
],
);
}, controller.currentLocation);
}
Widget _buildGpsButton() {
return Positioned(
right: 10,
bottom: 83,
child: ObxValue((data) {
return RFab.small(
backgroundColor: AppColor.greenNormal,
isLoading: data.value,
icon: Assets.vec.gpsSvg.svg(),
onPressed: () async {
controller.isLoading.value = true;
await controller.determineCurrentPosition();
controller.isLoading.value = false;
},
);
}, controller.isLoading),
);
}
Widget _buildFilterButton() {
return Positioned(
right: 10,
bottom: 30,
child: RFab.small(
backgroundColor: AppColor.blueNormal,
icon: Assets.vec.filterSvg.svg(width: 24, height: 24),
onPressed: () {},
),
);
}
}

View File

@@ -15,3 +15,4 @@ export 'tabs/new_tab.dart';
export 'tabs/tab.dart';
export 'vec_widget.dart';
export 'card/card_with_icon_with_border.dart';
export 'chips/r_chips.dart';

View File

@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:rasadyar_core/core.dart';
import 'logic.dart';
class ActionPage extends GetView<ActionLogic> {
@@ -7,6 +8,211 @@ class ActionPage extends GetView<ActionLogic> {
@override
Widget build(BuildContext context) {
return Container();
return Scaffold(
appBar: RAppBar(
title: 'لیست درخواست‌ها',
hasBack: false,
centerTitle: true,
),
body: Column(
children: [
SizedBox(height: 16),
_searchWidget(),
SizedBox(height: 16),
SizedBox(
height: 50,
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
padding: EdgeInsets.symmetric(horizontal: 12),
child: Row(
spacing: 12,
children: [
CustomChip(
title: 'انتخاب فیلتر',
index: 0,
isSelected: true,
selectedColor: AppColor.blueNormal,
onTap: (index) {},
),
RFilterChips(
title: 'درخواست‌های من',
index: 1,
isSelected: true,
selectedColor: AppColor.yellowNormal,
onTap: (index) {},
),
RFilterChips(
title: 'در انتظار ثبت ',
index: 2,
selectedColor: AppColor.greenLightActive,
isSelected: true,
onTap: (index) {},
),
RFilterChips(
title: 'ارجاع به تعاونی',
index: 3,
selectedColor: AppColor.blueLightHover,
isSelected: true,
onTap: (index) {},
),
],
),
),
),
SizedBox(height: 10),
Expanded(
child: ListView.separated(
itemCount: 10,
physics: BouncingScrollPhysics(),
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 10),
separatorBuilder: (context, index) => SizedBox(height: 16),
itemBuilder: (context, index) {
return Container(
width: Get.width,
height: 75,
decoration: BoxDecoration(
color:
index < 3
? AppColor.yellowNormal
: index < 7
? AppColor.greenLightActive
: AppColor.blueLight,
borderRadius: BorderRadius.circular(8),
),
child: Row(
children: [
SizedBox(width: 5),
Expanded(
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topRight: Radius.circular(8),
bottomRight: Radius.circular(8),
),
),
child: Row(
children: [
SizedBox(width: 10),
Text(
'محمد احمدی',
textAlign: TextAlign.center,
style: AppFonts.yekan12.copyWith(
color: AppColor.blueNormal,
fontWeight: FontWeight.w600,
),
),
SizedBox(width: 20),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'پنج شنبه 14 اردیبهشت',
textAlign: TextAlign.center,
style: AppFonts.yekan10.copyWith(
color: AppColor.darkGreyNormal,
),
),
Text(
' همدان - نهاوند - روستای - همدان - نهاوند - روستای ',
textAlign: TextAlign.center,
style: AppFonts.yekan10.copyWith(
color: AppColor.darkGreyNormal,
),
overflow: TextOverflow.ellipsis,
maxLines: 1,
),
],
),
),
SizedBox(width: 20),
GestureDetector(
onTap: () {
// controller.onTapMap();
},
child: SizedBox(
width: 50,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Assets.vec.mapSvg.svg(
width: 20,
height: 20,
colorFilter: ColorFilter.mode(
AppColor.blueNormal,
BlendMode.srcIn,
),
),
SizedBox(height: 8),
Text(
'مسیریابی',
textAlign: TextAlign.center,
style: AppFonts.yekan10.copyWith(
color: AppColor.blueNormal,
),
),
],
),
),
),
SizedBox(width: 20),
],
),
),
),
Container(
width: 20,
child: Center(
child: RotatedBox(
quarterTurns: 3,
child: Text(
index < 3
? ' بازرسی'
: index < 7
? 'اطلاعات'
: 'ارجاع به تعاونی',
style: AppFonts.yekan8,
textAlign: TextAlign.center,
),
),
),
),
],
),
);
},
),
),
],
),
);
}
Widget _searchWidget() {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: RTextField(
suffixIcon: Padding(
padding: const EdgeInsets.all(12.0),
child: Assets.vec.searchSvg.svg(
width: 10,
height: 10,
colorFilter: ColorFilter.mode(AppColor.blueNormal, BlendMode.srcIn),
),
),
hintText: 'جستجو',
onChanged: (value) {
//controller.search(value);
},
controller: TextEditingController(),
),
);
}
}

View File

@@ -2,4 +2,7 @@ import 'package:rasadyar_core/core.dart';
class MapLogic extends GetxController {
}

View File

@@ -1,14 +1,22 @@
import 'package:flutter/material.dart';
import 'package:flutter/material.dart' as mt;
import 'package:rasadyar_core/core.dart';
import 'package:rasadyar_core/presentation/widget/map/view.dart';
import 'logic.dart';
class MapPage extends GetView<MapLogic> {
MapPage({super.key});
@override
Widget build(BuildContext context) {
return Container();
return Scaffold(
body: Stack(
children: [
MapWidget(),
],
),
);
}
}
}

View File

@@ -6,7 +6,7 @@ import 'package:rasadyar_livestock/presentation/page/profile/view.dart';
class RootLogic extends GetxController {
List<Widget> pages = [ActionPage(), MapPage(), ProfilePage()];
RxInt indexedPage = 1.obs;
RxInt currentIndex = 1.obs;
@override
void onReady() {
@@ -19,4 +19,7 @@ class RootLogic extends GetxController {
// TODO: implement onClose
super.onClose();
}
void changePage(int i) => currentIndex.value = i;
}

View File

@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:rasadyar_core/core.dart';
import 'logic.dart';
class RootPage extends GetView<RootLogic> {
@@ -7,14 +8,39 @@ class RootPage extends GetView<RootLogic> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: ObxValue((data) {
return IndexedStack(
return ObxValue((currentIndex) {
return Scaffold(
body: IndexedStack(
children: controller.pages,
index: data.value,
index: currentIndex.value,
sizing: StackFit.expand,
);
}, controller.indexedPage),
);
),
bottomNavigationBar: BottomNavigation1(
items: [
BottomNavigation1Item(
icon: Assets.vec.filterSvg.path,
label: 'درخواست‌ها',
isSelected: currentIndex.value == 0,
onTap: () => controller.changePage(0),
),
BottomNavigation1Item(
icon: Assets.vec.mapSvg.path,
label: 'نقشه',
isSelected: currentIndex.value == 1,
onTap: () => controller.changePage(1),
),
BottomNavigation1Item(
icon: Assets.vec.profileUserSvg.path,
label: 'پروفایل',
isSelected: currentIndex.value == 2,
onTap: () => controller.changePage(2),
),
],
),
);
}, controller.currentIndex);
}
}

View File

@@ -1,10 +1,12 @@
import 'package:rasadyar_auth/auth.dart';
import 'package:rasadyar_core/core.dart';
import 'package:rasadyar_core/presentation/widget/map/logic.dart';
import 'package:rasadyar_livestock/presentation/page/action/logic.dart';
import 'package:rasadyar_livestock/presentation/page/map/logic.dart';
import 'package:rasadyar_livestock/presentation/page/profile/logic.dart';
import 'package:rasadyar_livestock/presentation/page/root/logic.dart';
import 'package:rasadyar_livestock/presentation/page/root/view.dart';
part 'app_routes.dart';
sealed class LiveStockPages {
@@ -21,6 +23,8 @@ sealed class LiveStockPages {
Get.lazyPut(() => ActionLogic());
Get.lazyPut(() => MapLogic());
Get.lazyPut(() => ProfileLogic());
Get.lazyPut(() => ProfileLogic());
Get.lazyPut(() => MapWidgetLogic());
}),
),
];

View File

@@ -11,8 +11,8 @@ PACKAGE_ABS_PATH="$SCRIPT_DIR/$PACKAGE_PATH"
echo "🗃️ package path: $PACKAGE_ABS_PATH"
# Directory to read files from
sourcePath="$PACKAGE_ABS_PATH/assets/icons"
targetPath="$PACKAGE_ABS_PATH/assets/vec"
sourcePath="../assets/icons"
targetPath="../assets/vec"
echo "🗃️ sourcePath path: $sourcePath"
echo "🗃️ targetPath path: $targetPath"