new change to use intaleq_map sdk 04-16-4

This commit is contained in:
Hamza-Ayed
2026-04-16 19:45:03 +03:00
parent 0aa1f15f25
commit a54a7a4189
850 changed files with 83282 additions and 3075 deletions

View File

@@ -0,0 +1,33 @@
import 'package:get/get.dart';
import '../../services/auth_service.dart';
import '../routes/app_pages.dart';
class EnsureAuthMiddleware extends GetMiddleware {
@override
Future<GetNavConfig?> redirectDelegate(GetNavConfig route) async {
// you can do whatever you want here
// but it's preferable to make this method fast
// await Future.delayed(Duration(milliseconds: 500));
if (!AuthService.to.isLoggedInValue) {
final newRoute = Routes.LOGIN_THEN(route.location!);
return GetNavConfig.fromRoute(newRoute);
}
return await super.redirectDelegate(route);
}
}
class EnsureNotAuthedMiddleware extends GetMiddleware {
@override
Future<GetNavConfig?> redirectDelegate(GetNavConfig route) async {
if (AuthService.to.isLoggedInValue) {
//NEVER navigate to auth screen, when user is already authed
return null;
//OR redirect user to another screen
//return GetNavConfig.fromRoute(Routes.PROFILE);
}
return await super.redirectDelegate(route);
}
}

View File

@@ -0,0 +1,12 @@
import 'package:get/get.dart';
import '../controllers/dashboard_controller.dart';
class DashboardBinding extends Bindings {
@override
void dependencies() {
Get.lazyPut<DashboardController>(
() => DashboardController(),
);
}
}

View File

@@ -0,0 +1,17 @@
import 'dart:async';
import 'package:get/get.dart';
class DashboardController extends GetxController {
final now = DateTime.now().obs;
@override
void onReady() {
super.onReady();
Timer.periodic(
Duration(seconds: 1),
(timer) {
now.value = DateTime.now();
},
);
}
}

View File

@@ -0,0 +1,26 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../controllers/dashboard_controller.dart';
class DashboardView extends GetView<DashboardController> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Obx(
() => Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
'DashboardView is working',
style: TextStyle(fontSize: 20),
),
Text('Time: ${controller.now.value.toString()}'),
],
),
),
),
);
}
}

View File

@@ -0,0 +1,12 @@
import 'package:get/get.dart';
import '../controllers/home_controller.dart';
class HomeBinding extends Bindings {
@override
void dependencies() {
Get.lazyPut<HomeController>(
() => HomeController(),
);
}
}

View File

@@ -0,0 +1,3 @@
import 'package:get/get.dart';
class HomeController extends GetxController {}

View File

@@ -0,0 +1,65 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../../routes/app_pages.dart';
import '../controllers/home_controller.dart';
class HomeView extends GetView<HomeController> {
@override
Widget build(BuildContext context) {
return GetRouterOutlet.builder(
builder: (context, delegate, currentRoute) {
//This router outlet handles the appbar and the bottom navigation bar
final currentLocation = currentRoute?.location;
var currentIndex = 0;
if (currentLocation?.startsWith(Routes.PRODUCTS) == true) {
currentIndex = 2;
}
if (currentLocation?.startsWith(Routes.PROFILE) == true) {
currentIndex = 1;
}
return Scaffold(
body: GetRouterOutlet(
initialRoute: Routes.DASHBOARD,
// anchorRoute: Routes.HOME,
key: Get.nestedKey(Routes.HOME),
),
bottomNavigationBar: BottomNavigationBar(
currentIndex: currentIndex,
onTap: (value) {
switch (value) {
case 0:
delegate.toNamed(Routes.HOME);
break;
case 1:
delegate.toNamed(Routes.PROFILE);
break;
case 2:
delegate.toNamed(Routes.PRODUCTS);
break;
default:
}
},
items: [
// _Paths.HOME + [Empty]
BottomNavigationBarItem(
icon: Icon(Icons.home),
label: 'Home',
),
// _Paths.HOME + Routes.PROFILE
BottomNavigationBarItem(
icon: Icon(Icons.account_box_rounded),
label: 'Profile',
),
// _Paths.HOME + _Paths.PRODUCTS
BottomNavigationBarItem(
icon: Icon(Icons.account_box_rounded),
label: 'Products',
),
],
),
);
},
);
}
}

View File

@@ -0,0 +1,12 @@
import 'package:get/get.dart';
import '../controllers/login_controller.dart';
class LoginBinding extends Bindings {
@override
void dependencies() {
Get.lazyPut<LoginController>(
() => LoginController(),
);
}
}

View File

@@ -0,0 +1,3 @@
import 'package:get/get.dart';
class LoginController extends GetxController {}

View File

@@ -0,0 +1,44 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../../../services/auth_service.dart';
import '../../../routes/app_pages.dart';
import '../controllers/login_controller.dart';
class LoginView extends GetView<LoginController> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Obx(
() {
final isLoggedIn = AuthService.to.isLoggedInValue;
return Text(
'You are currently:'
' ${isLoggedIn ? "Logged In" : "Not Logged In"}'
"\nIt's impossible to enter this "
"route when you are logged in!",
);
},
),
MaterialButton(
child: Text(
'Do LOGIN !!',
style: TextStyle(color: Colors.blue, fontSize: 20),
),
onPressed: () {
AuthService.to.login();
final thenTo = Get.rootDelegate.currentConfiguration!
.currentPage!.parameters?['then'];
Get.rootDelegate.offNamed(thenTo ?? Routes.HOME);
},
),
],
),
),
);
}
}

View File

@@ -0,0 +1,14 @@
import 'package:get/get.dart';
import '../controllers/product_details_controller.dart';
class ProductDetailsBinding extends Bindings {
@override
void dependencies() {
Get.create<ProductDetailsController>(
() => ProductDetailsController(
Get.parameters['productId'] ?? '',
),
);
}
}

View File

@@ -0,0 +1,18 @@
import 'package:get/get.dart';
class ProductDetailsController extends GetxController {
final String productId;
ProductDetailsController(this.productId);
@override
void onInit() {
super.onInit();
Get.log('ProductDetailsController created with id: $productId');
}
@override
void onClose() {
Get.log('ProductDetailsController close with id: $productId');
super.onClose();
}
}

View File

@@ -0,0 +1,25 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../controllers/product_details_controller.dart';
class ProductDetailsView extends GetWidget<ProductDetailsController> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
'ProductDetailsView is working',
style: TextStyle(fontSize: 20),
),
Text('ProductId: ${controller.productId}')
],
),
),
);
}
}

View File

@@ -0,0 +1,12 @@
import 'package:get/get.dart';
import '../controllers/products_controller.dart';
class ProductsBinding extends Bindings {
@override
void dependencies() {
Get.lazyPut<ProductsController>(
() => ProductsController(),
);
}
}

View File

@@ -0,0 +1,28 @@
import 'package:get/get.dart';
import '../../../../models/demo_product.dart';
class ProductsController extends GetxController {
final products = <DemoProduct>[].obs;
void loadDemoProductsFromSomeWhere() {
products.add(
DemoProduct(
name: 'Product added on: ${DateTime.now().toString()}',
id: DateTime.now().millisecondsSinceEpoch.toString(),
),
);
}
@override
void onReady() {
super.onReady();
loadDemoProductsFromSomeWhere();
}
@override
void onClose() {
Get.printInfo(info: 'Products: onClose');
super.onClose();
}
}

View File

@@ -0,0 +1,49 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../../routes/app_pages.dart';
import '../controllers/products_controller.dart';
class ProductsView extends GetView<ProductsController> {
@override
Widget build(BuildContext context) {
return Scaffold(
floatingActionButton: FloatingActionButton.extended(
onPressed: controller.loadDemoProductsFromSomeWhere,
label: Text('Add'),
),
body: Column(
children: [
Hero(
tag: 'heroLogo',
child: const FlutterLogo(),
),
Expanded(
child: Obx(
() => RefreshIndicator(
onRefresh: () async {
controller.products.clear();
controller.loadDemoProductsFromSomeWhere();
},
child: ListView.builder(
itemCount: controller.products.length,
itemBuilder: (context, index) {
final item = controller.products[index];
return ListTile(
onTap: () {
Get.rootDelegate
.toNamed(Routes.PRODUCT_DETAILS(item.id));
},
title: Text(item.name),
subtitle: Text(item.id),
);
},
),
),
),
),
],
),
);
}
}

View File

@@ -0,0 +1,12 @@
import 'package:get/get.dart';
import '../controllers/profile_controller.dart';
class ProfileBinding extends Bindings {
@override
void dependencies() {
Get.lazyPut<ProfileController>(
() => ProfileController(),
);
}
}

View File

@@ -0,0 +1,3 @@
import 'package:get/get.dart';
class ProfileController extends GetxController {}

View File

