Commit b2fb65e0 by Ramesh Babu Puvvadi

added new changes

parent f4cbf453
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
<array> <array>
<string>tel</string> <string>tel</string>
</array> </array>
<key>NSAppleMusicUsageDescription</key>
<string>This app requires access to your music usage description</string>
<key>NSCameraUsageDescription</key> <key>NSCameraUsageDescription</key>
<string>Camera access is required to capture</string> <string>Camera access is required to capture</string>
<key>NSPhotoLibraryAddUsageDescription</key> <key>NSPhotoLibraryAddUsageDescription</key>
......
...@@ -3,8 +3,8 @@ import 'package:firebase_messaging/firebase_messaging.dart'; ...@@ -3,8 +3,8 @@ import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
class FirebaseApi { class FirebaseApi {
final _firebasemessaging = FirebaseMessaging.instance;
final _firebasemessaging = FirebaseMessaging.instance;
Future<void> initNotifications() async { Future<void> initNotifications() async {
await _firebasemessaging.requestPermission(); await _firebasemessaging.requestPermission();
final fcmToken = await _firebasemessaging.getToken(); final fcmToken = await _firebasemessaging.getToken();
...@@ -15,8 +15,11 @@ class FirebaseApi { ...@@ -15,8 +15,11 @@ class FirebaseApi {
Future<void> handleBackgroundMessage(RemoteMessage message) async { Future<void> handleBackgroundMessage(RemoteMessage message) async {
await Firebase.initializeApp(); await Firebase.initializeApp();
//print('Title :${message.notification?.title}'); if (kDebugMode) {
//print('Title :${message.notification?.body}'); print('Firebase title :${message.notification?.title}');
//print('Title :${message.data}'); print('Firebase body :${message.notification?.body}');
print('Firebase data :${message.data}');
} }
}
} }
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:storemonitor/Screens/Constants.dart'; import 'package:storemonitor/Screens/Constants.dart';
import 'package:video_player/video_player.dart'; import 'package:video_player/video_player.dart';
...@@ -7,10 +8,7 @@ class VideoApp extends StatefulWidget { ...@@ -7,10 +8,7 @@ class VideoApp extends StatefulWidget {
final String id; final String id;
final String comment; final String comment;
const VideoApp({Key? key, const VideoApp({Key? key, required this.message, required this.id, required this.comment}): super(key: key);
required this.message,
required this.id,
required this.comment}): super(key: key);
@override @override
_VideoAppState createState() => _VideoAppState(); _VideoAppState createState() => _VideoAppState();
...@@ -26,39 +24,17 @@ class _VideoAppState extends State<VideoApp> { ...@@ -26,39 +24,17 @@ class _VideoAppState extends State<VideoApp> {
void initState() { void initState() {
super.initState(); super.initState();
isdata = widget.message; isdata = widget.message;
//List<String> parts = isdata.split('/');
// // Find the part that contains the file ID
// String? fileId;
// for (String part in parts) {
// if (part.startsWith('d/')) {
// fileId = part.substring(2);
// print('if Condition: $fileId');
// break;
// }
// }
// if (fileId != null) {
// print('File ID: $fileId');
// } else {
// print('File ID not found in the link');
// }
String googleDriveFileUrl = isdata; String googleDriveFileUrl = isdata;
// Split the URL by '/'
List<String> urlParts = googleDriveFileUrl.split('/'); List<String> urlParts = googleDriveFileUrl.split('/');
int indexOfD = urlParts.indexOf('d'); int indexOfD = urlParts.indexOf('d');
// The file ID is the part after 'd'
String fileId = urlParts.elementAt(indexOfD + 1); String fileId = urlParts.elementAt(indexOfD + 1);
//print('Testing : $urlParts[5]'); if (kDebugMode) {
// The fileId is the first part after the last '/'
//String fileId = urlParts.last;
print('File ID: $fileId'); print('File ID: $fileId');
}
videoUrl = 'https://drive.google.com/uc?export=view&id=$fileId'; videoUrl = 'https://drive.google.com/uc?export=view&id=$fileId';
if (kDebugMode) {
print('VideoLink : $videoUrl'); print('VideoLink : $videoUrl');
}
_controller = VideoPlayerController.networkUrl(Uri.parse(videoUrl)) _controller = VideoPlayerController.networkUrl(Uri.parse(videoUrl))
..initialize().then((_) { ..initialize().then((_) {
setState(() { setState(() {
...@@ -68,6 +44,7 @@ class _VideoAppState extends State<VideoApp> { ...@@ -68,6 +44,7 @@ class _VideoAppState extends State<VideoApp> {
}); });
}); });
} }
// void _initializeVideoPlayer() async { // void _initializeVideoPlayer() async {
// videoUrl = // videoUrl =
// 'https://drive.google.com/uc?export=view&id=1QVUJ34BKRilfchA_0ppmM3gFIPvYIl7i'; // 'https://drive.google.com/uc?export=view&id=1QVUJ34BKRilfchA_0ppmM3gFIPvYIl7i';
......
...@@ -386,26 +386,18 @@ class _SpeechSampleAppState extends State<SpeechSampleApp1> { ...@@ -386,26 +386,18 @@ class _SpeechSampleAppState extends State<SpeechSampleApp1> {
lastError = ''; lastError = '';
final pauseFor = int.tryParse(_pauseForController.text); final pauseFor = int.tryParse(_pauseForController.text);
final listenFor = int.tryParse(_listenForController.text); final listenFor = int.tryParse(_listenForController.text);
final options = SpeechListenOptions( final options = SpeechListenOptions(onDevice: _onDevice,listenMode: ListenMode.confirmation,cancelOnError: true, partialResults: true,autoPunctuation: true,enableHapticFeedback: true );
onDevice: _onDevice,
listenMode: ListenMode.confirmation,
cancelOnError: true,
partialResults: true,
autoPunctuation: true,
enableHapticFeedback: true);
// Note that `listenFor` is the maximum, not the minimum, on some
// systems recognition will be stopped before this value is reached.
// Similarly `pauseFor` is a maximum not a minimum and may be ignored
// on some devices.
speech.listen( speech.listen(
onResult: resultListener, onResult : resultListener,
listenFor: Duration(seconds: listenFor ?? 30), listenFor: Duration(seconds: listenFor ?? 30),
pauseFor: Duration(seconds: pauseFor ?? 3), pauseFor : Duration(seconds: pauseFor ?? 3),
localeId: _currentLocaleId, localeId : _currentLocaleId,
onSoundLevelChange: soundLevelListener, onSoundLevelChange: soundLevelListener,
listenOptions: options, listenOptions: options,
); );
setState(() {}); setState(() {});
} }
void stopListening() { void stopListening() {
...@@ -426,21 +418,18 @@ class _SpeechSampleAppState extends State<SpeechSampleApp1> { ...@@ -426,21 +418,18 @@ class _SpeechSampleAppState extends State<SpeechSampleApp1> {
// This callback is invoked each time new recognition results are // This callback is invoked each time new recognition results are
// available after `listen` is called. // available after `listen` is called.
void resultListener(SpeechRecognitionResult result) { void resultListener(SpeechRecognitionResult result) {
_logEvent( _logEvent('Result listener final: ${result.finalResult}, words: ${result.recognizedWords}');
'Result listener final: ${result.finalResult}, words: ${result.recognizedWords}');
if (kDebugMode) { if (kDebugMode) {
print( print('\nTesting listener final: ${result.finalResult}, words: ${result.recognizedWords}');
'\nTesting listener final: ${result.finalResult}, words: ${result.recognizedWords}');
} }
setState(() async { setState(() async {
//lastWords = '${result.recognizedWords} - ${result.finalResult}';
lastWords = result.recognizedWords; lastWords = result.recognizedWords;
if (result.finalResult) { if (result.finalResult) {
if (kDebugMode) { if (kDebugMode) {
print('Final Result: $lastWords'); print('Final Result: $lastWords');
} }
//await Future.delayed(Duration.zero);
remotevalidate(lastWords); remotevalidate(lastWords);
} }
}); });
...@@ -449,23 +438,20 @@ class _SpeechSampleAppState extends State<SpeechSampleApp1> { ...@@ -449,23 +438,20 @@ class _SpeechSampleAppState extends State<SpeechSampleApp1> {
void soundLevelListener(double level) { void soundLevelListener(double level) {
minSoundLevel = min(minSoundLevel, level); minSoundLevel = min(minSoundLevel, level);
maxSoundLevel = max(maxSoundLevel, level); maxSoundLevel = max(maxSoundLevel, level);
// _logEvent('sound level $level: $minSoundLevel - $maxSoundLevel ');
setState(() { setState(() {
this.level = level; this.level = level;
}); });
} }
void errorListener(SpeechRecognitionError error) { void errorListener(SpeechRecognitionError error) {
_logEvent( _logEvent('Received error status: $error, listening: ${speech.isListening}');
'Received error status: $error, listening: ${speech.isListening}');
setState(() { setState(() {
lastError = '${error.errorMsg} - ${error.permanent}'; lastError = '${error.errorMsg} - ${error.permanent}';
}); });
} }
void statusListener(String status) { void statusListener(String status) {
_logEvent( _logEvent('Received listener status: $status, listening: ${speech.isListening}');
'Received listener status: $status, listening: ${speech.isListening}');
setState(() { setState(() {
lastStatus = status; lastStatus = status;
}); });
...@@ -478,6 +464,7 @@ class _SpeechSampleAppState extends State<SpeechSampleApp1> { ...@@ -478,6 +464,7 @@ class _SpeechSampleAppState extends State<SpeechSampleApp1> {
// debugPrint(selectedVal); // debugPrint(selectedVal);
//} //}
void _logEvent(String eventDescription) { void _logEvent(String eventDescription) {
if (_logEvents) { if (_logEvents) {
var eventTime = DateTime.now().toIso8601String(); var eventTime = DateTime.now().toIso8601String();
...@@ -511,8 +498,7 @@ class _SpeechSampleAppState extends State<SpeechSampleApp1> { ...@@ -511,8 +498,7 @@ class _SpeechSampleAppState extends State<SpeechSampleApp1> {
if (kDebugMode) { if (kDebugMode) {
print('DataFetching1 $zoneValue'); print('DataFetching1 $zoneValue');
} }
Data dataInstance = Data dataInstance = Data(question: lastWords, answer: zoneValue, image: 'None');
Data(question: lastWords, answer: zoneValue, image: 'None');
await ftts.setLanguage('en-IN'); await ftts.setLanguage('en-IN');
//await ftts.setLanguage("en-IN"); //await ftts.setLanguage("en-IN");
await ftts.setSpeechRate(0.5); //speed of speech await ftts.setSpeechRate(0.5); //speed of speech
...@@ -525,20 +511,14 @@ class _SpeechSampleAppState extends State<SpeechSampleApp1> { ...@@ -525,20 +511,14 @@ class _SpeechSampleAppState extends State<SpeechSampleApp1> {
print(await ftts.getVoices); print(await ftts.getVoices);
} }
await ftts.setVoice({'name': 'Rishi', 'locale': 'en-IN'}); await ftts.setVoice({'name': 'Rishi', 'locale': 'en-IN'});
//await ftts.setVoice(ftts.getDefaultVoice());
//await ftts.setIosAudioCategory(
//[IosTextToSpeechAudioCategory.playAndRecord,
//IosTextToSpeechAudioCategoryOptions.defaultToSpeaker],
//);
await ftts.setIosAudioCategory( await ftts.setIosAudioCategory(
IosTextToSpeechAudioCategory.playback, IosTextToSpeechAudioCategory.playback,
[ [ IosTextToSpeechAudioCategoryOptions.allowBluetooth,
IosTextToSpeechAudioCategoryOptions.allowBluetooth,
IosTextToSpeechAudioCategoryOptions.allowBluetoothA2DP, IosTextToSpeechAudioCategoryOptions.allowBluetoothA2DP,
IosTextToSpeechAudioCategoryOptions.mixWithOthers, IosTextToSpeechAudioCategoryOptions.mixWithOthers,
IosTextToSpeechAudioCategoryOptions.defaultToSpeaker IosTextToSpeechAudioCategoryOptions.defaultToSpeaker ],
], IosTextToSpeechAudioMode.defaultMode
IosTextToSpeechAudioMode.defaultMode); );
} else { } else {
await ftts.setVoice({'name': ' Rishi', "locale": "en-IN"}); await ftts.setVoice({'name': ' Rishi', "locale": "en-IN"});
} }
...@@ -589,7 +569,6 @@ class _SpeechSampleAppState extends State<SpeechSampleApp1> { ...@@ -589,7 +569,6 @@ class _SpeechSampleAppState extends State<SpeechSampleApp1> {
setState(() { setState(() {
data = data; data = data;
}); });
lastWords = ''; lastWords = '';
setState(() {}); setState(() {});
} }
......
...@@ -109,6 +109,7 @@ class _CheckRegistration extends State<CheckRegistration> { ...@@ -109,6 +109,7 @@ class _CheckRegistration extends State<CheckRegistration> {
), ),
), ),
), ),
// ElevatedButton( // ElevatedButton(
// onPressed: () { // onPressed: () {
// if (_empId.text.isNotEmpty) { // if (_empId.text.isNotEmpty) {
...@@ -171,11 +172,11 @@ class _CheckRegistration extends State<CheckRegistration> { ...@@ -171,11 +172,11 @@ class _CheckRegistration extends State<CheckRegistration> {
_empId.text == ''; _empId.text == '';
_empId.clear(); _empId.clear();
Constants('Check Registration', 'Registered Sucessfully') Constants('Check Registration', 'Registered Sucessfully')
.showAlertDialog(context, false); .showAlertDialog(context, true);
} else { } else {
Navigator.pop(context); Navigator.pop(context);
Constants('Check Registration', 'Registation Failed') Constants('Check Registration', 'Registation Failed')
.showAlertDialog(context, false); .showAlertDialog(context, true);
file.delete(); file.delete();
//Navigator.of(context).pop(); //Navigator.of(context).pop();
} }
......
import 'dart:convert'; import 'dart:convert';
import 'dart:math';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
...@@ -27,23 +28,22 @@ class Home extends StatefulWidget { ...@@ -27,23 +28,22 @@ class Home extends StatefulWidget {
} }
class _Home extends State<Home> { class _Home extends State<Home> {
String? selectedRegion;
String? selectedDropdownItem = ''; String? selectedDropdownItem = '';
String? empId;
List<String>? namesList;
List<String> storeNames = []; List<String> storeNames = [];
List<Store> stores = []; List<Store> stores = [];
List<String> regions = []; List<String> regions = [];
late List<GDPData> _chartData;
DateTime _selectedDate = DateTime.now(); DateTime _selectedDate = DateTime.now();
final TextEditingController _dateTime = TextEditingController();
bool isAuthenticated = false; bool isAuthenticated = false;
bool iswarehouserelated = false; bool iswarehouserelated = false;
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>(); final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
final _controller = TextEditingController(); final _controller = TextEditingController();
List<Insight>? insightslist = []; List<Insight>? insightslist = [];
bool isSwitched = false; bool isSwitched = false;
String? empId;
late List<GDPData> _chartData;
String? selectedRegion;
List<String>? namesList;
final TextEditingController _dateTime = TextEditingController();
@override @override
void initState() { void initState() {
super.initState(); super.initState();
...@@ -52,15 +52,22 @@ class _Home extends State<Home> { ...@@ -52,15 +52,22 @@ class _Home extends State<Home> {
_selectedDate = DateTime.now(); _selectedDate = DateTime.now();
_dateTime.text = DateFormat('yyyy/MM/dd').format(_selectedDate); _dateTime.text = DateFormat('yyyy/MM/dd').format(_selectedDate);
} }
loadData() async { loadData() async {
SharedPreferences prefs = await SharedPreferences.getInstance(); SharedPreferences prefs = await SharedPreferences.getInstance();
if (prefs.getString('access') == 'DIRECTOR') {
setState(() {
isAuthenticated = true;
});
} else {
setState(() {
isAuthenticated = false;
});
}
String? userId = prefs.getString("stores_list"); String? userId = prefs.getString("stores_list");
empId = prefs.getString('empId'); empId = prefs.getString('empId');
if (kDebugMode) { if (kDebugMode) {
print(empId); print(empId);
} }
final List<dynamic> jsonResponse = json.decode(userId!); final List<dynamic> jsonResponse = json.decode(userId!);
if (kDebugMode) { if (kDebugMode) {
print(jsonResponse); print(jsonResponse);
...@@ -70,28 +77,26 @@ class _Home extends State<Home> { ...@@ -70,28 +77,26 @@ class _Home extends State<Home> {
print(stores); print(stores);
} }
// Get unique regions // Get unique regions
if(isAuthenticated){
regions = stores.map((store) => store.region).toSet().toList(); regions = stores.map((store) => store.region).toSet().toList();
//print(regions);
selectedRegion = regions[0]; selectedRegion = regions[0];
updateStoreNames(selectedRegion!); updateStoreNames(selectedRegion!);
setState(() {}); setState((){
});
selectedDropdownItem = storeNames[0];
getupdateData(selectedDropdownItem,empId!);
}else{
updateStores();
selectedDropdownItem = storeNames[0];
getupdateData(selectedDropdownItem,empId!);
}
//namesList = (json.decode(userId!) as List<dynamic>) //namesList = (json.decode(userId!) as List<dynamic>)
//.map((map) => map['name'] as String) //.map((map) => map['name'] as String)
//.toList(); //.toList();
selectedDropdownItem = storeNames[0]; if(selectedDropdownItem == 'WH KISMATPUR' ||
getupdateData(selectedDropdownItem);
if (prefs.getString('access') == 'ADMIN' ||
prefs.getString('access') == 'MANAGER') {
setState(() {
isAuthenticated = true;
});
} else {
setState(() {
isAuthenticated = false;
});
}
if (selectedDropdownItem == 'WH KISMATPUR' ||
selectedDropdownItem == 'WH BANGALORE' || selectedDropdownItem == 'WH BANGALORE' ||
selectedDropdownItem == 'WH VIJAYAWADA' || selectedDropdownItem == 'WH VIJAYAWADA' ||
selectedDropdownItem == 'WH KANCHI') { selectedDropdownItem == 'WH KANCHI') {
...@@ -102,45 +107,58 @@ class _Home extends State<Home> { ...@@ -102,45 +107,58 @@ class _Home extends State<Home> {
} }
Future<void> _selectDate(BuildContext context) async { Future<void> _selectDate(BuildContext context) async {
final DateTime? picked = await showDatePicker( final DateTime? picked = await showDatePicker (
context: context, context: context,
initialDate: _selectedDate, initialDate: _selectedDate,
firstDate: DateTime(1900), firstDate: DateTime(1900),
lastDate: DateTime.now(), lastDate: DateTime.now(),
builder: (context, child) { builder: (context, child) {
return Theme( return Theme (
data: Theme.of(context).copyWith( data: Theme.of(context).copyWith (
colorScheme: const ColorScheme.light( colorScheme: const ColorScheme.light (
primary: Color.fromARGB(255, 125, 50, 253), primary: Color.fromARGB(255, 125, 50, 253),
onPrimary: Colors.white, onPrimary: Colors.white,
onSurface: Colors.black, onSurface: Colors.black,
), ),
textButtonTheme: TextButtonThemeData( textButtonTheme: TextButtonThemeData (
style: TextButton.styleFrom( style: TextButton.styleFrom (
foregroundColor: const Color.fromARGB(255, 125, 50, 253), foregroundColor: const Color.fromARGB(255, 125, 50, 253),
), ),
), ),
), ),
child: child!, child: child!,
); );
}); }
);
setState(() { setState(() {
_selectedDate = picked!; _selectedDate = picked!;
_dateTime.text = _dateTime.text =
'${_selectedDate.year}/${_selectedDate.month}/${_selectedDate.day}'; '${_selectedDate.year}/${_selectedDate.month}/${_selectedDate.day}';
getupdateData(selectedDropdownItem); getupdateData(selectedDropdownItem,empId!);
}); });
} }
void updateStoreNames(String region) { void updateStoreNames(String region) {
storeNames = stores storeNames = ['All', ...stores
.where((store) => store.region == region) .where((store) => store.region == region)
.map((store) => store.storename) .map((store) => store.storename)
.toList(); .toList()];
selectedDropdownItem = storeNames[0]; // Reset the selected store selectedDropdownItem = storeNames[0]; // Reset the selected store
setState(() { setState(() {
getupdateData(selectedDropdownItem); getupdateData(selectedDropdownItem,empId!);
});
}
void updateStores() {
storeNames = stores.map((store) => store.storename).toList();
print('Testing Selecting Store :$storeNames');
selectedDropdownItem = storeNames[0]; // Reset the selected store
print('Testing Selecting Store :$selectedDropdownItem');
setState(() {
getupdateData(selectedDropdownItem,empId!);
}); });
} }
...@@ -188,7 +206,6 @@ class _Home extends State<Home> { ...@@ -188,7 +206,6 @@ class _Home extends State<Home> {
if (kDebugMode) { if (kDebugMode) {
print('force press down'); print('force press down');
} }
//Navigator.pop(context);
}, },
child: Container( child: Container(
margin: const EdgeInsets.all(12.0), margin: const EdgeInsets.all(12.0),
...@@ -196,7 +213,8 @@ class _Home extends State<Home> { ...@@ -196,7 +213,8 @@ class _Home extends State<Home> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
Container( Visibility(visible: isAuthenticated,
child:Container(
padding: const EdgeInsets.symmetric(horizontal: 10.0), padding: const EdgeInsets.symmetric(horizontal: 10.0),
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.all(color: Colors.grey), border: Border.all(color: Colors.grey),
...@@ -223,6 +241,7 @@ class _Home extends State<Home> { ...@@ -223,6 +241,7 @@ class _Home extends State<Home> {
), ),
), ),
), ),
),
const SizedBox( const SizedBox(
height: 15, height: 15,
width: 1, width: 1,
...@@ -240,15 +259,7 @@ class _Home extends State<Home> { ...@@ -240,15 +259,7 @@ class _Home extends State<Home> {
onChanged: (newValue) { onChanged: (newValue) {
setState(() { setState(() {
selectedDropdownItem = newValue; selectedDropdownItem = newValue;
getupdateData(selectedDropdownItem); getupdateData(selectedDropdownItem,empId!);
// if (selectedDropdownItem == 'WH KISMATPUR' ||
// selectedDropdownItem == 'WH BANGALORE' ||
// selectedDropdownItem == 'WH VIJAYAWADA' ||
// selectedDropdownItem == 'WH KANCHI') {
// iswarehouserelated = true;
// } else {
// iswarehouserelated = false;
// }
}); });
}, },
items: storeNames.map((item) { items: storeNames.map((item) {
...@@ -271,8 +282,7 @@ class _Home extends State<Home> { ...@@ -271,8 +282,7 @@ class _Home extends State<Home> {
readOnly: true, readOnly: true,
onTap: () {}, onTap: () {},
decoration: InputDecoration( decoration: InputDecoration(
contentPadding: const EdgeInsets.symmetric( contentPadding: const EdgeInsets.symmetric(vertical: 15, horizontal: 10),
vertical: 15, horizontal: 10),
isDense: true, isDense: true,
hintText: 'Select date', hintText: 'Select date',
border: OutlineInputBorder( border: OutlineInputBorder(
...@@ -289,9 +299,16 @@ class _Home extends State<Home> { ...@@ -289,9 +299,16 @@ class _Home extends State<Home> {
), ),
), ),
const SizedBox(height: 10), const SizedBox(height: 10),
const Text('AI Powered Insights', Visibility(
visible: isAuthenticated,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'AI Powered Insights',
textAlign: TextAlign.right, textAlign: TextAlign.right,
style: Constants.headerfontStyle), style: Constants.headerfontStyle,
),
const SizedBox( const SizedBox(
width: 0, width: 0,
height: 5, height: 5,
...@@ -305,7 +322,6 @@ class _Home extends State<Home> { ...@@ -305,7 +322,6 @@ class _Home extends State<Home> {
height: 15, height: 15,
width: 1, width: 1,
), ),
SizedBox( SizedBox(
height: MediaQuery.of(context).size.height * 0.15, height: MediaQuery.of(context).size.height * 0.15,
child: ListView.builder( child: ListView.builder(
...@@ -325,9 +341,7 @@ class _Home extends State<Home> { ...@@ -325,9 +341,7 @@ class _Home extends State<Home> {
builder: (BuildContext context) { builder: (BuildContext context) {
return AlertDialog( return AlertDialog(
title: const Text('View Insights'), title: const Text('View Insights'),
content: Text( content: Text(Constants.capitalizeFirstLetter(insightslist![index].content)),
Constants.capitalizeFirstLetter(
insightslist![index].content)),
actions: <Widget>[ actions: <Widget>[
ToggleSwitch( ToggleSwitch(
minWidth: 90.0, minWidth: 90.0,
...@@ -363,13 +377,12 @@ class _Home extends State<Home> { ...@@ -363,13 +377,12 @@ class _Home extends State<Home> {
Padding( Padding(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
vertical: 2.0, horizontal: 2.0), vertical: 2.0, horizontal: 2.0),
child: Row(children: [ child: Row(
children: [
SizedBox( SizedBox(
width: MediaQuery.of(context).size.width * width: MediaQuery.of(context).size.width * 0.68,
0.68,
child: Text( child: Text(
Constants.capitalizeFirstLetter( Constants.capitalizeFirstLetter(insightslist![index].heading),
insightslist![index].heading),
style: Constants.headerlistitems1, style: Constants.headerlistitems1,
maxLines: 2, maxLines: 2,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
...@@ -377,36 +390,17 @@ class _Home extends State<Home> { ...@@ -377,36 +390,17 @@ class _Home extends State<Home> {
), ),
), ),
SizedBox( SizedBox(
width: MediaQuery.of(context).size.width * width: MediaQuery.of(context).size.width * 0.22,
0.22,
child: IconButton( child: IconButton(
icon: const Icon( icon: const Icon(
false Icons.visibility_off, // or Icons.visibility
? Icons.visibility
: Icons.visibility_off,
// You can customize the color, size, and other properties of the icon as needed
), ),
onPressed: () {}, onPressed: () {},
), ),
), ),
]), ],
),
), ),
// const VerticalDivider(
// width: 1.0,
// color: Colors.white,
// ),
// SizedBox(
// width:
// MediaQuery.of(context).size.width / 0.8,
// height: 100,
// child: Text(
// insightslist![index].ins2.last,
// style: Constants.headerlistitems,
// overflow: TextOverflow.ellipsis,
// textAlign: TextAlign.left,
// //softWrap: true,
// ),
// ),
const VerticalDivider( const VerticalDivider(
width: 1.0, width: 1.0,
color: Colors.white, color: Colors.white,
...@@ -419,6 +413,10 @@ class _Home extends State<Home> { ...@@ -419,6 +413,10 @@ class _Home extends State<Home> {
}, },
), ),
), ),
],
),
),
const SizedBox(height: 10), const SizedBox(height: 10),
const Text('AI Alert Status', const Text('AI Alert Status',
textAlign: TextAlign.right, textAlign: TextAlign.right,
...@@ -621,10 +619,7 @@ class _Home extends State<Home> { ...@@ -621,10 +619,7 @@ class _Home extends State<Home> {
margin: const EdgeInsets.only( margin: const EdgeInsets.only(
left: 0, top: 0, right: 0, bottom: 0), left: 0, top: 0, right: 0, bottom: 0),
width: MediaQuery.of(context).size.width * 0.44, width: MediaQuery.of(context).size.width * 0.44,
//visible: isAuthenticated,
child: Container( child: Container(
//height: MediaQuery.of(context).size.width * 0.12,
padding: const EdgeInsets.all(1), padding: const EdgeInsets.all(1),
decoration: BoxDecoration( decoration: BoxDecoration(
gradient: const LinearGradient( gradient: const LinearGradient(
...@@ -632,7 +627,6 @@ class _Home extends State<Home> { ...@@ -632,7 +627,6 @@ class _Home extends State<Home> {
end: Alignment.bottomCenter, end: Alignment.bottomCenter,
colors: [ colors: [
Color.fromARGB(255, 170, 133, 220), Color.fromARGB(255, 170, 133, 220),
//Color(0xFFC2185B),
Color.fromARGB(255, 201, 175, 236), Color.fromARGB(255, 201, 175, 236),
], ],
), ),
...@@ -642,15 +636,14 @@ class _Home extends State<Home> { ...@@ -642,15 +636,14 @@ class _Home extends State<Home> {
controller: _controller, controller: _controller,
readOnly: true, readOnly: true,
enabled: false, enabled: false,
decoration: const InputDecoration( decoration: const InputDecoration(border: InputBorder.none),
border: InputBorder.none),
style: Constants.whitefontStyle, style: Constants.whitefontStyle,
textAlign: TextAlign.left, textAlign: TextAlign.left,
onEditingComplete: () { onEditingComplete: () {
FocusScope.of(context) FocusScope.of(context).unfocus(); // remove the focus from the TextFormField
.unfocus(); // remove the focus from the TextFormField
}, },
)), ),
),
), ),
), ),
], ],
...@@ -1148,7 +1141,7 @@ class _Home extends State<Home> { ...@@ -1148,7 +1141,7 @@ class _Home extends State<Home> {
// return chartData; // return chartData;
// } // }
Future<void> getupdateData(String? selectedDropdownItem) async { Future<void> getupdateData(String? selectedDropdownItem, String empid) async {
showDialog( showDialog(
context: context, context: context,
builder: (context) { builder: (context) {
...@@ -1169,7 +1162,7 @@ class _Home extends State<Home> { ...@@ -1169,7 +1162,7 @@ class _Home extends State<Home> {
final String res; final String res;
//Response data; //Response data;
respon = await RemoteData().geAlertSummary(selectedDropdownItem!, respon = await RemoteData().geAlertSummary(selectedDropdownItem!,
'${_selectedDate.year}-$selectedmonth-$selectedday'); '${_selectedDate.year}-$selectedmonth-$selectedday',empid);
res = await RemoteData().getpendingAlerts( res = await RemoteData().getpendingAlerts(
selectedDropdownItem, selectedDropdownItem,
...@@ -1194,6 +1187,7 @@ class _Home extends State<Home> { ...@@ -1194,6 +1187,7 @@ class _Home extends State<Home> {
//_controller1.text = '\t\t Pending Videos Alerts : $pending_video_alerts'; //_controller1.text = '\t\t Pending Videos Alerts : $pending_video_alerts';
}); });
if(isAuthenticated){
String insights = await RemoteData().getInsights( String insights = await RemoteData().getInsights(
selectedRegion!, selectedRegion!,
selectedDropdownItem, selectedDropdownItem,
...@@ -1211,6 +1205,7 @@ class _Home extends State<Home> { ...@@ -1211,6 +1205,7 @@ class _Home extends State<Home> {
insightslist = insightsList; insightslist = insightsList;
}); });
} }
}
} }
class MyData { class MyData {
......
...@@ -50,33 +50,25 @@ class _IssueVideos extends State<IssueVideos> { ...@@ -50,33 +50,25 @@ class _IssueVideos extends State<IssueVideos> {
Future<void> loadData() async { Future<void> loadData() async {
SharedPreferences prefs = await SharedPreferences.getInstance(); SharedPreferences prefs = await SharedPreferences.getInstance();
String? userId = prefs.getString("storeName"); String? userId = prefs.getString("storeName");
//print(userId);
storesList = (json.decode(userId!) as List<dynamic>) storesList = (json.decode(userId!) as List<dynamic>)
.map((map) => map['name'] as String) .map((map) => map['name'] as String)
.toList(); .toList();
//print(storesList);
int index = storesList!.indexWhere((item) => item.contains(isMeeters)); int index = storesList!.indexWhere((item) => item.contains(isMeeters));
setState(() { setState(() {
selectedDropdownItem = storesList![index]; selectedDropdownItem = storesList![index];
//print(selectedDropdownItem);
getData(selectedDropdownItem!); getData(selectedDropdownItem!);
}); });
} }
void getData(String name) async { void getData(String name) async {
if (kDebugMode) {
print("Second Class Hitting");
}
bool isInternetConnected = await Constants.checkInternetConnectivity(); bool isInternetConnected = await Constants.checkInternetConnectivity();
if (isInternetConnected) { if (isInternetConnected) {
showDialog( showDialog(
context: context, context: context,
builder: (context) { builder: (context) {
return const Center( return const Center(child: CircularProgressIndicator(color: Color.fromARGB(255, 29, 20, 34)));
child: CircularProgressIndicator( }
color: Color.fromARGB(255, 29, 20, 34))); );
});
final respon = await RemoteData().getIssueVideos(name); final respon = await RemoteData().getIssueVideos(name);
Map<String, dynamic> responseMap = jsonDecode(respon); Map<String, dynamic> responseMap = jsonDecode(respon);
if (kDebugMode) { if (kDebugMode) {
...@@ -87,13 +79,10 @@ class _IssueVideos extends State<IssueVideos> { ...@@ -87,13 +79,10 @@ class _IssueVideos extends State<IssueVideos> {
setState(() { setState(() {
notificationslist; notificationslist;
}); });
//Navigator.of(context).pop();
} else { } else {
//print('response $responseMap');
issue = Issue.fromJson(responseMap); issue = Issue.fromJson(responseMap);
notificationslist = issue!.data; notificationslist = issue!.data;
if (notificationslist!.isNotEmpty) { if (notificationslist!.isNotEmpty) {
//Navigator.of(context).pop();
setState(() { setState(() {
notificationslist; notificationslist;
}); });
......
...@@ -3,8 +3,7 @@ import 'package:flutter/foundation.dart'; ...@@ -3,8 +3,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_sms/flutter_sms.dart'; import 'package:flutter_sms/flutter_sms.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
import 'package:shared_preferences/shared_preferences.dart' import 'package:shared_preferences/shared_preferences.dart' show SharedPreferences;
show SharedPreferences;
import 'package:storemonitor/Screens/Chatboat.dart'; import 'package:storemonitor/Screens/Chatboat.dart';
import 'package:storemonitor/Screens/Constants.dart'; import 'package:storemonitor/Screens/Constants.dart';
import 'package:storemonitor/Screens/LoginPage.dart'; import 'package:storemonitor/Screens/LoginPage.dart';
...@@ -39,10 +38,9 @@ class _NavBarState extends State<NavBar> { ...@@ -39,10 +38,9 @@ class _NavBarState extends State<NavBar> {
_getSharedPreferencesValues(); _getSharedPreferencesValues();
isMeeters = widget.message; isMeeters = widget.message;
names = widget.storeNames names = widget.storeNames
.substring(1, widget.storeNames.length - 1) // Remove square brackets .substring(1, widget.storeNames.length - 1)
.split(", ") // Split by comma and space .split(", ")
.map((store) => store.replaceAll( .map((store) => store.replaceAll(RegExp(r'[^\w\s]+'), ''))
RegExp(r'[^\w\s]+'), '')) // Remove non-alphanumeric characters
.toList(); .toList();
if (kDebugMode) { if (kDebugMode) {
print(isMeeters); print(isMeeters);
...@@ -52,34 +50,17 @@ class _NavBarState extends State<NavBar> { ...@@ -52,34 +50,17 @@ class _NavBarState extends State<NavBar> {
} }
} }
// void makePhoneCall(String phoneNumber) async {
// //FlutterPhoneDirectCaller.callNumber(phoneNumber);
// //launchUrl("tel:+99364921507");
// // final Uri phoneUri = Uri(scheme: "tel", path: phoneNumber);
// // try {
// // if (await canLaunchUrl(phoneUri)) await canLaunchUrl(phoneUri);
// // } catch (error) {
// // throw ("Cannot dial");
// // }
// final url = Uri.parse('tel:$phoneNumber');
// if (await canLaunchUrl(url)) {
// await launchUrl(url);
// } else {
// throw 'Could not launch $url';
// }
// }
void makePhoneCall(String phoneNumber) async { void makePhoneCall(String phoneNumber) async {
final Uri launchUri = Uri( final Uri launchUri = Uri(
scheme: 'tel', scheme: 'tel',
path: phoneNumber, path: phoneNumber,
); );
if (!mounted) return; // Check if the widget is still mounted if (!mounted) return;
await launchUrl(launchUri); await launchUrl(launchUri);
} }
void requestPhoneCallPermission() async { void requestPhoneCallPermission() async {
if (!mounted) return; // Check if the widget is still mounted if (!mounted) return;
PermissionStatus status = await Permission.microphone.request(); PermissionStatus status = await Permission.microphone.request();
if (kDebugMode) { if (kDebugMode) {
print('Status $status'); print('Status $status');
...@@ -88,13 +69,10 @@ class _NavBarState extends State<NavBar> { ...@@ -88,13 +69,10 @@ class _NavBarState extends State<NavBar> {
if (status.isGranted) { if (status.isGranted) {
makePhoneCall('8121007327'); makePhoneCall('8121007327');
} else { } else {
// Permission is denied or permanently denied, show an explanation to the user
if (status.isPermanentlyDenied) { if (status.isPermanentlyDenied) {
// Show a dialog explaining why the permission is required and how to enable it
openAppSettings(); openAppSettings();
} else { } else {
// Permission is denied but not permanently, show a rationale to the user if (!mounted) return;
if (!mounted) return; // Check if the widget is still mounted
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar( SnackBar(
content: const Text('Phone call permission is required to make calls.'), content: const Text('Phone call permission is required to make calls.'),
...@@ -112,7 +90,6 @@ class _NavBarState extends State<NavBar> { ...@@ -112,7 +90,6 @@ class _NavBarState extends State<NavBar> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
//_getSharedPreferencesValues();
return Drawer( return Drawer(
child: Column( child: Column(
children: [ children: [
...@@ -121,11 +98,11 @@ class _NavBarState extends State<NavBar> { ...@@ -121,11 +98,11 @@ class _NavBarState extends State<NavBar> {
height: 120, height: 120,
margin: const EdgeInsets.only(top: 0.0), margin: const EdgeInsets.only(top: 0.0),
color: const Color.fromARGB( color: const Color.fromARGB(
255, 123, 50, 254), // Set the background color 255, 123, 50, 254),
child: const Text( child: const Text(
'\n\n\t\t\t\tMENU', // Text content '\n\n\t\t\t\tMENU',
style: TextStyle( style: TextStyle(
color: Colors.white, // Set the text color color: Colors.white,
fontSize: 22.0, fontSize: 22.0,
fontWeight: FontWeight.w400), fontWeight: FontWeight.w400),
textAlign: TextAlign.left, textAlign: TextAlign.left,
...@@ -154,18 +131,13 @@ class _NavBarState extends State<NavBar> { ...@@ -154,18 +131,13 @@ class _NavBarState extends State<NavBar> {
), ),
children: [ children: [
ListTile( ListTile(
title: Text('Name : $name', title: Text('Name : $name', style: Constants.headerlistitems),
style: Constants.headerlistitems),
//onTap: () => null,
), ),
const Divider( const Divider(
height: 1, height: 1,
), ),
ListTile( ListTile(
//leading: const Icon(Icons.support_agent), title: Text('Access Level : $access',style: Constants.headerlistitems),
title: Text('Access Level : $access',
style: Constants.headerlistitems),
//onTap: () => null,
), ),
const Divider( const Divider(
height: 1, height: 1,
...@@ -209,20 +181,19 @@ class _NavBarState extends State<NavBar> { ...@@ -209,20 +181,19 @@ class _NavBarState extends State<NavBar> {
height: 1, height: 1,
), ),
ListTile( ListTile(
leading: Image.asset( leading: Image.asset (
'assets/images/support.png', 'assets/images/support.png',
width: 32, width: 32,
height: 32, height: 32,
), ),
title: const Text( title: const Text (
'Raise a ticket', 'Raise a ticket',
style: Constants.headerlistitems, style: Constants.headerlistitems,
), ),
onTap: () => showDialog( onTap: () => showDialog (
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
return CustomDialog1( return CustomDialog1(message: isMeeters, names: names.toString());
message: isMeeters, names: names.toString());
}, },
), ),
), ),
...@@ -230,25 +201,22 @@ class _NavBarState extends State<NavBar> { ...@@ -230,25 +201,22 @@ class _NavBarState extends State<NavBar> {
height: 1, height: 1,
), ),
ListTile( ListTile(
leading: Image.asset( leading: Image.asset (
'assets/images/change_password.png', 'assets/images/change_password.png',
width: 32, width: 32,
height: 32, height: 32,
), ),
title: const Text( title: const Text (
'Change Password', 'Change Password',
style: Constants.headerlistitems, style: Constants.headerlistitems,
), ),
onTap: () { onTap: () {
// Navigator.push( showDialog (
// context,
// MaterialPageRoute(builder: (context) => const VideoApp()),
// );
showDialog(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
return const CustomDialog(); return const CustomDialog();
}); }
);
}, },
), ),
const Divider( const Divider(
...@@ -475,10 +443,8 @@ class _CustomDialogState extends State<CustomDialog> { ...@@ -475,10 +443,8 @@ class _CustomDialogState extends State<CustomDialog> {
Constants('Change Password ', 'Enter Confirm Password') Constants('Change Password ', 'Enter Confirm Password')
.showAlertDialog(context, false); .showAlertDialog(context, false);
} else { } else {
if (_textFieldController2.text == if (_textFieldController2.text == _textFieldController3.text) {
_textFieldController3.text) { bool isInternetConnected = await Constants.checkInternetConnectivity();
bool isInternetConnected =
await Constants.checkInternetConnectivity();
if (isInternetConnected) { if (isInternetConnected) {
showDialog( showDialog(
context: context, context: context,
...@@ -509,28 +475,26 @@ class _CustomDialogState extends State<CustomDialog> { ...@@ -509,28 +475,26 @@ class _CustomDialogState extends State<CustomDialog> {
Constants('Change Password', status) Constants('Change Password', status)
.showAlertDialog(context, true); .showAlertDialog(context, true);
} }
//login(_email.text, _pass.text); //login(_email.text, _pass.text);
//Navigator.pop(context); //Navigator.pop(context);
// Navigator.pop(context); // Navigator.pop(context);
} else { } else {
Constants.dialogMessage(context, 'Change Password', Constants.dialogMessage(context, 'Change Password','Check your internetconnection');
'Check your internetconnection');
} }
} else { } else {
Constants.dialogMessage(context, 'Change Password', Constants.dialogMessage(context, 'Change Password','Must be Same New and Confirm Password');
'Must be Same New and Confirm Password');
} }
} }
}, },
style: ButtonStyle( style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<Color>( backgroundColor: WidgetStateProperty.all<Color>(const Color.fromARGB(255, 62, 43, 75)),
const Color.fromARGB(255, 62, 43, 75)), shape: WidgetStateProperty.all<RoundedRectangleBorder>(
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder( RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5.0), borderRadius: BorderRadius.circular(5.0),
//side: BorderSide(color: Colors.red) //side: BorderSide(color: Colors.red)
))), )
)
),
child: const Text( child: const Text(
'UPDATE', 'UPDATE',
style: Constants.fontStyle, style: Constants.fontStyle,
...@@ -568,7 +532,6 @@ class _customdialog1state extends State<CustomDialog1> { ...@@ -568,7 +532,6 @@ class _customdialog1state extends State<CustomDialog1> {
final TextEditingController _textFieldController3 = TextEditingController(); final TextEditingController _textFieldController3 = TextEditingController();
String? selectedDropdownItem; String? selectedDropdownItem;
late String message; late String message;
List<String>? storesList; List<String>? storesList;
@override @override
...@@ -780,16 +743,6 @@ class _customdialog1state extends State<CustomDialog1> { ...@@ -780,16 +743,6 @@ class _customdialog1state extends State<CustomDialog1> {
// Show a dialog explaining why the permission is required and how to enable it // Show a dialog explaining why the permission is required and how to enable it
openAppSettings(); openAppSettings();
} else { } else {
// Permission is denied b
//ut not permanently, show a rationale to the user
// var status = await Permission.sms.request();
// if (status.isGranted) {
// requestSmsPermission(message, reciepts);
// } else {
// // Permission denied
// print('SMS permission denied.');
// }
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar( SnackBar(
content: const Text('SMS permission is required to send messages.'), content: const Text('SMS permission is required to send messages.'),
......
...@@ -62,6 +62,7 @@ class _SignUpState extends State<SignUp> { ...@@ -62,6 +62,7 @@ class _SignUpState extends State<SignUp> {
} }
String jsonStr = json.encode(normalArray); String jsonStr = json.encode(normalArray);
Navigator.pop(context); Navigator.pop(context);
print('User Level :$userResponse.level');
Constants.saveLoginCredentials(userResponse.empName, _email.text, Constants.saveLoginCredentials(userResponse.empName, _email.text,
jsonStr, '', userResponse.level, true); jsonStr, '', userResponse.level, true);
Navigator.pushReplacement( Navigator.pushReplacement(
......
...@@ -7,7 +7,6 @@ import 'package:http/http.dart' as http; ...@@ -7,7 +7,6 @@ import 'package:http/http.dart' as http;
class RemoteData { class RemoteData {
String BaseUrl = 'http://vaman.plutokm.com/'; String BaseUrl = 'http://vaman.plutokm.com/';
String LoginUrl = 'http://vaman.plutokm.com/login_test'; String LoginUrl = 'http://vaman.plutokm.com/login_test';
//String AlertSummary = 'http://vaman.plutokm.com/alert_summary_flutter';
String AlertSummary = 'http://vaman.plutokm.com/alert_summary_flutter'; String AlertSummary = 'http://vaman.plutokm.com/alert_summary_flutter';
String Review = 'http://vaman.plutokm.com/alerts_new'; String Review = 'http://vaman.plutokm.com/alerts_new';
String EmpReport = 'http://vaman.plutokm.com/regstatusreport'; String EmpReport = 'http://vaman.plutokm.com/regstatusreport';
...@@ -15,17 +14,14 @@ class RemoteData { ...@@ -15,17 +14,14 @@ class RemoteData {
String UploadVideo = 'http://vaman.plutokm.com/registeration_video'; String UploadVideo = 'http://vaman.plutokm.com/registeration_video';
String feedback = 'http://vaman.plutokm.com/api/mx_feedback_new'; String feedback = 'http://vaman.plutokm.com/api/mx_feedback_new';
String AuditData = 'http://vaman.plutokm.com/audit_page'; String AuditData = 'http://vaman.plutokm.com/audit_page';
//String AuditData = 'http://192.168.65.111:8088/audit_page';
//String AuditupdateData = 'http://192.168.65.111:8088/audit_update';
String AuditupdateData = 'http://vaman.plutokm.com/audit_update'; String AuditupdateData = 'http://vaman.plutokm.com/audit_update';
String ChangePassword = 'http://vaman.plutokm.com/changePassword'; String ChangePassword = 'http://vaman.plutokm.com/changePassword';
String FootFallVerify = 'http://vaman.plutokm.com/footfall_verify_flutter'; String FootFallVerify = 'http://vaman.plutokm.com/footfall_verify_flutter';
String EmployeeStatus = 'http://vaman.plutokm.com/employees_status'; String EmployeeStatus = 'http://vaman.plutokm.com/employees_status';
String DepartmentSearch = String DepartmentSearch = 'http://vaman.plutokm.com/employees_status_department_instore';
'http://vaman.plutokm.com/employees_status_department_instore';
String IssueVideos = 'http://vaman.plutokm.com/video_alert_page'; String IssueVideos = 'http://vaman.plutokm.com/video_alert_page';
String UpdateIssueVideos = 'http://vaman.plutokm.com/update_video_alert'; String UpdateIssueVideos= 'http://vaman.plutokm.com/update_video_alert';
String UpdateIssueVideos1 = 'http://vaman.plutokm.com/L2_update_video_alert'; String UpdateIssueVideos1= 'http://vaman.plutokm.com/L2_update_video_alert';
String Insights = 'http://vaman.plutokm.com/get_insights'; String Insights = 'http://vaman.plutokm.com/get_insights';
String Type = "Content-Type"; String Type = "Content-Type";
String App_json = "application/json"; String App_json = "application/json";
...@@ -37,26 +33,26 @@ class RemoteData { ...@@ -37,26 +33,26 @@ class RemoteData {
// Stores List Request GET Method // Stores List Request GET Method
// Login Request POST Method // Login Request POST Method
Future<String> getLoginRequest( Future<String> getLoginRequest(String loginid, String pass, String token) async {
String loginid, String pass, String token) async {
Map<String, dynamic> body = { Map<String, dynamic> body = {
'login_id': loginid, 'login_id': loginid,
'password': pass, 'password': pass,
'token': token, 'token' : token,
'os': Platform.isAndroid 'os': Platform.isAndroid
? 'Android' ? 'Android'
: Platform.isIOS : Platform.isIOS
? 'IOS' ? 'IOS'
: 'Unknown', : 'Unknown',
}; };
if (kDebugMode) { if (kDebugMode){
print(body); print(body);
} }
var client = http.Client(); var client = http.Client();
var res = await client.post(Uri.parse(LoginUrl), var res = await client.post(Uri.parse(LoginUrl), headers: {Type: App_json}, body: json.encode(body));
headers: {Type: App_json}, body: json.encode(body));
if (res.statusCode == 200) { if (res.statusCode == 200) {
if (kDebugMode) {
print(res.body); print(res.body);
}
return res.body; return res.body;
} else { } else {
throw Exception('Status code was wrong$res.statusCode'); throw Exception('Status code was wrong$res.statusCode');
...@@ -64,7 +60,6 @@ class RemoteData { ...@@ -64,7 +60,6 @@ class RemoteData {
} }
Future<String> getVoiceResponse(File text, String? userid) async { Future<String> getVoiceResponse(File text, String? userid) async {
var header = {Type: App_json};
var res = ''; var res = '';
var url = ''; var url = '';
if (kDebugMode) { if (kDebugMode) {
...@@ -76,11 +71,9 @@ class RemoteData { ...@@ -76,11 +71,9 @@ class RemoteData {
if (kDebugMode) { if (kDebugMode) {
print(url); print(url);
} }
try { try {
final request = http.MultipartRequest('POST', Uri.parse(url)); final request = http.MultipartRequest('POST', Uri.parse(url));
request.files request.files.add(await http.MultipartFile.fromPath('image', text.path));
.add(await http.MultipartFile.fromPath('image', text.path));
//request.files.add(http.MultipartFile.fromString('body_image_path', image)); //request.files.add(http.MultipartFile.fromString('body_image_path', image));
//request.fields['style_code'] = stylecode; //request.fields['style_code'] = stylecode;
var response = await request.send(); var response = await request.send();
...@@ -96,8 +89,7 @@ class RemoteData { ...@@ -96,8 +89,7 @@ class RemoteData {
} }
// var response = await http.post( // var response = await http.post(
// Uri.parse(url), // Uri.parse(url),
// headers: header, // headers: header);
// );
// if (kDebugMode) { // if (kDebugMode) {
// print(response.statusCode); // print(response.statusCode);
// } // }
...@@ -136,7 +128,6 @@ class RemoteData { ...@@ -136,7 +128,6 @@ class RemoteData {
print(url); print(url);
} }
} }
var response = await http.post( var response = await http.post(
Uri.parse(url), Uri.parse(url),
headers: header, headers: header,
...@@ -154,11 +145,10 @@ class RemoteData { ...@@ -154,11 +145,10 @@ class RemoteData {
return res; return res;
} }
Future<int> getFeedbackStatus(String notificationId, String userId, Future<int> getFeedbackStatus(String notificationId, String userId,String feed, String comments) async {
String feed, String comments) async {
Map<String, dynamic> body = { Map<String, dynamic> body = {
'NotificationID': notificationId, 'NotificationID': notificationId,
'user_id': userId, 'user_id' : userId,
'verified': 'Verified', 'verified': 'Verified',
'feedback': feed, 'feedback': feed,
'comments': comments, 'comments': comments,
...@@ -182,13 +172,10 @@ class RemoteData { ...@@ -182,13 +172,10 @@ class RemoteData {
//return 200; //return 200;
} }
Future<String?> empuploadVideo( Future<String?> empuploadVideo(File imagepath, String filename, String storename) async {
File imagepath, String filename, String storename) async { try{
try { final request = http.MultipartRequest('Post', Uri.parse('http://192.168.65.111:8080/zoom'));
final request = http.MultipartRequest( request.files.add(await http.MultipartFile.fromPath('video_path', imagepath.path));
'Post', Uri.parse('http://192.168.65.111:8080/zoom'));
request.files
.add(await http.MultipartFile.fromPath('video_path', imagepath.path));
request.fields['empid'] = '78'; request.fields['empid'] = '78';
request.fields['store_name'] = 'KLM AMEERPET'; request.fields['store_name'] = 'KLM AMEERPET';
request.fields['file'] = filename; request.fields['file'] = filename;
...@@ -200,11 +187,10 @@ class RemoteData { ...@@ -200,11 +187,10 @@ class RemoteData {
return responseString; return responseString;
} }
} catch (e) { } catch (e) {
if (kDebugMode) { if(kDebugMode){
print("Error in upload video $e"); print("Error in upload video $e");
} }
} }
return null; return null;
} }
...@@ -213,7 +199,9 @@ class RemoteData { ...@@ -213,7 +199,9 @@ class RemoteData {
'store': store, 'store': store,
'date': date, 'date': date,
}; };
if (kDebugMode) {
print(body); print(body);
}
var client = http.Client(); var client = http.Client();
var res = await client.post(Uri.parse(pendingAlerts), var res = await client.post(Uri.parse(pendingAlerts),
headers: {Type: App_json}, body: json.encode(body)); headers: {Type: App_json}, body: json.encode(body));
...@@ -229,9 +217,9 @@ class RemoteData { ...@@ -229,9 +217,9 @@ class RemoteData {
Future<String> getInsights(String region, String store, String date) async { Future<String> getInsights(String region, String store, String date) async {
Map<String, dynamic> body = { Map<String, dynamic> body = {
'region': region, 'region': region,
'store': store, 'store' : store,
'date': date, 'date' : date,
'os': Platform.isAndroid 'os' : Platform.isAndroid
? 'Android' ? 'Android'
: Platform.isIOS : Platform.isIOS
? 'IOS' ? 'IOS'
...@@ -241,8 +229,7 @@ class RemoteData { ...@@ -241,8 +229,7 @@ class RemoteData {
print(body); print(body);
} }
var client = http.Client(); var client = http.Client();
var res = await client.post(Uri.parse(Insights), var res = await client.post(Uri.parse(Insights), headers: {Type: App_json}, body: json.encode(body));
headers: {Type: App_json}, body: json.encode(body));
if (res.statusCode == 200) { if (res.statusCode == 200) {
return res.body; return res.body;
} else { } else {
...@@ -252,10 +239,11 @@ class RemoteData { ...@@ -252,10 +239,11 @@ class RemoteData {
// Alert Summary Post Request // Alert Summary Post Request
Future<String> geAlertSummary(String store, String date) async { Future<String> geAlertSummary(String store, String date, String userid) async {
Map<String, dynamic> body = { Map<String, dynamic> body = {
'store': store, 'store' : store,
'date': date, 'date' : date,
'user_id' : userid,
'platform': Platform.isAndroid 'platform': Platform.isAndroid
? 'Android' ? 'Android'
: Platform.isIOS : Platform.isIOS
...@@ -265,6 +253,9 @@ class RemoteData { ...@@ -265,6 +253,9 @@ class RemoteData {
var client = http.Client(); var client = http.Client();
var res = await client.post(Uri.parse(AlertSummary), var res = await client.post(Uri.parse(AlertSummary),
headers: {Type: App_json}, body: json.encode(body)); headers: {Type: App_json}, body: json.encode(body));
if (kDebugMode) {
print(res.statusCode);
}
if (res.statusCode == 200) { if (res.statusCode == 200) {
return res.body; return res.body;
} else { } else {
...@@ -272,16 +263,14 @@ class RemoteData { ...@@ -272,16 +263,14 @@ class RemoteData {
} }
} }
Future<http.Response?> getFootFallVerify( Future<http.Response?> getFootFallVerify(String store, String hours, String selectdate) async {
String store, String hours, String selectdate) async { Map<String,dynamic> body = {
Map<String, dynamic> body = {
'store': store, 'store': store,
'hours': hours, 'hours': hours,
'date': selectdate, 'date' : selectdate,
}; };
var client = http.Client(); var client = http.Client();
var res = await client.post(Uri.parse(FootFallVerify), var res = await client.post(Uri.parse(FootFallVerify), headers: {Type: App_json}, body: json.encode(body));
headers: {Type: App_json}, body: json.encode(body));
if (res.statusCode == 200) { if (res.statusCode == 200) {
if (kDebugMode) { if (kDebugMode) {
print(res.body); print(res.body);
...@@ -311,8 +300,7 @@ class RemoteData { ...@@ -311,8 +300,7 @@ class RemoteData {
} }
} }
Future<http.Response?> getDepartmentSearch( Future<http.Response?> getDepartmentSearch(String store, String dept, String empid) async {
String store, String dept, String empid) async {
if (kDebugMode) { if (kDebugMode) {
print(store); print(store);
} }
...@@ -322,8 +310,7 @@ class RemoteData { ...@@ -322,8 +310,7 @@ class RemoteData {
'login_id': empid, 'login_id': empid,
}; };
var client = http.Client(); var client = http.Client();
var res = await client.post(Uri.parse(DepartmentSearch), var res = await client.post(Uri.parse(DepartmentSearch),headers:{Type: App_json},body:json.encode(body));
headers: {Type: App_json}, body: json.encode(body));
if (res.statusCode == 200) { if (res.statusCode == 200) {
if (kDebugMode) { if (kDebugMode) {
print(res.body); print(res.body);
...@@ -334,8 +321,7 @@ class RemoteData { ...@@ -334,8 +321,7 @@ class RemoteData {
} }
} }
Future<String> getChangePassword( Future<String> getChangePassword(String oldpass, String newpass, String userid) async {
String oldpass, String newpass, String userid) async {
//print(date); //print(date);
Map<String, dynamic> body = { Map<String, dynamic> body = {
'old_password': oldpass, 'old_password': oldpass,
...@@ -365,7 +351,6 @@ class RemoteData { ...@@ -365,7 +351,6 @@ class RemoteData {
var res = await client.post(Uri.parse(AuditData), var res = await client.post(Uri.parse(AuditData),
headers: {Type: App_json}, body: json.encode(body)); headers: {Type: App_json}, body: json.encode(body));
if (res.statusCode == 200) { if (res.statusCode == 200) {
//loginResponseFromJson(res as String);
if (kDebugMode) { if (kDebugMode) {
print(res.body); print(res.body);
} }
...@@ -375,8 +360,7 @@ class RemoteData { ...@@ -375,8 +360,7 @@ class RemoteData {
} }
} }
Future<String> getWeeklyUpdate( Future<String> getWeeklyUpdate(String userid, String store, List<Map<String, dynamic>> array) async {
String userid, String store, List<Map<String, dynamic>> array) async {
Map<String, dynamic> body = { Map<String, dynamic> body = {
'userid': userid, 'userid': userid,
'store': store, 'store': store,
...@@ -400,8 +384,7 @@ class RemoteData { ...@@ -400,8 +384,7 @@ class RemoteData {
'key': path, 'key': path,
}; };
var client = http.Client(); var client = http.Client();
var res = await client.post(Uri.parse(ImageUrl), var res = await client.post(Uri.parse(ImageUrl), headers: {Type: App_json}, body: json.encode(body));
headers: {Type: App_json}, body: json.encode(body));
var jsonMap = jsonDecode(res.body); var jsonMap = jsonDecode(res.body);
return jsonMap['url']; return jsonMap['url'];
} }
...@@ -411,8 +394,7 @@ class RemoteData { ...@@ -411,8 +394,7 @@ class RemoteData {
'STORE': storeName, 'STORE': storeName,
}; };
var client = http.Client(); var client = http.Client();
var res = await client.post(Uri.parse(EmpReport), var res = await client.post(Uri.parse(EmpReport),headers: {Type: App_json}, body: json.encode(body));
headers: {Type: App_json}, body: json.encode(body));
if (res.statusCode == 200) { if (res.statusCode == 200) {
return res.body; return res.body;
} else { } else {
...@@ -461,14 +443,13 @@ class RemoteData { ...@@ -461,14 +443,13 @@ class RemoteData {
'comment': comment, 'comment': comment,
}; };
var client = http.Client(); var client = http.Client();
var res = await client.post(Uri.parse(UpdateIssueVideos1), var res = await client.post(Uri.parse(UpdateIssueVideos1),headers: {Type: App_json}, body: json.encode(body));
headers: {Type: App_json}, body: json.encode(body)); if(kDebugMode){
if (kDebugMode) {
print('Status Code :$res.statusCode'); print('Status Code :$res.statusCode');
} }
if (res.statusCode == 200) { if(res.statusCode == 200) {
return res.body; return res.body;
} else { }else{
throw Exception(res.statusCode); throw Exception(res.statusCode);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment