new change to use intaleq_map sdk 04-16-4
This commit is contained in:
@@ -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(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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()}'),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class HomeController extends GetxController {}
|
||||
@@ -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',
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class LoginController extends GetxController {}
|
||||
@@ -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);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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'] ?? '',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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}')
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class ProfileController extends GetxController {}
|
||||
@@ -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),
|
||||
);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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++;
|
||||
}
|
||||
@@ -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();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
// },
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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++;
|
||||
}
|
||||
@@ -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),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user