feat : some changes
This commit is contained in:
@@ -1,8 +1,6 @@
|
|||||||
import 'package:flutter_map_tile_caching/flutter_map_tile_caching.dart';
|
|
||||||
import 'package:get_it/get_it.dart';
|
|
||||||
import 'package:logger/logger.dart';
|
import 'package:logger/logger.dart';
|
||||||
|
import 'package:rasadyar_core/core.dart';
|
||||||
import 'package:rasadyar_core/data/services/network_status.dart';
|
import 'package:rasadyar_core/data/services/network_status.dart';
|
||||||
import 'package:rasadyar_core/infrastructure/local/hive_local_storage.dart';
|
|
||||||
|
|
||||||
final diCore = GetIt.instance;
|
final diCore = GetIt.instance;
|
||||||
|
|
||||||
|
|||||||
55
packages/core/lib/presentation/widget/marquee/r_marquee.dart
Normal file
55
packages/core/lib/presentation/widget/marquee/r_marquee.dart
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:rasadyar_core/core.dart';
|
||||||
|
|
||||||
|
class RMarquee extends StatefulWidget {
|
||||||
|
const RMarquee({super.key, required this.text, this.duration = const Duration(seconds: 5)});
|
||||||
|
|
||||||
|
final String text;
|
||||||
|
final Duration duration;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<RMarquee> createState() => _RMarqueeState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _RMarqueeState extends State<RMarquee> with SingleTickerProviderStateMixin {
|
||||||
|
late ScrollController _scrollController;
|
||||||
|
late double _textWidth;
|
||||||
|
late double _screenWidth;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_scrollController = ScrollController();
|
||||||
|
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
_startScrolling();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _startScrolling() async {
|
||||||
|
while (true) {
|
||||||
|
await _scrollController.animateTo(
|
||||||
|
_scrollController.position.maxScrollExtent,
|
||||||
|
duration: widget.duration,
|
||||||
|
curve: Curves.linear,
|
||||||
|
);
|
||||||
|
|
||||||
|
await _scrollController.animateTo(0, duration: Duration(seconds: 0), curve: Curves.linear);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SizedBox(
|
||||||
|
height: 40,
|
||||||
|
child: ListView(
|
||||||
|
controller: _scrollController,
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
children: [
|
||||||
|
Text(widget.text, style: AppFonts.yekan16Bold),
|
||||||
|
SizedBox(width: 50),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,6 +22,9 @@ export 'list_item/list_item_with_out_number.dart';
|
|||||||
export 'list_row_item.dart';
|
export 'list_row_item.dart';
|
||||||
export 'list_view/list_view.dart';
|
export 'list_view/list_view.dart';
|
||||||
export 'loading_widget.dart';
|
export 'loading_widget.dart';
|
||||||
|
// other
|
||||||
|
export 'logo_widget.dart';
|
||||||
|
export 'marquee/r_marquee.dart';
|
||||||
export 'overlay_dropdown_widget/view.dart';
|
export 'overlay_dropdown_widget/view.dart';
|
||||||
export 'pagination/pagination_from_until.dart';
|
export 'pagination/pagination_from_until.dart';
|
||||||
export 'pagination/show_more.dart';
|
export 'pagination/show_more.dart';
|
||||||
@@ -29,6 +32,3 @@ export 'tabs/new_tab.dart';
|
|||||||
export 'tabs/r_segment.dart';
|
export 'tabs/r_segment.dart';
|
||||||
export 'tabs/tab.dart';
|
export 'tabs/tab.dart';
|
||||||
export 'vec_widget.dart';
|
export 'vec_widget.dart';
|
||||||
|
|
||||||
// other
|
|
||||||
export 'logo_widget.dart';
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ Future<void> setupLiveStockDI() async {
|
|||||||
await tokenService.saveBaseUrl('https://api.dam.rasadyar.net/');
|
await tokenService.saveBaseUrl('https://api.dam.rasadyar.net/');
|
||||||
}
|
}
|
||||||
|
|
||||||
await FMTCStore(mapStoreKey).manage.create();
|
|
||||||
|
|
||||||
|
|
||||||
// First register AppInterceptor with lazy callbacks
|
// First register AppInterceptor with lazy callbacks
|
||||||
|
|||||||
@@ -22,7 +22,9 @@ class MapWidgetLogic extends GetxController with GetTickerProviderStateMixin {
|
|||||||
Timer? _debounceTimer;
|
Timer? _debounceTimer;
|
||||||
RxBool isLoading = false.obs;
|
RxBool isLoading = false.obs;
|
||||||
|
|
||||||
late FMTCTileProvider tileProvider;
|
/* FMTCTileProvider tileProvider = FMTCTileProvider(
|
||||||
|
stores: {mapStoreKey: BrowseStoreStrategy.readUpdateCreate},
|
||||||
|
);*/
|
||||||
|
|
||||||
RxList<LatLng> markerLocations = RxList();
|
RxList<LatLng> markerLocations = RxList();
|
||||||
RootLogic rootLogic = Get.find<RootLogic>();
|
RootLogic rootLogic = Get.find<RootLogic>();
|
||||||
@@ -57,8 +59,6 @@ class MapWidgetLogic extends GetxController with GetTickerProviderStateMixin {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
tileProvider = FMTCTileProvider(stores: {mapStoreKey: BrowseStoreStrategy.readUpdateCreate});
|
|
||||||
|
|
||||||
repository.addLocations(generateRandomLocations(currentLocation.value, 10, 100));
|
repository.addLocations(generateRandomLocations(currentLocation.value, 10, 100));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,15 @@ class MapWidget extends GetView<MapWidgetLogic> {
|
|||||||
child: Stack(
|
child: Stack(
|
||||||
fit: StackFit.expand,
|
fit: StackFit.expand,
|
||||||
children: [
|
children: [
|
||||||
|
|
||||||
|
Positioned(
|
||||||
|
top: 10,
|
||||||
|
right: 0,
|
||||||
|
left: 0,
|
||||||
|
child: RMarquee(text: "This is scrolling text from right to left..."),
|
||||||
|
),
|
||||||
|
|
||||||
|
|
||||||
ObxValue((errorType) {
|
ObxValue((errorType) {
|
||||||
if (errorType.isNotEmpty) {
|
if (errorType.isNotEmpty) {
|
||||||
if (errorType.contains(ErrorLocationType.serviceDisabled)) {
|
if (errorType.contains(ErrorLocationType.serviceDisabled)) {
|
||||||
@@ -104,7 +113,6 @@ class MapWidget extends GetView<MapWidgetLogic> {
|
|||||||
flags: InteractiveFlag.all & ~InteractiveFlag.rotate,
|
flags: InteractiveFlag.all & ~InteractiveFlag.rotate,
|
||||||
),
|
),
|
||||||
initialZoom: 15,
|
initialZoom: 15,
|
||||||
|
|
||||||
onPositionChanged: (camera, hasGesture) {
|
onPositionChanged: (camera, hasGesture) {
|
||||||
controller.currentZoom.value = camera.zoom;
|
controller.currentZoom.value = camera.zoom;
|
||||||
/* controller.debouncedUpdateVisibleMarkers(
|
/* controller.debouncedUpdateVisibleMarkers(
|
||||||
@@ -118,7 +126,7 @@ class MapWidget extends GetView<MapWidgetLogic> {
|
|||||||
TileLayer(
|
TileLayer(
|
||||||
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
|
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||||
userAgentPackageName: 'ir.mnpc.rasadyar',
|
userAgentPackageName: 'ir.mnpc.rasadyar',
|
||||||
tileProvider: controller.tileProvider,
|
// tileProvider: controller.tileProvider,
|
||||||
),
|
),
|
||||||
|
|
||||||
ObxValue((markers) {
|
ObxValue((markers) {
|
||||||
@@ -181,9 +189,11 @@ class MapWidget extends GetView<MapWidgetLogic> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Marker> buildMarkers(RxList<LatLng> latLng) => latLng
|
List<Marker> buildMarkers(RxList<LatLng> latLng) =>
|
||||||
|
latLng
|
||||||
.map(
|
.map(
|
||||||
(element) => Marker(
|
(element) =>
|
||||||
|
Marker(
|
||||||
point: element,
|
point: element,
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'dart:async';
|
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@@ -10,15 +9,21 @@ import 'package:rasadyar_livestock/presentation/page/requests/view.dart';
|
|||||||
import 'package:rasadyar_livestock/presentation/routes/app_pages.dart';
|
import 'package:rasadyar_livestock/presentation/routes/app_pages.dart';
|
||||||
|
|
||||||
class RootLogic extends GetxController {
|
class RootLogic extends GetxController {
|
||||||
List<Widget> pages = [
|
// Unique nested keys for each Navigator
|
||||||
|
final List<GlobalKey<NavigatorState>> navigatorKeys = [
|
||||||
|
?Get.nestedKey(0), // Map
|
||||||
|
?Get.nestedKey(1), // Requests / RequestTagging
|
||||||
|
?Get.nestedKey(2), // Profile
|
||||||
|
];
|
||||||
|
|
||||||
|
List<Widget> get pages => [
|
||||||
Navigator(
|
Navigator(
|
||||||
key: Get.nestedKey(0),
|
key: navigatorKeys[0],
|
||||||
onGenerateRoute: (settings) => GetPageRoute(page: () => MapPage()),
|
onGenerateRoute: (settings) => GetPageRoute(page: () => MapPage()),
|
||||||
),
|
),
|
||||||
|
|
||||||
Navigator(
|
Navigator(
|
||||||
key: Get.nestedKey(1),
|
key: navigatorKeys[1],
|
||||||
initialRoute: LiveStockRoutes.requests,
|
|
||||||
onGenerateRoute: (settings) {
|
onGenerateRoute: (settings) {
|
||||||
switch (settings.name) {
|
switch (settings.name) {
|
||||||
case LiveStockRoutes.requests:
|
case LiveStockRoutes.requests:
|
||||||
@@ -32,7 +37,7 @@ class RootLogic extends GetxController {
|
|||||||
),
|
),
|
||||||
|
|
||||||
Navigator(
|
Navigator(
|
||||||
key: Get.nestedKey(2),
|
key: navigatorKeys[2],
|
||||||
onGenerateRoute: (settings) => GetPageRoute(page: () => ProfilePage()),
|
onGenerateRoute: (settings) => GetPageRoute(page: () => ProfilePage()),
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
@@ -40,60 +45,28 @@ class RootLogic extends GetxController {
|
|||||||
RxInt currentIndex = 0.obs;
|
RxInt currentIndex = 0.obs;
|
||||||
TokenStorageService tokenService = Get.find<TokenStorageService>();
|
TokenStorageService tokenService = Get.find<TokenStorageService>();
|
||||||
|
|
||||||
late StreamSubscription<List<ConnectivityResult>> connectivitySubscription;
|
|
||||||
RxList<ConnectivityResult> connectivityResults = <ConnectivityResult>[].obs;
|
|
||||||
|
|
||||||
DateTime? lastBackPressed;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
connectivitySubscription = Connectivity().onConnectivityChanged.listen((result) {
|
|
||||||
if (result.isNotEmpty) {
|
|
||||||
connectivityResults.assignAll(result);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/* GetIt.instance.allReady().then((value) async {
|
|
||||||
await diLiveStock.get<LivestockRepositoryImp>().addLocations(generateRandomPoints());
|
|
||||||
});*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<LatLng> generateRandomPoints() {
|
|
||||||
final Random random = Random();
|
|
||||||
final double centerLat = 35.824891;
|
|
||||||
final double centerLon = 50.948025;
|
|
||||||
final double radiusKm = 1.0;
|
|
||||||
final double kmToDegLat = 1 / 111.0; // 1 km ≈ 0.009° latitude
|
|
||||||
final double kmToDegLon = 1 / (111.0 * cos(centerLat * pi / 180)); // Adjust for longitude
|
|
||||||
|
|
||||||
List<LatLng> points = [];
|
|
||||||
for (int i = 0; i < 100; i++) {
|
|
||||||
// Generate random angle (0 to 2π) and random radius (0 to 1 km, using sqrt for uniform distribution)
|
|
||||||
double theta = random.nextDouble() * 2 * pi;
|
|
||||||
double r =
|
|
||||||
sqrt(random.nextDouble()) * radiusKm; // Square root for uniform distribution in circle
|
|
||||||
// Convert polar coordinates to Cartesian, then to LatLng
|
|
||||||
double deltaLat = r * cos(theta) * kmToDegLat;
|
|
||||||
double deltaLon = r * sin(theta) * kmToDegLon;
|
|
||||||
double newLat = centerLat + deltaLat;
|
|
||||||
double newLon = centerLon + deltaLon;
|
|
||||||
points.add(LatLng(newLat, newLon));
|
|
||||||
}
|
|
||||||
return points;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onReady() {
|
void onReady() {
|
||||||
// TODO: implement onReady
|
|
||||||
super.onReady();
|
super.onReady();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onClose() {
|
void onClose() {
|
||||||
connectivitySubscription.cancel();
|
|
||||||
super.onClose();
|
super.onClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
void changePage(int i) => currentIndex.value = i;
|
void changePage(int index) {
|
||||||
|
if (index == currentIndex.value) {
|
||||||
|
// Optional: pop to first route if the same tab is tapped
|
||||||
|
navigatorKeys[index].currentState?.popUntil((route) => route.isFirst);
|
||||||
|
} else {
|
||||||
|
currentIndex.value = index;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class RootPage extends GetView<RootLogic> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final now = DateTime.now();
|
final now = DateTime.now();
|
||||||
if (controller.lastBackPressed == null ||
|
/*if (controller.lastBackPressed == null ||
|
||||||
now.difference(controller.lastBackPressed!) > const Duration(seconds: 2)) {
|
now.difference(controller.lastBackPressed!) > const Duration(seconds: 2)) {
|
||||||
controller.lastBackPressed = now;
|
controller.lastBackPressed = now;
|
||||||
Get.snackbar(
|
Get.snackbar(
|
||||||
@@ -28,7 +28,7 @@ class RootPage extends GetView<RootLogic> {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
await SystemNavigator.pop();
|
await SystemNavigator.pop();
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ sealed class LiveStockPages {
|
|||||||
Get.lazyPut(() => RequestsLogic());
|
Get.lazyPut(() => RequestsLogic());
|
||||||
Get.lazyPut(() => MapLogic());
|
Get.lazyPut(() => MapLogic());
|
||||||
Get.lazyPut(() => ProfileLogic());
|
Get.lazyPut(() => ProfileLogic());
|
||||||
Get.lazyPut(() => ProfileLogic());
|
|
||||||
Get.lazyPut(() => MapWidgetLogic());
|
Get.lazyPut(() => MapWidgetLogic());
|
||||||
Get.lazyPut(() => BaseLogic());
|
Get.lazyPut(() => BaseLogic());
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ sealed class LiveStockRoutes {
|
|||||||
static const requests = '/requests';
|
static const requests = '/requests';
|
||||||
static const map = '/map';
|
static const map = '/map';
|
||||||
static const profile = '/profile';
|
static const profile = '/profile';
|
||||||
|
|
||||||
//static const requestTagging = '$init/tagging';
|
|
||||||
static const requestTagging = '$requests/tagging';
|
static const requestTagging = '$requests/tagging';
|
||||||
static const tagging = '/tagging';
|
static const tagging = '/tagging';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user