feat: actions and map page
This commit is contained in:
@@ -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';
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
),
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
|
||||
],
|
||||
);
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
),
|
||||
|
||||
85
packages/core/lib/presentation/widget/chips/r_chips.dart
Normal file
85
packages/core/lib/presentation/widget/chips/r_chips.dart
Normal 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);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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: () {},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user