@@ -0,0 +1,51 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../../routes/app_pages.dart';
import '../controllers/profile_controller.dart';
class ProfileView extends GetView<ProfileController> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.amber,
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
'ProfileView is working',
style: TextStyle(fontSize: 20),
),
Hero(
tag: 'heroLogo',
child: const FlutterLogo(),
),
MaterialButton(
child: Text('Show a test dialog'),
onPressed: () {
//shows a dialog
Get.defaultDialog(
title: 'Test Dialog !!',
barrierDismissible: true,
);
},
),
MaterialButton(
child: Text('Show a test dialog in Home router outlet'),
onPressed: () {
//shows a dialog
Get.defaultDialog(
title: 'Test Dialog In Home Outlet !!',
barrierDismissible: true,
navigatorKey: Get.nestedKey(Routes.HOME),
);
},
)
],
),
),
);
}
}

View File

@@ -0,0 +1,12 @@
import 'package:get/get.dart';
import '../controllers/root_controller.dart';
class RootBinding extends Bindings {
@override
void dependencies() {
Get.lazyPut<RootController>(
() => RootController(),
);
}
}

View File

@@ -0,0 +1,20 @@
import 'package:get/get.dart';
class RootController extends GetxController {
//TODO: Implement RootController
final count = 0.obs;
@override
void onInit() {
super.onInit();
}
@override
void onReady() {
super.onReady();
}
@override
void onClose() {}
void increment() => count.value++;
}

View File

@@ -0,0 +1,74 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../../../services/auth_service.dart';
import '../../../routes/app_pages.dart';
class DrawerWidget extends StatelessWidget {
const DrawerWidget({
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Drawer(
child: Column(
children: [
Container(
height: 100,
color: Colors.red,
),
ListTile(
title: Text('Home'),
onTap: () {
Get.rootDelegate.toNamed(Routes.HOME);
//to close the drawer
Navigator.of(context).pop();
},
),
ListTile(
title: Text('Settings'),
onTap: () {
Get.rootDelegate.toNamed(Routes.SETTINGS);
//to close the drawer
Navigator.of(context).pop();
},
),
if (AuthService.to.isLoggedInValue)
ListTile(
title: Text(
'Logout',
style: TextStyle(
color: Colors.red,
),
),
onTap: () {
AuthService.to.logout();
Get.rootDelegate.toNamed(Routes.LOGIN);
//to close the drawer
Navigator.of(context).pop();
},
),
if (!AuthService.to.isLoggedInValue)
ListTile(
title: Text(
'Login',
style: TextStyle(
color: Colors.blue,
),
),
onTap: () {
Get.rootDelegate.toNamed(Routes.LOGIN);
//to close the drawer
Navigator.of(context).pop();
},
),
],
),
);
}
}

View File

@@ -0,0 +1,31 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../../routes/app_pages.dart';
import '../controllers/root_controller.dart';
import 'drawer.dart';
class RootView extends GetView<RootController> {
@override
Widget build(BuildContext context) {
return GetRouterOutlet.builder(
builder: (context, delegate, current) {
final title = current?.location;
return Scaffold(
drawer: DrawerWidget(),
appBar: AppBar(
title: Text(title ?? ''),
centerTitle: true,
),
body: GetRouterOutlet(
initialRoute: Routes.HOME,
// anchorRoute: '/',
// filterPages: (afterAnchor) {
// return afterAnchor.take(1);
// },
),
);
},
);
}
}

View File

@@ -0,0 +1,12 @@
import 'package:get/get.dart';
import '../controllers/settings_controller.dart';
class SettingsBinding extends Bindings {
@override
void dependencies() {
Get.lazyPut<SettingsController>(
() => SettingsController(),
);
}
}

View File

@@ -0,0 +1,20 @@
import 'package:get/get.dart';
class SettingsController extends GetxController {
//TODO: Implement SettingsController
final count = 0.obs;
@override
void onInit() {
super.onInit();
}
@override
void onReady() {
super.onReady();
}
@override
void onClose() {}
void increment() => count.value++;
}

View File

@@ -0,0 +1,19 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../controllers/settings_controller.dart';
class SettingsView extends GetView<SettingsController> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Text(
'SettingsView is working',
style: TextStyle(fontSize: 20),
),
),
);
}
}

View File

