feat : profile and map

This commit is contained in:
2025-07-28 15:57:30 +03:30
parent 6057976b46
commit d9724f681c
67 changed files with 2835 additions and 444 deletions

View File

@@ -1,16 +1,60 @@
import 'package:flutter/material.dart';
import 'package:rasadyar_core/core.dart';
import 'package:rasadyar_inspection/data/model/response/user_profile/user_profile_model.dart';
import 'package:rasadyar_inspection/data/repositories/user/user_repository_imp.dart';
import 'package:rasadyar_inspection/injection/inspection_di.dart';
import 'package:rasadyar_inspection/presentation/pages/action/view.dart';
import 'package:rasadyar_inspection/presentation/pages/inspection_map/view.dart';
import 'package:rasadyar_inspection/presentation/pages/profile/view.dart';
enum ErrorLocationType { serviceDisabled, permissionDenied, none }
class RootLogic extends GetxController {
RxInt currentIndex = 0.obs;
List<Widget> pages = [InspectionMapPage(), ActionPage(), ProfilePage()];
RxList<ErrorLocationType> errorLocationType = RxList();
TokenStorageService tokenStorageService = Get.find<TokenStorageService>();
UserRepositoryImp userRepository = diInspection.get<UserRepositoryImp>();
Rxn<UserProfileModel> userProfile = Rxn<UserProfileModel>();
@override
void onInit() {
super.onInit();
userRepository
.fetchUserProfile(token: tokenStorageService.accessToken.value ?? '')
.then((value) => userProfile.value = value);
}
@override
void onReady() {
super.onReady();
locationServiceEnabled().then((value) {
if (!value) {
errorLocationType.add(ErrorLocationType.serviceDisabled);
}
});
checkPermission().then((value) {
if (!value) {
errorLocationType.add(ErrorLocationType.permissionDenied);
}
});
listenToLocationServiceStatus().listen((event) {
if (!event) {
errorLocationType.add(ErrorLocationType.serviceDisabled);
} else {
errorLocationType.remove(ErrorLocationType.serviceDisabled);
}
});
}
@override
void onClose() {
// TODO: implement onClose
super.onClose();
}
Stream<bool> listenToLocationServiceStatus() {
return Geolocator.getServiceStatusStream().map((status) {
@@ -52,38 +96,7 @@ class RootLogic extends GetxController {
}
}
@override
void onReady() {
super.onReady();
locationServiceEnabled().then((value) {
if (!value) {
errorLocationType.add(ErrorLocationType.serviceDisabled);
}
});
checkPermission().then((value) {
if (!value) {
errorLocationType.add(ErrorLocationType.permissionDenied);
}
});
listenToLocationServiceStatus().listen((event) {
if (!event) {
errorLocationType.add(ErrorLocationType.serviceDisabled);
} else {
errorLocationType.remove(ErrorLocationType.serviceDisabled);
}
});
}
void changePage(int index) {
currentIndex.value = index;
}
@override
void onClose() {
// TODO: implement onClose
super.onClose();
}
}