second commit
This commit is contained in:
93
lib/Globalwidgets/Googleplaces/Googleplaces.dart
Normal file
93
lib/Globalwidgets/Googleplaces/Googleplaces.dart
Normal file
@@ -0,0 +1,93 @@
|
||||
// import 'dart:convert';
|
||||
//
|
||||
// import 'package:http/http.dart' as http;
|
||||
// import 'package:gear/Helper/Logger.dart';
|
||||
// import 'package:shared_preferences/shared_preferences.dart';
|
||||
//
|
||||
//
|
||||
// class GooglePlacesService {
|
||||
//
|
||||
// String? latitude;
|
||||
// String? longitude;
|
||||
// String? city;
|
||||
// String? googleApiKey;
|
||||
// int? radius;
|
||||
//
|
||||
// GooglePlacesService();
|
||||
//
|
||||
// // Future<List<Map<String, dynamic>>> getPlacesPredictions(String input) async {
|
||||
// // final url = Uri.parse(
|
||||
// // 'https://maps.googleapis.com/maps/api/place/autocomplete/json?input=$input&key=AIzaSyCF4KatYCI3vqz1_H3kiHeyS3yCMfYToh8');
|
||||
// //
|
||||
// // final response = await http.get(url);
|
||||
// //
|
||||
// // if (response.statusCode == 200) {
|
||||
// // final predictions = json.decode(response.body)['predictions'];
|
||||
// // return List<Map<String, dynamic>>.from(predictions);
|
||||
// // } else {
|
||||
// // throw Exception('Failed to load predictions');
|
||||
// // }
|
||||
// // }
|
||||
//
|
||||
// Future<List<Map<String, dynamic>>> getPlacesPredictions(String input) async {
|
||||
// SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
// latitude = prefs.getString('appLatitude');
|
||||
// longitude = prefs.getString('appLongitude');
|
||||
// city = prefs.getString('appLocation');
|
||||
// radius = prefs.getInt('appRadius');
|
||||
// googleApiKey = prefs.getString('googleApiKey')??'AIzaSyBhkGfnq27sN0wV5y_S-M2KojpFTk_by-Q';
|
||||
//
|
||||
// logger.i(city);
|
||||
// final url = Uri.parse(
|
||||
// // 'https://maps.googleapis.com/maps/api/place/autocomplete/json?input=$input&components=country:IN&key=AIzaSyCF4KatYCI3vqz1_H3kiHeyS3yCMfYToh8');
|
||||
// 'https://maps.googleapis.com/maps/api/place/autocomplete/json?input=$input$city&location=$latitude,$longitude&radius=15000&bounds=$latitude,$longitude&components=country:IN&types=establishment&key=$googleApiKey');
|
||||
// logger.i(url);
|
||||
// final response = await http.get(url);
|
||||
//
|
||||
// if (response.statusCode == 200) {
|
||||
// final Map<String, dynamic> data = json.decode(response.body);
|
||||
// final predictions = data['predictions'] as List<dynamic>;
|
||||
// return predictions.map((prediction) => prediction as Map<String, dynamic>).toList();
|
||||
// } else {
|
||||
// throw Exception('Failed to load autocomplete suggestions');
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Future<Map<String, dynamic>> getPlaceDetails(String placeId) async {
|
||||
// SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
// googleApiKey = prefs.getString('googleApiKey')??'AIzaSyBhkGfnq27sN0wV5y_S-M2KojpFTk_by-Q';
|
||||
//
|
||||
// final url = Uri.parse(
|
||||
// 'https://maps.googleapis.com/maps/api/place/details/json?place_id=$placeId&key=$googleApiKey');
|
||||
//
|
||||
// final response = await http.get(url);
|
||||
//
|
||||
// if (response.statusCode == 200) {
|
||||
// final details = json.decode(response.body)['result'];
|
||||
// return Map<String, dynamic>.from(details);
|
||||
// } else {
|
||||
// throw Exception('Failed to load place details');
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Future<double> getDistance(double pickupLat, double pickupLong, double dropLat, double dropLong) async {
|
||||
// SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
// googleApiKey = prefs.getString('googleApiKey')??'AIzaSyBhkGfnq27sN0wV5y_S-M2KojpFTk_by-Q';
|
||||
//
|
||||
// final url =
|
||||
// 'https://maps.googleapis.com/maps/api/distancematrix/json?units=metric&origins=$pickupLat,$pickupLong&destinations=$dropLat,$dropLong&key=$googleApiKey';
|
||||
//
|
||||
// final response = await http.get(Uri.parse(url));
|
||||
//
|
||||
// if (response.statusCode == 200) {
|
||||
// final data = jsonDecode(response.body);
|
||||
// final distanceText = data['rows'][0]['elements'][0]['distance']['text'];
|
||||
// final distanceValue = data['rows'][0]['elements'][0]['distance']['value'] / 1000; // Convert meters to kilometers
|
||||
// print('Distance: $distanceText');
|
||||
// return distanceValue;
|
||||
// } else {
|
||||
// throw Exception('Failed to load distance');
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
164
lib/Globalwidgets/Localnotificationservice.dart
Normal file
164
lib/Globalwidgets/Localnotificationservice.dart
Normal file
@@ -0,0 +1,164 @@
|
||||
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:get/route_manager.dart';
|
||||
|
||||
import '../Controller/Dashboard/Tabs/Completedordercontroller.dart';
|
||||
import '../Controller/Dashboard/Tabs/Ongoingordercontroller.dart';
|
||||
import '../Controller/Dashboard/Tabs/Ordercontroller.dart';
|
||||
import '../View/Home/Homeview.dart';
|
||||
import '../maindev.dart';
|
||||
|
||||
|
||||
|
||||
class LocalNotificationService {
|
||||
|
||||
|
||||
static final instance = FirebaseMessaging.instance;
|
||||
static final FlutterLocalNotificationsPlugin _notificationsPlugin =
|
||||
FlutterLocalNotificationsPlugin();
|
||||
int? moduleId;
|
||||
String? notificationOrderId;
|
||||
int? locationId;
|
||||
static void setValues(message){
|
||||
|
||||
}
|
||||
|
||||
static void initialize(BuildContext context) async{
|
||||
|
||||
instance.requestPermission(
|
||||
alert: true,
|
||||
badge: true,
|
||||
sound: true,
|
||||
);
|
||||
await _notificationsPlugin.resolvePlatformSpecificImplementation<AndroidFlutterLocalNotificationsPlugin>()?.createNotificationChannel(channel);
|
||||
final DarwinInitializationSettings initializationSettingsIOS = DarwinInitializationSettings(
|
||||
requestSoundPermission: false,
|
||||
requestBadgePermission: false,
|
||||
requestAlertPermission: false,
|
||||
);
|
||||
final InitializationSettings initializationSettings =
|
||||
InitializationSettings(
|
||||
android: AndroidInitializationSettings("ic_launcher"),
|
||||
iOS: initializationSettingsIOS
|
||||
);
|
||||
|
||||
_notificationsPlugin.initialize(
|
||||
initializationSettings,
|
||||
onDidReceiveNotificationResponse: (NotificationResponse response) {
|
||||
if (response.payload != null) {
|
||||
selectNotification(response.payload!);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// TextToSpeech tts = TextToSpeech();
|
||||
|
||||
CurrentOrderController currentOrderController = Get.put(CurrentOrderController());
|
||||
OnGoingOrderController onGoingOrderController = Get.put(OnGoingOrderController());
|
||||
CompletedOrderController completedOrderController = Get.put(CompletedOrderController()) ;
|
||||
|
||||
|
||||
FirebaseMessaging.instance.getInitialMessage().then((message) async{
|
||||
if (message != null) {
|
||||
|
||||
RemoteNotification notification = message.notification!;
|
||||
AndroidNotification? android = message.notification?.android;
|
||||
if (android != null) {
|
||||
|
||||
display(message);
|
||||
currentOrderController.getOrder('created');
|
||||
onGoingOrderController.getCurrentOrder();
|
||||
completedOrderController.getCompletedOrder();
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FirebaseMessaging.onMessage.listen((RemoteMessage message) async{
|
||||
print('message before data ');
|
||||
print(message.data);
|
||||
RemoteNotification notification = message.notification!;
|
||||
AndroidNotification? android = message.notification?.android;
|
||||
print('message before if data ');
|
||||
|
||||
if (android != null) {
|
||||
|
||||
display(message);
|
||||
currentOrderController.getOrder('created');
|
||||
onGoingOrderController.getCurrentOrder();
|
||||
completedOrderController.getCompletedOrder();
|
||||
|
||||
print('message after if data ');
|
||||
}
|
||||
});
|
||||
|
||||
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) async{
|
||||
print('A new onMessageOpenedApp event was published!');
|
||||
// message.data['orderid'];
|
||||
RemoteNotification? notification = message.notification;
|
||||
AndroidNotification? android = message.notification?.android;
|
||||
if (notification != null && android != null) {
|
||||
|
||||
Get.to(()=> HomeView(selectedIndex: 0,));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
static Future<dynamic> selectNotification(String? payload) async {
|
||||
|
||||
try {
|
||||
Get.to(()=> HomeView(selectedIndex: 0,));
|
||||
} on Exception catch (e) {
|
||||
print(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void display(RemoteMessage message) async {
|
||||
print('message notification${message.notification}');
|
||||
print('message mutableContent${message.mutableContent}');
|
||||
|
||||
try {
|
||||
final id = DateTime.now().millisecondsSinceEpoch ~/1000;
|
||||
|
||||
|
||||
final NotificationDetails notificationDetails = NotificationDetails(
|
||||
|
||||
android: AndroidNotificationDetails(
|
||||
"Nearlexpress Business",
|
||||
"Nearlexpress Business Notification",
|
||||
importance: Importance.max,
|
||||
priority: Priority.high,
|
||||
icon: 'ic_launcher',
|
||||
playSound: true,
|
||||
sound: RawResourceAndroidNotificationSound('ring'),
|
||||
largeIcon: const DrawableResourceAndroidBitmap('ic_launcher'),
|
||||
vibrationPattern: Int64List.fromList([500, 1000, 500]),
|
||||
enableVibration:true,
|
||||
),
|
||||
);
|
||||
|
||||
await _notificationsPlugin.show(
|
||||
id,
|
||||
message.notification!.title,
|
||||
message.notification!.body,
|
||||
notificationDetails,
|
||||
payload: message.data.toString(),
|
||||
);
|
||||
} on Exception catch (e) {
|
||||
print(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
11
lib/Globalwidgets/binding.dart
Normal file
11
lib/Globalwidgets/binding.dart
Normal file
@@ -0,0 +1,11 @@
|
||||
import 'package:get/get.dart';
|
||||
import '../Controller/Authentication/Authcontroller.dart';
|
||||
import '../Controller/Dashboard/Dashboardcontroller.dart';
|
||||
|
||||
class GlobalBinding implements Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut<DashboardController>(() => DashboardController());
|
||||
Get.lazyPut<AuthController>(() => AuthController(),fenix: true);
|
||||
}
|
||||
}
|
||||
52
lib/Globalwidgets/textwidget.dart
Normal file
52
lib/Globalwidgets/textwidget.dart
Normal file
@@ -0,0 +1,52 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../Helper/Constants/Colorconstants.dart';
|
||||
|
||||
class TextWidget extends StatelessWidget {
|
||||
final String text;
|
||||
final double? fontSize;
|
||||
final double? textHeight;
|
||||
final String? fontFamily;
|
||||
final FontWeight? fontWeight;
|
||||
final FontStyle? fontStyle;
|
||||
final Color? color;
|
||||
final TextAlign? textAlign;
|
||||
final int? maxLines;
|
||||
final TextDecoration? isUnderText;
|
||||
|
||||
const TextWidget({
|
||||
super.key,
|
||||
required this.text,
|
||||
this.fontSize,
|
||||
this.textHeight,
|
||||
this.fontFamily,
|
||||
this.fontWeight,
|
||||
this.fontStyle,
|
||||
this.color,
|
||||
this.textAlign,
|
||||
this.maxLines,
|
||||
this.isUnderText,
|
||||
});
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
fontSize: fontSize ?? 13,
|
||||
decoration: isUnderText,
|
||||
fontFamily: fontFamily ?? 'Lato',
|
||||
decorationColor: color,
|
||||
fontWeight: fontWeight ?? FontWeight.normal,
|
||||
fontStyle: fontStyle ?? FontStyle.normal,
|
||||
color: color ?? Colors.black,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
height: textHeight,
|
||||
),
|
||||
maxLines: maxLines,
|
||||
textAlign: textAlign ?? TextAlign.start,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
65
lib/Globalwidgets/web_view.dart
Normal file
65
lib/Globalwidgets/web_view.dart
Normal file
@@ -0,0 +1,65 @@
|
||||
import 'package:NearleDailyBusiness/Globalwidgets/textwidget.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get/get_core/src/get_main.dart';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
|
||||
import '../Controller/More/web_view_controller.dart';
|
||||
import '../Helper/Constants/Colorconstants.dart';
|
||||
|
||||
class WebViewApp extends StatelessWidget {
|
||||
final String url;
|
||||
final String appBarText;
|
||||
|
||||
const WebViewApp({
|
||||
super.key,
|
||||
required this.url,
|
||||
required this.appBarText,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final controller = Get.put(WebViewAppController());
|
||||
controller.initializeWebViewController(url);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
automaticallyImplyLeading: false,
|
||||
backgroundColor: ColorConstants.primaryColor,
|
||||
title: Row(
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Get.back();
|
||||
},
|
||||
child: const Icon(
|
||||
Icons.arrow_back_ios,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 5,),
|
||||
TextWidget(
|
||||
text: appBarText,
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Colors.white,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
body: Stack(
|
||||
children: [
|
||||
WebViewWidget(
|
||||
controller: controller.webViewController,
|
||||
),
|
||||
Obx(() {
|
||||
return controller.isLoading.value
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: const SizedBox.shrink();
|
||||
}),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user