@@ -0,0 +1,98 @@
import 'package:get/get.dart';
import '../middleware/auth_middleware.dart';
import '../modules/dashboard/bindings/dashboard_binding.dart';
import '../modules/dashboard/views/dashboard_view.dart';
import '../modules/home/bindings/home_binding.dart';
import '../modules/home/views/home_view.dart';
import '../modules/login/bindings/login_binding.dart';
import '../modules/login/views/login_view.dart';
import '../modules/product_details/bindings/product_details_binding.dart';
import '../modules/product_details/views/product_details_view.dart';
import '../modules/products/bindings/products_binding.dart';
import '../modules/products/views/products_view.dart';
import '../modules/profile/bindings/profile_binding.dart';
import '../modules/profile/views/profile_view.dart';
import '../modules/root/bindings/root_binding.dart';
import '../modules/root/views/root_view.dart';
import '../modules/settings/bindings/settings_binding.dart';
import '../modules/settings/views/settings_view.dart';
part 'app_routes.dart';
class AppPages {
AppPages._();
static const INITIAL = Routes.HOME;
static final routes = [
GetPage(
name: '/',
page: () => RootView(),
binding: RootBinding(),
participatesInRootNavigator: true,
preventDuplicates: true,
children: [
GetPage(
middlewares: [
//only enter this route when not authed
EnsureNotAuthedMiddleware(),
],
name: _Paths.LOGIN,
page: () => LoginView(),
binding: LoginBinding(),
),
GetPage(
preventDuplicates: true,
name: _Paths.HOME,
page: () => HomeView(),
bindings: [
HomeBinding(),
],
title: null,
children: [
GetPage(
name: _Paths.DASHBOARD,
page: () => DashboardView(),
binding: DashboardBinding(),
),
GetPage(
middlewares: [
//only enter this route when authed
EnsureAuthMiddleware(),
],
name: _Paths.PROFILE,
page: () => ProfileView(),
title: 'Profile',
transition: Transition.size,
binding: ProfileBinding(),
),
GetPage(
name: _Paths.PRODUCTS,
page: () => ProductsView(),
title: 'Products',
transition: Transition.zoom,
binding: ProductsBinding(),
children: [
GetPage(
name: _Paths.PRODUCT_DETAILS,
page: () => ProductDetailsView(),
binding: ProductDetailsBinding(),
middlewares: [
//only enter this route when authed
EnsureAuthMiddleware(),
],
),
],
),
],
),
GetPage(
name: _Paths.SETTINGS,
page: () => SettingsView(),
binding: SettingsBinding(),
),
],
),
];
}

View File

@@ -0,0 +1,30 @@
// ignore_for_file: non_constant_identifier_names
part of 'app_pages.dart';
// DO NOT EDIT. This is code generated via package:get_cli/get_cli.dart
abstract class Routes {
static const HOME = _Paths.HOME;
static const PROFILE = _Paths.HOME + _Paths.PROFILE;
static const SETTINGS = _Paths.SETTINGS;
static const PRODUCTS = _Paths.HOME + _Paths.PRODUCTS;
static const LOGIN = _Paths.LOGIN;
static const DASHBOARD = _Paths.HOME + _Paths.DASHBOARD;
Routes._();
static String LOGIN_THEN(String afterSuccessfulLogin) =>
'$LOGIN?then=${Uri.encodeQueryComponent(afterSuccessfulLogin)}';
static String PRODUCT_DETAILS(String productId) => '$PRODUCTS/$productId';
}
abstract class _Paths {
static const HOME = '/home';
static const PRODUCTS = '/products';
static const PROFILE = '/profile';
static const SETTINGS = '/settings';
static const PRODUCT_DETAILS = '/:productId';
static const LOGIN = '/login';
static const DASHBOARD = '/dashboard';
}

View File

@@ -0,0 +1,27 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'app/routes/app_pages.dart';
import 'services/auth_service.dart';
void main() {
runApp(
GetMaterialApp.router(
title: "Application",
initialBinding: BindingsBuilder(
() {
Get.put(AuthService());
},
),
getPages: AppPages.routes,
// routeInformationParser: GetInformationParser(
// // initialRoute: Routes.HOME,
// ),
// routerDelegate: GetDelegate(
// backButtonPopMode: PopMode.History,
// preventDuplicateHandlingMode:
// PreventDuplicateHandlingMode.ReorderRoutes,
// ),
),
);
}

View File

@@ -0,0 +1,9 @@
class DemoProduct {
final String name;
final String id;
DemoProduct({
required this.name,
required this.id,
});
}

View File

@@ -0,0 +1,17 @@
import 'package:get/get.dart';
class AuthService extends GetxService {
static AuthService get to => Get.find();
/// Mocks a login process
final isLoggedIn = false.obs;
bool get isLoggedInValue => isLoggedIn.value;
void login() {
isLoggedIn.value = true;
}
void logout() {
isLoggedIn.value = false;
}
}