Compare commits
No commits in common. 'master' and 'dev' have entirely different histories.
@ -1,48 +0,0 @@
|
|||||||
{
|
|
||||||
"project_info": {
|
|
||||||
"project_number": "60196905754",
|
|
||||||
"project_id": "health-pharma-67443",
|
|
||||||
"storage_bucket": "health-pharma-67443.appspot.com"
|
|
||||||
},
|
|
||||||
"client": [
|
|
||||||
{
|
|
||||||
"client_info": {
|
|
||||||
"mobilesdk_app_id": "1:60196905754:android:05ea9ecef5280e578a42a3",
|
|
||||||
"android_client_info": {
|
|
||||||
"package_name": "com.arminta.healthcare_pharmacy"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"oauth_client": [],
|
|
||||||
"api_key": [
|
|
||||||
{
|
|
||||||
"current_key": "AIzaSyC89L-Xg53Bd_mdCPvKOu7BcC9Ya6UZeds"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"services": {
|
|
||||||
"appinvite_service": {
|
|
||||||
"other_platform_oauth_client": []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"client_info": {
|
|
||||||
"mobilesdk_app_id": "1:60196905754:android:a35c084e291315488a42a3",
|
|
||||||
"android_client_info": {
|
|
||||||
"package_name": "com.arminta.healthparma"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"oauth_client": [],
|
|
||||||
"api_key": [
|
|
||||||
{
|
|
||||||
"current_key": "AIzaSyC89L-Xg53Bd_mdCPvKOu7BcC9Ya6UZeds"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"services": {
|
|
||||||
"appinvite_service": {
|
|
||||||
"other_platform_oauth_client": []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"configuration_version": "1"
|
|
||||||
}
|
|
Before Width: | Height: | Size: 16 KiB |
@ -1,6 +0,0 @@
|
|||||||
|
|
||||||
class ChatMessage{
|
|
||||||
String message;
|
|
||||||
String type;
|
|
||||||
ChatMessage({required this.message,required this.type});
|
|
||||||
}
|
|
@ -1,125 +0,0 @@
|
|||||||
|
|
||||||
import 'dart:convert';
|
|
||||||
|
|
||||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
|
||||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
|
||||||
import 'package:healthcare_pharmacy/settings.dart';
|
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
|
||||||
|
|
||||||
|
|
||||||
class PushNotificationService {
|
|
||||||
final FirebaseMessaging _fcm = FirebaseMessaging.instance;
|
|
||||||
final FlutterLocalNotificationsPlugin _flutterLocalNotificationsPlugin =
|
|
||||||
FlutterLocalNotificationsPlugin();
|
|
||||||
|
|
||||||
|
|
||||||
// Constructor to initialize the FCM token
|
|
||||||
PushNotificationService() {
|
|
||||||
_initFCMToken();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _initFCMToken() async {
|
|
||||||
// Get the stored FCM token
|
|
||||||
AppSettings.fcmId = await _getStoredFCMToken();
|
|
||||||
|
|
||||||
// If FCM token is not available, request a new one
|
|
||||||
if (AppSettings.fcmId.isEmpty) {
|
|
||||||
await _fcm.getToken().then((token) {
|
|
||||||
print('FCM Token: $token');
|
|
||||||
// Store the FCM token directly in AppSettings
|
|
||||||
AppSettings.fcmId = token!;
|
|
||||||
_storeFCMToken(token);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _storeFCMToken(String token) async {
|
|
||||||
// Store the FCM token using SharedPreferences
|
|
||||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
||||||
await prefs.setString('fcmToken', token);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<String> _getStoredFCMToken() async {
|
|
||||||
// Retrieve the stored FCM token from SharedPreferences
|
|
||||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
||||||
return prefs.getString('fcmToken') ?? '';
|
|
||||||
}
|
|
||||||
Future<void> initialize() async {
|
|
||||||
// Request permission for user notifications
|
|
||||||
await _fcm.requestPermission();
|
|
||||||
|
|
||||||
// Get the FCM token and handle incoming messages while the app is in the foreground
|
|
||||||
_fcm.getToken().then((token) {
|
|
||||||
print('FCM Token: $token');
|
|
||||||
// Do something with the token (e.g., send it to your server)
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Listen to incoming messages while the app is in the foreground
|
|
||||||
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
|
|
||||||
print("data::::$message");
|
|
||||||
// var payload = message.data.toString();
|
|
||||||
// // Handle the incoming message
|
|
||||||
// Map<String, dynamic> notificationPayload = jsonDecode(payload);
|
|
||||||
// Access the extra data using the keys
|
|
||||||
var payload=message.data;
|
|
||||||
var extramessage;
|
|
||||||
if(payload.isNotEmpty){
|
|
||||||
extramessage = message.data['extraKey1'];
|
|
||||||
String? extraValue2 = message.data['extraKey2'];
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Show a local notification with the received message
|
|
||||||
_showNotification(message.notification?.title, message.notification?.body,extramessage);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Handle messages when the app is in the background or terminated
|
|
||||||
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
|
|
||||||
var payload = message.data.toString();
|
|
||||||
if (payload != null) {
|
|
||||||
// Parse the JSON payload
|
|
||||||
Map<String, dynamic> notificationPayload = jsonDecode(payload);
|
|
||||||
// Access the extra data using the keys
|
|
||||||
String? extraValue1 = notificationPayload['extraKey1'];
|
|
||||||
String? extraValue2 = notificationPayload['extraKey2'];
|
|
||||||
// Do something with the extra data, e.g., display it in a dialog or use it in your app logic.
|
|
||||||
}
|
|
||||||
|
|
||||||
// Show a local notification with the received message
|
|
||||||
// _showNotification(message.notification?.title, message.notification?.body);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Method to show a local notification using flutter_local_notifications
|
|
||||||
Future<void> _showNotification(String? title, String? body,String extramessage) async {
|
|
||||||
const AndroidNotificationDetails androidPlatformChannelSpecifics =
|
|
||||||
AndroidNotificationDetails(
|
|
||||||
'healthpharma', // Replace with your channel ID
|
|
||||||
'healthpharmanotifications', // Replace with your channel name
|
|
||||||
importance: Importance.high,
|
|
||||||
priority: Priority.high,
|
|
||||||
showWhen: false,
|
|
||||||
icon: "logo"
|
|
||||||
|
|
||||||
);
|
|
||||||
|
|
||||||
const NotificationDetails platformChannelSpecifics =
|
|
||||||
NotificationDetails(android: androidPlatformChannelSpecifics);
|
|
||||||
Map<String, dynamic> notificationPayload = {
|
|
||||||
"body": body,
|
|
||||||
"title": title,
|
|
||||||
"extraKey1": extramessage,
|
|
||||||
"extraKey2": "Extra Value 2",
|
|
||||||
// Add more key-value pairs as needed
|
|
||||||
};
|
|
||||||
await _flutterLocalNotificationsPlugin.show(
|
|
||||||
0, // notification ID (can be any unique ID)
|
|
||||||
title, // notification title
|
|
||||||
body, // notification body
|
|
||||||
platformChannelSpecifics,
|
|
||||||
payload: jsonEncode(notificationPayload), // optional, you can pass data or identifier related to the notification
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,51 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:healthcare_pharmacy/settings.dart';
|
|
||||||
import 'package:photo_view/photo_view.dart';
|
|
||||||
|
|
||||||
|
|
||||||
class ZoomedImageView extends StatelessWidget {
|
|
||||||
final String imageUrl;
|
|
||||||
|
|
||||||
ZoomedImageView({required this.imageUrl});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
backgroundColor: primaryColor, // Set the background color
|
|
||||||
title: Text('Preview Image'), // Set the title text
|
|
||||||
actions: [
|
|
||||||
IconButton(
|
|
||||||
icon: Icon(Icons.close),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
|
|
||||||
body: GestureDetector(
|
|
||||||
onTap: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
child: Center(
|
|
||||||
child: Container(
|
|
||||||
width: MediaQuery.of(context).size.width,
|
|
||||||
height: MediaQuery.of(context).size.height,
|
|
||||||
child: PhotoView(
|
|
||||||
imageProvider: NetworkImage(imageUrl),
|
|
||||||
maxScale: PhotoViewComputedScale.contained * 4.0,
|
|
||||||
minScale: PhotoViewComputedScale.contained,
|
|
||||||
initialScale: PhotoViewComputedScale.contained,
|
|
||||||
basePosition: Alignment.center,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,430 +0,0 @@
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
|
||||||
import 'package:healthcare_pharmacy/dashboard.dart';
|
|
||||||
import 'package:healthcare_pharmacy/keys.dart';
|
|
||||||
import 'package:healthcare_pharmacy/settings.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'dart:io' show File, Platform;
|
|
||||||
import 'package:google_maps_flutter_android/google_maps_flutter_android.dart';
|
|
||||||
import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart';
|
|
||||||
import 'package:location/location.dart' as locationmap;
|
|
||||||
import 'google_maps_place_picker_mb/src/models/pick_result.dart';
|
|
||||||
import 'google_maps_place_picker_mb/src/place_picker.dart';
|
|
||||||
|
|
||||||
class Deliverboy extends StatefulWidget {
|
|
||||||
const Deliverboy({Key? key}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<Deliverboy> createState() => _deliverboyState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _deliverboyState extends State<Deliverboy> {
|
|
||||||
|
|
||||||
TextEditingController pharmacyNameController = TextEditingController();
|
|
||||||
TextEditingController deliverNameController = TextEditingController();
|
|
||||||
TextEditingController deliveryPhoneNumberController = TextEditingController();
|
|
||||||
TextEditingController deliveryAlternativePhoneNumberController = TextEditingController();
|
|
||||||
TextEditingController deliveryAddressCapturingController = TextEditingController();
|
|
||||||
|
|
||||||
|
|
||||||
String _currentAddress ='';
|
|
||||||
String address1 = '';
|
|
||||||
String address2 = '';
|
|
||||||
String city = '';
|
|
||||||
String state = '';
|
|
||||||
String zip = '';
|
|
||||||
String status = '';
|
|
||||||
double lat=0;
|
|
||||||
double lng=0;
|
|
||||||
|
|
||||||
PickResult? selectedPlace;
|
|
||||||
|
|
||||||
bool _mapsInitialized = false;
|
|
||||||
final String _mapsRenderer = "latest";
|
|
||||||
|
|
||||||
var kInitialPosition = const LatLng(15.462477, 78.717401);
|
|
||||||
|
|
||||||
locationmap.Location location = locationmap.Location();
|
|
||||||
|
|
||||||
final GoogleMapsFlutterPlatform mapsImplementation =
|
|
||||||
GoogleMapsFlutterPlatform.instance;
|
|
||||||
|
|
||||||
void initRenderer() {
|
|
||||||
if (_mapsInitialized) return;
|
|
||||||
if (mapsImplementation is GoogleMapsFlutterAndroid) {
|
|
||||||
switch (_mapsRenderer) {
|
|
||||||
case "legacy":
|
|
||||||
(mapsImplementation as GoogleMapsFlutterAndroid)
|
|
||||||
.initializeWithRenderer(AndroidMapRenderer.legacy);
|
|
||||||
break;
|
|
||||||
case "latest":
|
|
||||||
(mapsImplementation as GoogleMapsFlutterAndroid)
|
|
||||||
.initializeWithRenderer(AndroidMapRenderer.latest);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setState(() {
|
|
||||||
_mapsInitialized = true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar:AppSettings.appBar('Add Deliveryboy'),
|
|
||||||
body: SafeArea(
|
|
||||||
child: SingleChildScrollView(
|
|
||||||
child: Column(
|
|
||||||
children: <Widget>[
|
|
||||||
const SizedBox(
|
|
||||||
height: 15,
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
height: MediaQuery.of(context).size.height * .15,
|
|
||||||
width: double.infinity,
|
|
||||||
child: Image(
|
|
||||||
image: const AssetImage('images/logo.png'),
|
|
||||||
height: MediaQuery.of(context).size.height * .25,
|
|
||||||
)),
|
|
||||||
|
|
||||||
const SizedBox(
|
|
||||||
height: 15,
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
//padding: const EdgeInsets.fromLTRB(10, 10, 10, 0),
|
|
||||||
padding: const EdgeInsets.all(10),
|
|
||||||
child: TextFormField(
|
|
||||||
cursorColor: greyColor,
|
|
||||||
controller: pharmacyNameController,
|
|
||||||
textCapitalization: TextCapitalization.characters,
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
prefixIcon: Icon(
|
|
||||||
Icons.propane_tank,
|
|
||||||
color: greyColor,
|
|
||||||
),
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: greyColor)),
|
|
||||||
focusedBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: greyColor),
|
|
||||||
),
|
|
||||||
enabledBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: greyColor),
|
|
||||||
),
|
|
||||||
labelText: 'Enter pharmacy name',
|
|
||||||
labelStyle: TextStyle(
|
|
||||||
color: greyColor, //<-- SEE HERE
|
|
||||||
),
|
|
||||||
),
|
|
||||||
), //tanker name
|
|
||||||
),
|
|
||||||
|
|
||||||
|
|
||||||
const SizedBox(
|
|
||||||
height: 15,
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
//padding: const EdgeInsets.fromLTRB(10, 10, 10, 0),
|
|
||||||
padding: const EdgeInsets.all(10),
|
|
||||||
child: TextFormField(
|
|
||||||
cursorColor: greyColor,
|
|
||||||
controller: deliverNameController,
|
|
||||||
textCapitalization: TextCapitalization.characters,
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
prefixIcon: Icon(
|
|
||||||
Icons.propane_tank,
|
|
||||||
color: greyColor,
|
|
||||||
),
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: greyColor)),
|
|
||||||
focusedBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: greyColor),
|
|
||||||
),
|
|
||||||
enabledBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: greyColor),
|
|
||||||
),
|
|
||||||
labelText: 'Enter deliveryboy name',
|
|
||||||
labelStyle: TextStyle(
|
|
||||||
color: greyColor, //<-- SEE HERE
|
|
||||||
),
|
|
||||||
),
|
|
||||||
), //tanker name
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 5,
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
padding: const EdgeInsets.all(10),
|
|
||||||
child: TextFormField(
|
|
||||||
cursorColor: greyColor,
|
|
||||||
controller: deliveryPhoneNumberController,
|
|
||||||
keyboardType: TextInputType.number,
|
|
||||||
maxLength: 10,
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
prefixIcon: Icon(
|
|
||||||
Icons.phone_android,
|
|
||||||
color: greyColor,
|
|
||||||
),
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: greyColor)),
|
|
||||||
focusedBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: greyColor),
|
|
||||||
),
|
|
||||||
enabledBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: greyColor),
|
|
||||||
),
|
|
||||||
labelText: 'Enter phone number',
|
|
||||||
labelStyle: TextStyle(
|
|
||||||
color: greyColor, //<-- SEE HERE
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
), //phone number
|
|
||||||
const SizedBox(
|
|
||||||
height: 5,
|
|
||||||
),
|
|
||||||
|
|
||||||
Container(
|
|
||||||
padding: const EdgeInsets.all(10),
|
|
||||||
child: TextFormField(
|
|
||||||
cursorColor: greyColor,
|
|
||||||
controller: deliveryAlternativePhoneNumberController,
|
|
||||||
keyboardType: TextInputType.number,
|
|
||||||
maxLength: 10,
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
prefixIcon: Icon(
|
|
||||||
Icons.phone_android,
|
|
||||||
color: greyColor,
|
|
||||||
),
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: greyColor)),
|
|
||||||
focusedBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: greyColor),
|
|
||||||
),
|
|
||||||
enabledBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: greyColor),
|
|
||||||
),
|
|
||||||
labelText: 'Enter alternative phone number',
|
|
||||||
labelStyle: TextStyle(
|
|
||||||
color: greyColor, //<-- SEE HERE
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
), //alternative phone number
|
|
||||||
const SizedBox(
|
|
||||||
height: 5,
|
|
||||||
),
|
|
||||||
|
|
||||||
|
|
||||||
GestureDetector(
|
|
||||||
child:Container(
|
|
||||||
padding: const EdgeInsets.all(10),
|
|
||||||
child: TextFormField(
|
|
||||||
cursorColor: greyColor,
|
|
||||||
controller: deliveryAddressCapturingController,
|
|
||||||
onTap:()
|
|
||||||
{
|
|
||||||
|
|
||||||
//=============================================================================================
|
|
||||||
location.serviceEnabled().then((value) {
|
|
||||||
if (value) {
|
|
||||||
initRenderer();
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) {
|
|
||||||
return PlacePicker(
|
|
||||||
resizeToAvoidBottomInset: false,
|
|
||||||
hintText: "Find a place ...",
|
|
||||||
searchingText: "Please wait ...",
|
|
||||||
selectText: "Select place",
|
|
||||||
outsideOfPickAreaText: "Place not in area",
|
|
||||||
initialPosition: kInitialPosition,
|
|
||||||
useCurrentLocation: true,
|
|
||||||
selectInitialPosition: true,
|
|
||||||
usePinPointingSearch: true,
|
|
||||||
usePlaceDetailSearch: true,
|
|
||||||
zoomGesturesEnabled: true,
|
|
||||||
zoomControlsEnabled: true,
|
|
||||||
onMapCreated: (GoogleMapController controller) {},
|
|
||||||
onPlacePicked: (PickResult result) {
|
|
||||||
setState(() {
|
|
||||||
selectedPlace = result;
|
|
||||||
lat=selectedPlace!.geometry!.location.lat;
|
|
||||||
lng=selectedPlace!.geometry!.location.lng;
|
|
||||||
if(selectedPlace!.types!.length==1){
|
|
||||||
deliveryAddressCapturingController.text =
|
|
||||||
selectedPlace!.formattedAddress!;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
deliveryAddressCapturingController.text =selectedPlace!.name!+', '+selectedPlace!.formattedAddress!;
|
|
||||||
}
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onMapTypeChanged: (MapType mapType) {},
|
|
||||||
apiKey: Platform.isAndroid
|
|
||||||
? APIKeys.androidApiKey
|
|
||||||
: APIKeys.iosApiKey,
|
|
||||||
forceAndroidLocationManager: true,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
showGeneralDialog(
|
|
||||||
context: context,
|
|
||||||
pageBuilder: (context, x, y) {
|
|
||||||
return Scaffold(
|
|
||||||
backgroundColor: Colors.grey.withOpacity(.5),
|
|
||||||
body: Center(
|
|
||||||
child: Container(
|
|
||||||
width: double.infinity,
|
|
||||||
height: 150,
|
|
||||||
padding:
|
|
||||||
const EdgeInsets.symmetric(horizontal: 20),
|
|
||||||
child: Card(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(10.0),
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
const Text(
|
|
||||||
"Please enable the location",
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize:18,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 20,
|
|
||||||
),
|
|
||||||
ElevatedButton(
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
child: const Text("Cancel"),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
//=====================================================================================
|
|
||||||
|
|
||||||
// _getCurrentPosition();
|
|
||||||
},
|
|
||||||
keyboardType: TextInputType.streetAddress,
|
|
||||||
readOnly: false,
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
prefixIcon: Icon(
|
|
||||||
Icons.location_on_rounded,
|
|
||||||
color: greyColor,
|
|
||||||
),
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: greyColor)),
|
|
||||||
focusedBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: greyColor),
|
|
||||||
),
|
|
||||||
enabledBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: greyColor),
|
|
||||||
),
|
|
||||||
labelText: 'select address from MAP',
|
|
||||||
labelStyle: TextStyle(
|
|
||||||
color: greyColor, //<-- SEE HERE
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
),
|
|
||||||
),
|
|
||||||
/* onTap: ()
|
|
||||||
{
|
|
||||||
},*///address
|
|
||||||
),
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const SizedBox(
|
|
||||||
height: 5,
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
width: MediaQuery.of(context).size.width * .99,
|
|
||||||
height: 50,
|
|
||||||
padding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
|
|
||||||
child: ElevatedButton(
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
primary: primaryColor, // background
|
|
||||||
onPrimary: Colors.white, // foreground
|
|
||||||
),
|
|
||||||
onPressed: () async {
|
|
||||||
|
|
||||||
if (deliverNameController.text != '' &&
|
|
||||||
deliveryPhoneNumberController.text != ''
|
|
||||||
) {
|
|
||||||
AppSettings.preLoaderDialog(context);
|
|
||||||
|
|
||||||
var payload = new Map<String, dynamic>();
|
|
||||||
payload["pharmacyname"] = pharmacyNameController.text.toString();
|
|
||||||
payload["Name"] = deliverNameController.text.toString();
|
|
||||||
payload["phone"] = deliveryPhoneNumberController.text.toString();
|
|
||||||
payload["alternativeContactNumber"] = deliveryAlternativePhoneNumberController.text.toString();
|
|
||||||
payload["address"] = deliveryAddressCapturingController.text;
|
|
||||||
payload["city"] = city;
|
|
||||||
payload["state"] = state;
|
|
||||||
payload["zip"] = zip;
|
|
||||||
payload["latitude"] = lat;
|
|
||||||
payload["longitude"] = lng;
|
|
||||||
payload["status"] = status;
|
|
||||||
bool deliveryboyStatus = await AppSettings.addDeliverboy(payload);
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (deliveryboyStatus) {
|
|
||||||
AppSettings.longSuccessToast(
|
|
||||||
"Deliverboy Created Successfully");
|
|
||||||
deliverNameController.text= '';
|
|
||||||
deliveryPhoneNumberController.text= '';
|
|
||||||
deliveryAlternativePhoneNumberController.text= '';
|
|
||||||
Navigator.of(context,rootNavigator: true).pop();
|
|
||||||
await Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => const Dashboard()),
|
|
||||||
);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Navigator.of(context,rootNavigator: true).pop();
|
|
||||||
AppSettings.longFailedToast("Deliverboy not Created Successfully");
|
|
||||||
}
|
|
||||||
} catch (exception) {
|
|
||||||
print(exception);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
AppSettings.longFailedToast("Please enter valid details");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
child: const Text(
|
|
||||||
'Add Deliverboy',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 25,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)),
|
|
||||||
|
|
||||||
],
|
|
||||||
),
|
|
||||||
)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,369 +0,0 @@
|
|||||||
import 'dart:convert';
|
|
||||||
import 'dart:io';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:geolocator/geolocator.dart';
|
|
||||||
import 'package:healthcare_pharmacy/createoffers.dart';
|
|
||||||
import 'package:healthcare_pharmacy/getmedicines.dart';
|
|
||||||
import 'package:healthcare_pharmacy/models/approvedoffer_model.dart';
|
|
||||||
import 'package:healthcare_pharmacy/models/biddingrequest_model.dart';
|
|
||||||
import 'package:healthcare_pharmacy/settings.dart';
|
|
||||||
|
|
||||||
import 'package:image_picker/image_picker.dart';
|
|
||||||
import 'package:photo_view/photo_view.dart';
|
|
||||||
|
|
||||||
class ApprovedOffersData extends StatefulWidget {
|
|
||||||
const ApprovedOffersData({Key? key}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<ApprovedOffersData> createState() => _ApprovedOffersDataState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ApprovedOffersDataState extends State<ApprovedOffersData> {
|
|
||||||
bool isOfferDataLoading=false;
|
|
||||||
bool isSereverIssue = false;
|
|
||||||
bool isSereverIssueConnected = false;
|
|
||||||
bool isSereverIssuePending = false;
|
|
||||||
List<GetApprovedOffersDetailsModel> approvedOffersList = [];
|
|
||||||
final ImagePicker _picker = ImagePicker();
|
|
||||||
bool isActiveDataLoading=false;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Future<void> getApprovedOffersViewData() async {
|
|
||||||
isActiveDataLoading = true;
|
|
||||||
try {
|
|
||||||
var data = await AppSettings.getApprovedOffers();
|
|
||||||
setState(() {
|
|
||||||
List<dynamic> responseData = jsonDecode(data)['data'];
|
|
||||||
approvedOffersList = responseData
|
|
||||||
.map((jsonObject) => GetApprovedOffersDetailsModel.fromJson(jsonObject))
|
|
||||||
.toList();
|
|
||||||
isActiveDataLoading = false;
|
|
||||||
});
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
setState(() {
|
|
||||||
isActiveDataLoading = false;
|
|
||||||
isSereverIssueConnected = true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
getApprovedOffersViewData();
|
|
||||||
super.initState();
|
|
||||||
}
|
|
||||||
|
|
||||||
showPicDialog(var imageUrl){
|
|
||||||
return showDialog(
|
|
||||||
context: context,
|
|
||||||
barrierDismissible: false,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return StatefulBuilder(
|
|
||||||
builder: (BuildContext context, StateSetter setState) {
|
|
||||||
return AlertDialog(
|
|
||||||
title: const Text(''),
|
|
||||||
content: SingleChildScrollView(
|
|
||||||
child: ListBody(
|
|
||||||
children: <Widget>[
|
|
||||||
Container(
|
|
||||||
width: MediaQuery.of(context).size.width * .10,
|
|
||||||
height: MediaQuery.of(context).size.height * .50,
|
|
||||||
child: PhotoView(
|
|
||||||
imageProvider: NetworkImage(imageUrl) as ImageProvider,
|
|
||||||
maxScale: PhotoViewComputedScale.contained * 4.0,
|
|
||||||
minScale: PhotoViewComputedScale.contained,
|
|
||||||
initialScale: PhotoViewComputedScale.contained,
|
|
||||||
basePosition: Alignment.center,
|
|
||||||
|
|
||||||
)
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
actions: <Widget>[
|
|
||||||
TextButton(
|
|
||||||
child: Text('Close', style: textButtonStyle()),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Widget renderzActiveUi(){
|
|
||||||
if(approvedOffersList.length!=0){
|
|
||||||
|
|
||||||
return Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
|
||||||
children: [
|
|
||||||
Expanded(child:ListView.builder(
|
|
||||||
padding: EdgeInsets.all(0),
|
|
||||||
itemCount: approvedOffersList .length,
|
|
||||||
itemBuilder: (context,index){
|
|
||||||
var data=approvedOffersList[index];
|
|
||||||
return GestureDetector(
|
|
||||||
onTap: () {
|
|
||||||
|
|
||||||
},
|
|
||||||
child: Card(
|
|
||||||
child: ListTile(
|
|
||||||
leading: GestureDetector(
|
|
||||||
onTap: () {
|
|
||||||
showPicDialog(approvedOffersList[index].picture[0].url);
|
|
||||||
},
|
|
||||||
child: Container(
|
|
||||||
width: 100,
|
|
||||||
height: 300,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
image: DecorationImage(
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
alignment: Alignment.center,
|
|
||||||
image: data.picture.isEmpty
|
|
||||||
? AssetImage('images/logo.png') as ImageProvider
|
|
||||||
: NetworkImage(approvedOffersList[index].picture[0].url),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
|
|
||||||
title: RichText(
|
|
||||||
text: TextSpan(
|
|
||||||
style: DefaultTextStyle.of(context).style,
|
|
||||||
children: <TextSpan>[
|
|
||||||
TextSpan(
|
|
||||||
text: 'Name: ',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.black,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TextSpan(
|
|
||||||
text: approvedOffersList[index].offer_name,
|
|
||||||
style: TextStyle(
|
|
||||||
color: primaryColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
subtitle: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
// ... (other RichText widgets for Code, Description, Start Date, End Date)
|
|
||||||
RichText(
|
|
||||||
text: TextSpan(
|
|
||||||
style: DefaultTextStyle.of(context).style,
|
|
||||||
children: <TextSpan>[
|
|
||||||
TextSpan(
|
|
||||||
text: 'Code: ',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.black, // Change the color for "Description" text
|
|
||||||
fontWeight: FontWeight.bold, // You can apply other styles too
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TextSpan(
|
|
||||||
text: approvedOffersList[index].offer_code,
|
|
||||||
style: TextStyle(
|
|
||||||
color: primaryColor, // Change the color for description content
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
RichText(
|
|
||||||
text: TextSpan(
|
|
||||||
style: DefaultTextStyle.of(context).style,
|
|
||||||
children: <TextSpan>[
|
|
||||||
TextSpan(
|
|
||||||
text: 'Description: ',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.black, // Change the color for "Description" text
|
|
||||||
fontWeight: FontWeight.bold, // You can apply other styles too
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TextSpan(
|
|
||||||
text: approvedOffersList[index].description,
|
|
||||||
style: TextStyle(
|
|
||||||
color:primaryColor, // Change the color for description content
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
RichText(
|
|
||||||
text: TextSpan(
|
|
||||||
style: DefaultTextStyle.of(context).style,
|
|
||||||
children: <TextSpan>[
|
|
||||||
TextSpan(
|
|
||||||
text: 'Category: ',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.black, // Change the color for "Description" text
|
|
||||||
fontWeight: FontWeight.bold, // You can apply other styles too
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TextSpan(
|
|
||||||
text: approvedOffersList[index].category,
|
|
||||||
style: TextStyle(
|
|
||||||
color:primaryColor, // Change the color for description content
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
RichText(
|
|
||||||
text: TextSpan(
|
|
||||||
style: DefaultTextStyle.of(context).style,
|
|
||||||
children: <TextSpan>[
|
|
||||||
TextSpan(
|
|
||||||
text: 'Start Date: ',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.black, // Change the color for "Description" text
|
|
||||||
fontWeight: FontWeight.bold, // You can apply other styles too
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TextSpan(
|
|
||||||
text: approvedOffersList[index].starting_date,
|
|
||||||
|
|
||||||
style: TextStyle(
|
|
||||||
color:primaryColor, // Change the color for description content
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
RichText(
|
|
||||||
text: TextSpan(
|
|
||||||
style: DefaultTextStyle.of(context).style,
|
|
||||||
children: <TextSpan>[
|
|
||||||
TextSpan(
|
|
||||||
text: 'End Date :',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.black, // Change the color for "Description" text
|
|
||||||
fontWeight: FontWeight.bold, // You can apply other styles too
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TextSpan(
|
|
||||||
text: approvedOffersList[index].ending_date,
|
|
||||||
style: TextStyle(
|
|
||||||
color:primaryColor, // Change the color for description content
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}) ),
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.fromLTRB(8, 8, 8, 8),
|
|
||||||
child: CircleAvatar(
|
|
||||||
backgroundColor: primaryColor,
|
|
||||||
radius: 40,
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: <Widget>[
|
|
||||||
IconButton(
|
|
||||||
iconSize: 40,
|
|
||||||
icon: const Icon(
|
|
||||||
Icons.add,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
onPressed: () async{
|
|
||||||
Navigator.pop(context);
|
|
||||||
await Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => offers()),
|
|
||||||
);
|
|
||||||
//showBoreAddingDialog();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
/* Padding(
|
|
||||||
padding: EdgeInsets.fromLTRB(5, 0, 5, 5),
|
|
||||||
child: Text(
|
|
||||||
'Add Tanks ',
|
|
||||||
style: TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
)*/
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
return Center(
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.fromLTRB(0, 40, 0, 0),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
SizedBox(height: MediaQuery.of(context).size.height * .25,),
|
|
||||||
Text('Click below icon to add new Offer'),
|
|
||||||
SizedBox(
|
|
||||||
height: 20,
|
|
||||||
),
|
|
||||||
CircleAvatar(
|
|
||||||
backgroundColor: primaryColor,
|
|
||||||
radius: 40,
|
|
||||||
child: IconButton(
|
|
||||||
iconSize: 40,
|
|
||||||
icon: const Icon(
|
|
||||||
Icons.add,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
onPressed: () async {
|
|
||||||
Navigator.pop(context);
|
|
||||||
await Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => offers()),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**/
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return SafeArea(
|
|
||||||
child: Scaffold(
|
|
||||||
appBar: AppSettings.appBar('Approved Ofers'),
|
|
||||||
body: isActiveDataLoading?Center(
|
|
||||||
child: CircularProgressIndicator(
|
|
||||||
color: primaryColor,
|
|
||||||
strokeWidth: 5.0,
|
|
||||||
),
|
|
||||||
):renderzActiveUi(),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,88 +0,0 @@
|
|||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:firebase_storage/firebase_storage.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:get/get.dart';
|
|
||||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
|
||||||
import 'chatmessage.dart';
|
|
||||||
|
|
||||||
|
|
||||||
class ChatController extends GetxController {
|
|
||||||
final CollectionReference _messagesCollection =
|
|
||||||
FirebaseFirestore.instance.collection('messages');
|
|
||||||
|
|
||||||
// Observable list of messages
|
|
||||||
RxList<ChatMessage> messages = <ChatMessage>[].obs;
|
|
||||||
|
|
||||||
void sendMessage(String messageContent, String messageType, bool isText) async {
|
|
||||||
try {
|
|
||||||
await _messagesCollection.add({
|
|
||||||
'messageContent': messageContent,
|
|
||||||
'messageType': messageType,
|
|
||||||
'isText': isText,
|
|
||||||
'timestamp': Timestamp.now(),
|
|
||||||
});
|
|
||||||
print("Message sent successfully");
|
|
||||||
} catch (e) {
|
|
||||||
print('Error sending message: $e');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<String> uploadImage(File image, String id) async {
|
|
||||||
try {
|
|
||||||
String fileName = DateTime.now().millisecondsSinceEpoch.toString();
|
|
||||||
Reference storageReference =
|
|
||||||
FirebaseStorage.instance.ref().child('products/$fileName');
|
|
||||||
SettableMetadata metadata = SettableMetadata(contentType: 'image/jpeg');
|
|
||||||
UploadTask uploadTask = storageReference.putFile(image, metadata);
|
|
||||||
|
|
||||||
String temporaryMessageId = UniqueKey().toString();
|
|
||||||
messages.add(ChatMessage(
|
|
||||||
messageContent: 'Uploading...',
|
|
||||||
messageType: id,
|
|
||||||
isText: true,
|
|
||||||
temporaryMessageId: temporaryMessageId,
|
|
||||||
));
|
|
||||||
|
|
||||||
TaskSnapshot taskSnapshot = await uploadTask;
|
|
||||||
String downloadURL = await storageReference.getDownloadURL();
|
|
||||||
|
|
||||||
// Replace the temporary message with the uploaded image
|
|
||||||
int index = messages.indexWhere((message) => message.temporaryMessageId == temporaryMessageId);
|
|
||||||
if (index != -1) {
|
|
||||||
messages[index] = ChatMessage(
|
|
||||||
messageContent: downloadURL,
|
|
||||||
messageType: id,
|
|
||||||
isText: false,
|
|
||||||
temporaryMessageId: '',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
print('Image uploaded successfully. Download URL: $downloadURL');
|
|
||||||
return downloadURL;
|
|
||||||
} catch (e) {
|
|
||||||
print('Error uploading image: $e');
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Stream<QuerySnapshot> getMessagesStream() {
|
|
||||||
return _messagesCollection.orderBy('timestamp').snapshots();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void onInit() {
|
|
||||||
super.onInit();
|
|
||||||
// Listen for changes in the messages collection and update the local list
|
|
||||||
getMessagesStream().listen((QuerySnapshot snapshot) {
|
|
||||||
messages.assignAll(snapshot.docs.map((doc) => ChatMessage(
|
|
||||||
messageContent: doc['messageContent'],
|
|
||||||
messageType: doc['messageType'],
|
|
||||||
isText: doc['isText'],
|
|
||||||
temporaryMessageId: '',
|
|
||||||
)));
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
|
|
||||||
class ChatMessage {
|
|
||||||
String messageContent;
|
|
||||||
String messageType;
|
|
||||||
bool isText;
|
|
||||||
String temporaryMessageId; // New property for temporary message identifier
|
|
||||||
|
|
||||||
ChatMessage({
|
|
||||||
required this.messageContent,
|
|
||||||
required this.messageType,
|
|
||||||
required this.isText,
|
|
||||||
required this.temporaryMessageId, // Include in the constructor
|
|
||||||
});
|
|
||||||
}
|
|
@ -1,241 +0,0 @@
|
|||||||
import 'dart:io';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:get/get.dart';
|
|
||||||
import 'package:healthcare_pharmacy/chat/chatzoomable_image.dart';
|
|
||||||
import 'package:healthcare_pharmacy/pages/index.dart';
|
|
||||||
import 'package:healthcare_pharmacy/settings.dart';
|
|
||||||
import 'package:image_picker/image_picker.dart';
|
|
||||||
import 'chat_controller.dart';
|
|
||||||
import 'chatmessage.dart';
|
|
||||||
import 'package:photo_view/photo_view.dart';
|
|
||||||
|
|
||||||
class ChatPage extends StatefulWidget {
|
|
||||||
var pharmacyName;
|
|
||||||
var profilePictureUrl;
|
|
||||||
|
|
||||||
|
|
||||||
ChatPage({
|
|
||||||
this.pharmacyName,this.profilePictureUrl
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<ChatPage> createState() => _ChatPageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ChatPageState extends State<ChatPage> {
|
|
||||||
final ChatController chatController = Get.put(ChatController());
|
|
||||||
final TextEditingController content = TextEditingController();
|
|
||||||
final ImagePicker _picker = ImagePicker();
|
|
||||||
XFile? _image;
|
|
||||||
var id="2";
|
|
||||||
bool _sending = false;
|
|
||||||
final ScrollController _scrollController = ScrollController();
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
_scrollToBottom();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
backgroundColor:Colors.green,
|
|
||||||
elevation: 0,
|
|
||||||
automaticallyImplyLeading: false,
|
|
||||||
flexibleSpace: SafeArea(
|
|
||||||
child: Container(
|
|
||||||
padding: EdgeInsets.only(right: 16),
|
|
||||||
child: Row(
|
|
||||||
children: <Widget>[
|
|
||||||
IconButton(
|
|
||||||
onPressed: (){
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
icon: Icon(Icons.arrow_back,color: Colors.black,),
|
|
||||||
),
|
|
||||||
SizedBox(width: 2,),
|
|
||||||
CircleAvatar(
|
|
||||||
backgroundImage: NetworkImage(AppSettings.profilePictureUrl),
|
|
||||||
maxRadius: 20,
|
|
||||||
),
|
|
||||||
SizedBox(width: 12,),
|
|
||||||
Expanded(
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: <Widget>[
|
|
||||||
Text(widget.pharmacyName,style: TextStyle( fontSize: 16 ,fontWeight: FontWeight.w600),),
|
|
||||||
// SizedBox(height: 6,),
|
|
||||||
// Text("Online",style: TextStyle(color: Colors.grey.shade600, fontSize: 13),),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
/*IconButton(
|
|
||||||
onPressed: () {
|
|
||||||
UrlLauncher.launch("tel://8328206298");
|
|
||||||
},
|
|
||||||
icon: Icon(Icons.call, color: Colors.black),
|
|
||||||
),*/
|
|
||||||
IconButton(
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => IndexPage()),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
icon: Icon(Icons.videocam, color: Colors.black),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
body: Stack(
|
|
||||||
children: [
|
|
||||||
Obx(() => ListView.builder(
|
|
||||||
itemCount: chatController.messages.length,
|
|
||||||
shrinkWrap: true,
|
|
||||||
padding: EdgeInsets.only(top: 10, bottom: 80), // Adjust bottom padding to accommodate the input field
|
|
||||||
physics: ScrollPhysics(),
|
|
||||||
controller: _scrollController,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
final data = chatController.messages[index];
|
|
||||||
return Container(
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
left: 14, right: 14, top: 10, bottom: 10),
|
|
||||||
child: Align(
|
|
||||||
alignment: (data.messageType != id ? Alignment.topLeft : Alignment.topRight),
|
|
||||||
child: GestureDetector(
|
|
||||||
onTap: () {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => ChatZoomableImage(data.messageContent),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
borderRadius: BorderRadius.circular(20),
|
|
||||||
color: (data.messageType != id
|
|
||||||
? Colors.grey.shade200
|
|
||||||
: Colors.blue[200]),
|
|
||||||
),
|
|
||||||
padding: EdgeInsets.all(16),
|
|
||||||
child: data.isText
|
|
||||||
? Text(data.messageContent, style: TextStyle(fontSize: 15))
|
|
||||||
: Image.network(
|
|
||||||
data.messageContent,
|
|
||||||
scale: 3,
|
|
||||||
width: 100,
|
|
||||||
height: 100,
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
)),
|
|
||||||
Align(alignment: Alignment.bottomCenter,child: Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
|
||||||
child: Container(
|
|
||||||
height: 60,
|
|
||||||
width: double.infinity,
|
|
||||||
color: Colors.white,
|
|
||||||
child: Row(
|
|
||||||
children: <Widget>[
|
|
||||||
GestureDetector(
|
|
||||||
onTap: getImage,
|
|
||||||
child: Container(
|
|
||||||
height: 30,
|
|
||||||
width: 30,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.lightBlue,
|
|
||||||
borderRadius: BorderRadius.circular(30),
|
|
||||||
),
|
|
||||||
child: Icon(Icons.add, color: Colors.white, size: 20),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(width: 15),
|
|
||||||
Expanded(
|
|
||||||
child: TextField(
|
|
||||||
controller: content,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
hintText: "Write message...",
|
|
||||||
hintStyle: TextStyle(color: Colors.black54),
|
|
||||||
border: InputBorder.none,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(width: 15),
|
|
||||||
FloatingActionButton(
|
|
||||||
onPressed: () {
|
|
||||||
sendMessage();
|
|
||||||
},
|
|
||||||
child: Icon(Icons.send, color: Colors.white, size: 18),
|
|
||||||
backgroundColor: Colors.blue,
|
|
||||||
elevation: 0,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _scrollToBottom() {
|
|
||||||
Future.delayed(Duration(milliseconds: 300), () {
|
|
||||||
if (_scrollController.hasClients) {
|
|
||||||
_scrollController.animateTo(
|
|
||||||
_scrollController.position.maxScrollExtent,
|
|
||||||
duration: Duration(milliseconds: 300),
|
|
||||||
curve: Curves.easeInOut,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Future getImage() async {
|
|
||||||
final XFile? image =
|
|
||||||
await _picker.pickImage(source: ImageSource.gallery);
|
|
||||||
if (image != null) {
|
|
||||||
setState(() {
|
|
||||||
_image = image;
|
|
||||||
});
|
|
||||||
sendMessage(); // Call sendMessage function to send the selected image immediately
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void sendMessage() async {
|
|
||||||
String messageContent = content.text.trim();
|
|
||||||
if (messageContent.isNotEmpty || _image != null) {
|
|
||||||
setState(() {
|
|
||||||
_sending = true;
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
if (_image != null) {
|
|
||||||
String imageUrl =
|
|
||||||
await chatController.uploadImage(File(_image!.path),'$id');
|
|
||||||
chatController.sendMessage(imageUrl, '$id', false);
|
|
||||||
_image = null; // Clear the selected image after sending
|
|
||||||
}
|
|
||||||
if (messageContent.isNotEmpty) {
|
|
||||||
chatController.sendMessage(messageContent, '$id', true);
|
|
||||||
content.clear();
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
setState(() {
|
|
||||||
_sending = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
_scrollToBottom(); // Scroll to the bottom after sending message
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:healthcare_pharmacy/settings.dart';
|
|
||||||
import 'package:photo_view/photo_view.dart';
|
|
||||||
|
|
||||||
class ChatZoomableImage extends StatelessWidget {
|
|
||||||
final String imageUrl;
|
|
||||||
|
|
||||||
ChatZoomableImage(this.imageUrl);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
backgroundColor: primaryColor, // Set the background color
|
|
||||||
title: Text('Preview Image'), // Set the title text
|
|
||||||
actions: [
|
|
||||||
IconButton(
|
|
||||||
icon: Icon(Icons.close),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
body: Center(
|
|
||||||
child: imageUrl.isNotEmpty
|
|
||||||
? PhotoView(
|
|
||||||
imageProvider: NetworkImage(imageUrl),
|
|
||||||
minScale: PhotoViewComputedScale.contained,
|
|
||||||
maxScale: PhotoViewComputedScale.contained * 3.0,
|
|
||||||
)
|
|
||||||
: Image.asset(
|
|
||||||
'images/mobilebg.png', // Path to your default image
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,201 +0,0 @@
|
|||||||
import 'dart:convert';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:healthcare_pharmacy/models/chatconversation_model.dart';
|
|
||||||
import 'package:healthcare_pharmacy/settings.dart';
|
|
||||||
import 'ChatMessage.dart';
|
|
||||||
|
|
||||||
class ChatUIconvoid extends StatefulWidget {
|
|
||||||
const ChatUIconvoid({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<ChatUIconvoid> createState() => _ChatUIconvoidState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ChatUIconvoidState extends State<ChatUIconvoid> {
|
|
||||||
|
|
||||||
TextEditingController _messageController = TextEditingController();
|
|
||||||
bool isLoading=false;
|
|
||||||
List<GetCoversatitonIdModel> chatCoversatitonIdList = [];
|
|
||||||
List<ChatMessage> messages = [
|
|
||||||
ChatMessage(message: "Hello", type: "receiver"),
|
|
||||||
ChatMessage(message: "How have you?", type: "receiver"),
|
|
||||||
ChatMessage(
|
|
||||||
message: "I am doing fine.How have you?",
|
|
||||||
type: "sender"),
|
|
||||||
|
|
||||||
];
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
// TODO: implement initState
|
|
||||||
isLoading=true;
|
|
||||||
getConversasionId();
|
|
||||||
super.initState();
|
|
||||||
}
|
|
||||||
Future<void> getConversasionId() async {
|
|
||||||
isLoading = true;
|
|
||||||
try {
|
|
||||||
var response = await AppSettings.getChatId();
|
|
||||||
setState(() {
|
|
||||||
chatCoversatitonIdList =
|
|
||||||
((jsonDecode(response)['newConversation']) as List).map((dynamic model) {
|
|
||||||
return GetCoversatitonIdModel.fromJson(model);
|
|
||||||
}).toList();
|
|
||||||
|
|
||||||
// Extracting the conversation_id from the response
|
|
||||||
String conversationId =
|
|
||||||
jsonDecode(response)['newConversation']['conversation_id'];
|
|
||||||
|
|
||||||
// Use the conversationId as needed in your code
|
|
||||||
print('Conversation ID: $conversationId');
|
|
||||||
|
|
||||||
isLoading = false;
|
|
||||||
isLoading = false;
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
} catch (e) {
|
|
||||||
setState(() {
|
|
||||||
isLoading = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
elevation: 0,
|
|
||||||
automaticallyImplyLeading: false,
|
|
||||||
backgroundColor: Colors.white,
|
|
||||||
flexibleSpace: SafeArea(
|
|
||||||
child: Container(
|
|
||||||
padding: EdgeInsets.only(right: 16),
|
|
||||||
child: Row(
|
|
||||||
children: <Widget>[
|
|
||||||
IconButton(
|
|
||||||
onPressed: (){
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
icon: Icon(Icons.arrow_back,color: Colors.black,),
|
|
||||||
),
|
|
||||||
SizedBox(width: 2,),
|
|
||||||
CircleAvatar(
|
|
||||||
backgroundImage: NetworkImage("https://www.shutterstock.com/image-photo/pharmacist-holding-medicine-box-capsule-260nw-717437125.jpg"),
|
|
||||||
maxRadius: 20,
|
|
||||||
),
|
|
||||||
SizedBox(width: 12,),
|
|
||||||
Expanded(
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: <Widget>[
|
|
||||||
Text("Arminta pharma",style: TextStyle( fontSize: 16 ,fontWeight: FontWeight.w600),),
|
|
||||||
// SizedBox(height: 6,),
|
|
||||||
// Text("Online",style: TextStyle(color: Colors.grey.shade600, fontSize: 13),),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Icon(Icons.settings,color: Colors.black54,),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
body: Stack(
|
|
||||||
children: <Widget>[
|
|
||||||
ListView.builder(
|
|
||||||
itemCount: messages.length,
|
|
||||||
shrinkWrap: true,
|
|
||||||
padding: EdgeInsets.only(top: 10,bottom: 60),
|
|
||||||
itemBuilder: (context, index){
|
|
||||||
return Container(
|
|
||||||
padding: EdgeInsets.only(left: 14,right: 14,top: 10,bottom: 10),
|
|
||||||
child: Align(
|
|
||||||
alignment: (messages[index].type == "receiver"?Alignment.topLeft:Alignment.topRight),
|
|
||||||
child: Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
borderRadius: BorderRadius.circular(20),
|
|
||||||
color: (messages[index].type == "receiver"?Colors.grey.shade200:Colors.blue[200]),
|
|
||||||
),
|
|
||||||
padding: EdgeInsets.symmetric(horizontal: 16,vertical: 10),
|
|
||||||
child: Text(messages[index].message, style: TextStyle(fontSize: 15),),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.bottomLeft,
|
|
||||||
child: Container(
|
|
||||||
padding: EdgeInsets.only(left: 10, bottom: 10, top: 10),
|
|
||||||
height: 60,
|
|
||||||
width: double.infinity,
|
|
||||||
color: Colors.white,
|
|
||||||
child: Row(
|
|
||||||
children: <Widget>[
|
|
||||||
GestureDetector(
|
|
||||||
onTap: () {},
|
|
||||||
child: Container(
|
|
||||||
height: 30,
|
|
||||||
width: 30,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.lightBlue,
|
|
||||||
borderRadius: BorderRadius.circular(30),
|
|
||||||
),
|
|
||||||
child: Icon(
|
|
||||||
Icons.add,
|
|
||||||
color: Colors.white,
|
|
||||||
size: 20,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
width: 15,
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: TextField(
|
|
||||||
controller: _messageController,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
hintText: "Write message...",
|
|
||||||
hintStyle: TextStyle(color: Colors.black54),
|
|
||||||
border: InputBorder.none),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
width: 15,
|
|
||||||
),
|
|
||||||
FloatingActionButton(
|
|
||||||
onPressed: () {
|
|
||||||
String newMessage = _messageController.text;
|
|
||||||
if (newMessage.isNotEmpty) {
|
|
||||||
// Add the new message to the list
|
|
||||||
setState(() {
|
|
||||||
messages.add(
|
|
||||||
ChatMessage(
|
|
||||||
message: newMessage,
|
|
||||||
type: "sender",
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Clear the text field
|
|
||||||
_messageController.clear();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: Icon(
|
|
||||||
Icons.send,
|
|
||||||
color: Colors.white,
|
|
||||||
size: 18,
|
|
||||||
),
|
|
||||||
backgroundColor: Colors.blue,
|
|
||||||
elevation: 0,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,395 +0,0 @@
|
|||||||
import 'dart:convert';
|
|
||||||
import 'dart:io';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:healthcare_pharmacy/pages/index.dart';
|
|
||||||
import 'package:healthcare_pharmacy/settings.dart';
|
|
||||||
import 'package:url_launcher/url_launcher.dart' as UrlLauncher;
|
|
||||||
import 'package:web_socket_channel/io.dart';
|
|
||||||
import 'package:web_socket_channel/web_socket_channel.dart';
|
|
||||||
import 'models/ChatMessage.dart';
|
|
||||||
import 'package:image_picker/image_picker.dart';
|
|
||||||
import 'package:flutter_callkeep/flutter_callkeep.dart';
|
|
||||||
|
|
||||||
|
|
||||||
class ChatUI extends StatefulWidget {
|
|
||||||
|
|
||||||
const ChatUI({Key? key}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<ChatUI> createState() => _ChatUIState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ChatUIState extends State<ChatUI> {
|
|
||||||
WebSocketChannel channel=IOWebSocketChannel.connect(
|
|
||||||
"wss://socketsbay.com/wss/v2/1/demo/",
|
|
||||||
);
|
|
||||||
// WebSocket channel for call signaling
|
|
||||||
late WebSocketChannel callChannel;
|
|
||||||
|
|
||||||
WebSocketConnectionState _connectionState = WebSocketConnectionState.connecting;
|
|
||||||
late ScrollController _scrollController;
|
|
||||||
final TextEditingController _controller = TextEditingController();
|
|
||||||
// Store messages
|
|
||||||
final List<ChatMessage> _messages = [];
|
|
||||||
String myUserId = 'user456';
|
|
||||||
String otherUserId = 'user123';
|
|
||||||
final ImagePicker _picker = ImagePicker();
|
|
||||||
|
|
||||||
Future pickImageFromGallery() async {
|
|
||||||
try {
|
|
||||||
final image = await _picker.pickImage(source: ImageSource.gallery);
|
|
||||||
if (image == null) return;
|
|
||||||
final imageTemp = File(image.path);
|
|
||||||
setState(() {
|
|
||||||
AppSettings.updatedImage = imageTemp;
|
|
||||||
});
|
|
||||||
// uploadProfileApi(AppSettings.updatedImage);
|
|
||||||
AppSettings.saveProfile(image.path);
|
|
||||||
|
|
||||||
|
|
||||||
} on PlatformException catch (e) {
|
|
||||||
print('Failed to pick image: $e');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future takeImageFromCamera() async {
|
|
||||||
try {
|
|
||||||
final image = await _picker.pickImage(source: ImageSource.camera);
|
|
||||||
if (image == null) return;
|
|
||||||
final imageTemp = File(image.path);
|
|
||||||
setState(() {
|
|
||||||
AppSettings.updatedImage = imageTemp;
|
|
||||||
});
|
|
||||||
|
|
||||||
//uploadProfileApi(AppSettings.updatedImage);
|
|
||||||
AppSettings.saveProfile(image.path);
|
|
||||||
|
|
||||||
} on PlatformException catch (e) {
|
|
||||||
print('Failed to pick image: $e');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
backgroundColor: _connectionState == WebSocketConnectionState.error ? Colors.red : _connectionState == WebSocketConnectionState.closed ? Colors.red : Colors.green,
|
|
||||||
elevation: 0,
|
|
||||||
automaticallyImplyLeading: false,
|
|
||||||
flexibleSpace: SafeArea(
|
|
||||||
child: Container(
|
|
||||||
padding: EdgeInsets.only(right: 16),
|
|
||||||
child: Row(
|
|
||||||
children: <Widget>[
|
|
||||||
IconButton(
|
|
||||||
onPressed: (){
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
icon: Icon(Icons.arrow_back,color: Colors.black,),
|
|
||||||
),
|
|
||||||
SizedBox(width: 2,),
|
|
||||||
CircleAvatar(
|
|
||||||
backgroundImage: NetworkImage("https://ehealth.eletsonline.com/wp-content/uploads/2020/12/pharma-industry-in-2021.jpg"),
|
|
||||||
maxRadius: 20,
|
|
||||||
),
|
|
||||||
SizedBox(width: 12,),
|
|
||||||
Expanded(
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: <Widget>[
|
|
||||||
Text("Suresh",style: TextStyle( fontSize: 16 ,fontWeight: FontWeight.w600),),
|
|
||||||
// SizedBox(height: 6,),
|
|
||||||
// Text("Online",style: TextStyle(color: Colors.grey.shade600, fontSize: 13),),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
onPressed: () {
|
|
||||||
UrlLauncher.launch("tel://8328206298");
|
|
||||||
},
|
|
||||||
icon: Icon(Icons.call, color: Colors.black),
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => IndexPage()),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
icon: Icon(Icons.videocam, color: Colors.black),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
body: Stack(
|
|
||||||
children: <Widget>[
|
|
||||||
ListView.builder(
|
|
||||||
controller: _scrollController,
|
|
||||||
itemCount: _messages.length,
|
|
||||||
shrinkWrap: true,
|
|
||||||
padding: EdgeInsets.only(top: 10,bottom: 60),
|
|
||||||
itemBuilder: (context, index){
|
|
||||||
bool isSentByMe = _messages[index].senderId == myUserId;
|
|
||||||
return Container(
|
|
||||||
padding: EdgeInsets.only(left: 14,right: 14,top: 10,bottom: 10),
|
|
||||||
child: Align(
|
|
||||||
alignment: (isSentByMe?Alignment.topRight:Alignment.topLeft),
|
|
||||||
child: Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
borderRadius: BorderRadius.circular(20),
|
|
||||||
color: (isSentByMe?Colors.blue[200]:Colors.grey[200]),
|
|
||||||
),
|
|
||||||
padding: EdgeInsets.symmetric(horizontal: 16,vertical: 10),
|
|
||||||
child: Text(_messages[index].messageContent, style: TextStyle(fontSize: 15),),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.bottomLeft,
|
|
||||||
child: Container(
|
|
||||||
padding: EdgeInsets.only(left: 10, bottom: 10, top: 10),
|
|
||||||
height: 60,
|
|
||||||
width: double.infinity,
|
|
||||||
color: Colors.white,
|
|
||||||
child: Row(
|
|
||||||
children: <Widget>[
|
|
||||||
GestureDetector(
|
|
||||||
onTap: () {
|
|
||||||
showModalBottomSheet<void>(
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return SizedBox(
|
|
||||||
height: 200,
|
|
||||||
child: Center(
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: <Widget>[
|
|
||||||
GestureDetector(
|
|
||||||
child: Icon(
|
|
||||||
Icons.camera_alt_outlined,
|
|
||||||
size: 100,
|
|
||||||
color: greyColor,
|
|
||||||
),
|
|
||||||
onTap: () async {
|
|
||||||
await takeImageFromCamera();
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
width:
|
|
||||||
MediaQuery.of(context).size.width * .20,
|
|
||||||
),
|
|
||||||
GestureDetector(
|
|
||||||
child: Icon(
|
|
||||||
Icons.photo,
|
|
||||||
size: 100,
|
|
||||||
color: greyColor,
|
|
||||||
),
|
|
||||||
onTap: () async {
|
|
||||||
await pickImageFromGallery();
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
child: Container(
|
|
||||||
height: 30,
|
|
||||||
width: 30,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.lightBlue,
|
|
||||||
borderRadius: BorderRadius.circular(30),
|
|
||||||
),
|
|
||||||
child: Icon(
|
|
||||||
Icons.add,
|
|
||||||
color: Colors.white,
|
|
||||||
size: 20,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
width: 15,
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: TextField(
|
|
||||||
controller: _controller,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
hintText: "Write message...",
|
|
||||||
hintStyle: TextStyle(color: Colors.black54),
|
|
||||||
border: InputBorder.none),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
width: 15,
|
|
||||||
),
|
|
||||||
FloatingActionButton(
|
|
||||||
onPressed: () {
|
|
||||||
String newMessage = _controller.text;
|
|
||||||
if (newMessage.isNotEmpty) {
|
|
||||||
// Add the new message to the list
|
|
||||||
setState(() {
|
|
||||||
_sendMessage();
|
|
||||||
});
|
|
||||||
|
|
||||||
// Clear the text field
|
|
||||||
_controller.clear();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: Icon(
|
|
||||||
Icons.send,
|
|
||||||
color: Colors.white,
|
|
||||||
size: 18,
|
|
||||||
),
|
|
||||||
backgroundColor: Colors.blue,
|
|
||||||
elevation: 0,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void _sendMessage() {
|
|
||||||
if (_controller.text.isNotEmpty) {
|
|
||||||
var message = ChatMessage(
|
|
||||||
senderId: myUserId,
|
|
||||||
receiverId: otherUserId,
|
|
||||||
messageType: 'text',
|
|
||||||
messageContent: _controller.text,
|
|
||||||
);
|
|
||||||
channel.sink.add(chatMessageToJson(message));
|
|
||||||
_messages.add(message);
|
|
||||||
_controller.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
// Initialize the WebSocket channel for call signaling
|
|
||||||
callChannel = IOWebSocketChannel.connect(
|
|
||||||
"wss://socketsbay.com/wss/v2/1/demo/call", // adjust the URL accordingly
|
|
||||||
);
|
|
||||||
_scrollController = ScrollController();
|
|
||||||
channel.stream.listen((message) {
|
|
||||||
if (message is String) {
|
|
||||||
var receivedMessage = chatMessageFromJson(message);
|
|
||||||
setState(() {
|
|
||||||
_messages.add(receivedMessage);
|
|
||||||
});
|
|
||||||
_scrollToBottom();
|
|
||||||
}
|
|
||||||
}, onError: (error) {
|
|
||||||
setState(() {
|
|
||||||
_connectionState = WebSocketConnectionState.error;
|
|
||||||
});
|
|
||||||
},onDone: (){
|
|
||||||
setState(() {
|
|
||||||
_connectionState = WebSocketConnectionState.closed;
|
|
||||||
});
|
|
||||||
},);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ... existing code ...
|
|
||||||
|
|
||||||
void startCall(String callId) {
|
|
||||||
// Send a call initiation message to the other user
|
|
||||||
var callMessage = {
|
|
||||||
'type': 'call',
|
|
||||||
'callId': callId,
|
|
||||||
'senderId': myUserId,
|
|
||||||
'receiverId': otherUserId,
|
|
||||||
};
|
|
||||||
callChannel.sink.add(jsonEncode(callMessage));
|
|
||||||
|
|
||||||
// Update UI or perform other actions as needed
|
|
||||||
// ...
|
|
||||||
|
|
||||||
// For simplicity, let's assume the call is accepted after a short delay
|
|
||||||
Future.delayed(Duration(seconds: 2), () {
|
|
||||||
// Handle call accepted
|
|
||||||
onCallAccepted(callId);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void onCallAccepted(String callId) {
|
|
||||||
// Update UI or perform other actions as needed
|
|
||||||
// ...
|
|
||||||
|
|
||||||
// Send a call accepted message to the other user
|
|
||||||
var acceptedMessage = {
|
|
||||||
'type': 'call_accepted',
|
|
||||||
'callId': callId,
|
|
||||||
'senderId': myUserId,
|
|
||||||
'receiverId': otherUserId,
|
|
||||||
};
|
|
||||||
callChannel.sink.add(jsonEncode(acceptedMessage));
|
|
||||||
|
|
||||||
// Start the actual call
|
|
||||||
// ...
|
|
||||||
}
|
|
||||||
|
|
||||||
void endCall(String callId) {
|
|
||||||
// Send a call end message to the other user
|
|
||||||
var endMessage = {
|
|
||||||
'type': 'call_end',
|
|
||||||
'callId': callId,
|
|
||||||
'senderId': myUserId,
|
|
||||||
'receiverId': otherUserId,
|
|
||||||
};
|
|
||||||
callChannel.sink.add(jsonEncode(endMessage));
|
|
||||||
|
|
||||||
// Update UI or perform other actions as needed
|
|
||||||
// ...
|
|
||||||
|
|
||||||
// For simplicity, let's assume the call is ended immediately
|
|
||||||
onCallEnded(callId);
|
|
||||||
}
|
|
||||||
|
|
||||||
void onCallEnded(String callId) {
|
|
||||||
// Update UI or perform other actions as needed
|
|
||||||
// ...
|
|
||||||
|
|
||||||
// Close the call WebSocket channel
|
|
||||||
callChannel.sink.close();
|
|
||||||
|
|
||||||
// For simplicity, let's assume the call ended immediately
|
|
||||||
// ...
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void _scrollToBottom() {
|
|
||||||
// Scroll to the bottom of the list
|
|
||||||
_scrollController.animateTo(
|
|
||||||
_scrollController.position.maxScrollExtent,
|
|
||||||
duration: Duration(milliseconds: 200),
|
|
||||||
curve: Curves.easeOut,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
channel.sink.close();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
enum WebSocketConnectionState { connecting, open, closing, closed, error }
|
|
@ -1,299 +0,0 @@
|
|||||||
import 'dart:convert';
|
|
||||||
import 'dart:io';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:geolocator/geolocator.dart';
|
|
||||||
import 'package:healthcare_pharmacy/companyoffrers.dart';
|
|
||||||
import 'package:healthcare_pharmacy/getmedicines.dart';
|
|
||||||
import 'package:healthcare_pharmacy/maps/app_colors.dart';
|
|
||||||
import 'package:healthcare_pharmacy/medicinecart.dart';
|
|
||||||
import 'package:healthcare_pharmacy/models/addoffer_model.dart';
|
|
||||||
import 'package:healthcare_pharmacy/models/biddingrequest_model.dart';
|
|
||||||
import 'package:healthcare_pharmacy/models/companyoffer_model.dart';
|
|
||||||
import 'package:healthcare_pharmacy/settings.dart';
|
|
||||||
|
|
||||||
import 'package:image_picker/image_picker.dart';
|
|
||||||
import 'package:photo_view/photo_view.dart';
|
|
||||||
|
|
||||||
class GetAllOffers extends StatefulWidget {
|
|
||||||
var bookidID;
|
|
||||||
|
|
||||||
GetAllOffers({
|
|
||||||
this.bookidID
|
|
||||||
});
|
|
||||||
@override
|
|
||||||
State<GetAllOffers> createState() => _GetAllOffersState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _GetAllOffersState extends State<GetAllOffers> {
|
|
||||||
String Url = '';
|
|
||||||
List<GetOffersDetailsModel> offersList = [];
|
|
||||||
List<GetOffersDetailsModel> prescriptionsListOriginal = [];
|
|
||||||
bool isPrescriptionsDataLoading = false;
|
|
||||||
bool isSereverIssue = false;
|
|
||||||
bool isLoading=false;
|
|
||||||
List<String> checked = [];
|
|
||||||
TextEditingController BookingidController = TextEditingController();
|
|
||||||
TextEditingController offerCodeController = TextEditingController();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Future<void> getActiveOffersViewData() async {
|
|
||||||
isLoading = true;
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
|
||||||
var data = await AppSettings.getOffers();
|
|
||||||
setState(() {
|
|
||||||
List<dynamic> responseData = jsonDecode(data)['data'];
|
|
||||||
offersList = responseData
|
|
||||||
.map((jsonObject) => GetOffersDetailsModel.fromJson(jsonObject))
|
|
||||||
.toList();
|
|
||||||
isLoading = false;
|
|
||||||
});
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
setState(() {
|
|
||||||
isLoading = false;
|
|
||||||
isSereverIssue = true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
getActiveOffersViewData();
|
|
||||||
super.initState();
|
|
||||||
BookingidController.text=widget.bookidID;
|
|
||||||
}
|
|
||||||
|
|
||||||
void _onCheckboxChanged(String id, bool value) {
|
|
||||||
setState(() {
|
|
||||||
if (value) {
|
|
||||||
checked.add(id);
|
|
||||||
} else {
|
|
||||||
checked.remove(id);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
showPicDialog(var imageUrl){
|
|
||||||
return showDialog(
|
|
||||||
context: context,
|
|
||||||
barrierDismissible: false,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return StatefulBuilder(
|
|
||||||
builder: (BuildContext context, StateSetter setState) {
|
|
||||||
return AlertDialog(
|
|
||||||
title: const Text(''),
|
|
||||||
content: SingleChildScrollView(
|
|
||||||
child: ListBody(
|
|
||||||
children: <Widget>[
|
|
||||||
Container(
|
|
||||||
width: MediaQuery.of(context).size.width * .10,
|
|
||||||
height: MediaQuery.of(context).size.height * .50,
|
|
||||||
child: PhotoView(
|
|
||||||
imageProvider: NetworkImage(imageUrl) as ImageProvider,
|
|
||||||
maxScale: PhotoViewComputedScale.contained * 4.0,
|
|
||||||
minScale: PhotoViewComputedScale.contained,
|
|
||||||
initialScale: PhotoViewComputedScale.contained,
|
|
||||||
basePosition: Alignment.center,
|
|
||||||
|
|
||||||
)
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
actions: <Widget>[
|
|
||||||
TextButton(
|
|
||||||
child: Text('Close', style: textButtonStyle()),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Widget _allPharmacies() {
|
|
||||||
if (offersList.length != 0) {
|
|
||||||
return Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: ListView.builder(
|
|
||||||
padding: EdgeInsets.all(0),
|
|
||||||
itemCount: offersList.length,
|
|
||||||
itemBuilder: (BuildContext context, int index) {
|
|
||||||
return Card(
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.all(8),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
GestureDetector(
|
|
||||||
child: Container(
|
|
||||||
width: MediaQuery.of(context).size.width * .18,
|
|
||||||
height: MediaQuery.of(context).size.height * .10,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
image: DecorationImage(
|
|
||||||
image: (AppSettings.updatedImage != null)
|
|
||||||
? FileImage(AppSettings.updatedImage!)
|
|
||||||
as ImageProvider
|
|
||||||
: AssetImage("images/mobilebg.png"), // picked file
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
// showPicDialog(prescriptionsList[index].prescription_url);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
SizedBox(width: MediaQuery.of(context).size.width * .02,),
|
|
||||||
Container(
|
|
||||||
width: MediaQuery.of(context).size.width * .55,
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
offersList[index].offer_name
|
|
||||||
.toString()
|
|
||||||
.toUpperCase(),
|
|
||||||
style: valuesTextStyle(),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
offersList[index].offer_code
|
|
||||||
.toString()
|
|
||||||
.toUpperCase(),
|
|
||||||
style: valuesTextStyle(),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
offersList[index].category
|
|
||||||
.toString()
|
|
||||||
.toUpperCase(),
|
|
||||||
style: valuesTextStyle(),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
offersList[index].description
|
|
||||||
.toString()
|
|
||||||
.toUpperCase(),
|
|
||||||
style: valuesTextStyle(),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Checkbox(
|
|
||||||
value: checked.contains(
|
|
||||||
offersList[index].offer_code.toString()),
|
|
||||||
onChanged: (value) {
|
|
||||||
_onCheckboxChanged(
|
|
||||||
offersList[index].offer_code.toString(),
|
|
||||||
value ?? false);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
Container(
|
|
||||||
padding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
|
|
||||||
child:TextButton(
|
|
||||||
onPressed: () {
|
|
||||||
// Add your button click logic here
|
|
||||||
},
|
|
||||||
child: Text(
|
|
||||||
'OfferId:$checked',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 15,
|
|
||||||
color:primaryColor, // Text color
|
|
||||||
decoration: TextDecoration.underline,// Underline the text
|
|
||||||
fontWeight: FontWeight.bold, // Bold text
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),),
|
|
||||||
SizedBox(
|
|
||||||
height: 10,
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
width: MediaQuery.of(context).size.width,
|
|
||||||
height: 60,
|
|
||||||
padding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
|
|
||||||
child: ElevatedButton(
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
primary: primaryColor, // background
|
|
||||||
onPrimary: Colors.white, // foreground
|
|
||||||
),
|
|
||||||
onPressed: ()async {
|
|
||||||
// Get the selected offer code from the checked list
|
|
||||||
String selectedOfferCode = checked.isNotEmpty ? checked[0] : '';
|
|
||||||
|
|
||||||
// Check if an offer code is selected
|
|
||||||
if (selectedOfferCode.isNotEmpty) {
|
|
||||||
bool discountOfferStatus = await AppSettings.discountOffer(
|
|
||||||
selectedOfferCode,
|
|
||||||
widget.bookidID,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (discountOfferStatus) {
|
|
||||||
AppSettings.longSuccessToast('Offer added successfully');
|
|
||||||
Navigator.of(context).pop(true);
|
|
||||||
await Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => MedicineCartList())
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
AppSettings.longFailedToast('Offer addition failed');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Handle the case where no offer code is selected
|
|
||||||
AppSettings.longFailedToast('Please select an offer');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: Text('Submit'),
|
|
||||||
)),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return Center(
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.fromLTRB(0, 40, 0, 0),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
SizedBox(height: MediaQuery.of(context).size.height * .25,),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**/
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppSettings.appBar('All Pharmacies'),
|
|
||||||
body: isPrescriptionsDataLoading?Center(
|
|
||||||
child: CircularProgressIndicator(
|
|
||||||
color: primaryColor,
|
|
||||||
strokeWidth: 5.0,
|
|
||||||
),
|
|
||||||
): _allPharmacies(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,501 +0,0 @@
|
|||||||
import 'dart:convert';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:healthcare_pharmacy/adddeliveryboy.dart';
|
|
||||||
import 'package:healthcare_pharmacy/dashboard.dart';
|
|
||||||
import 'package:healthcare_pharmacy/models/getdeliveryboy_model.dart';
|
|
||||||
import 'package:healthcare_pharmacy/settings.dart';
|
|
||||||
|
|
||||||
class GetDeliveryboyData extends StatefulWidget {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<GetDeliveryboyData> createState() => _GetDeliveryboyDataState();
|
|
||||||
}
|
|
||||||
class _GetDeliveryboyDataState extends State<GetDeliveryboyData> {
|
|
||||||
List<GetDeliveryboyDetailsModel> modeldeliveryboyList = [];
|
|
||||||
TextEditingController deliveryboyNameController = TextEditingController();
|
|
||||||
TextEditingController deliveryboyPhoneController = TextEditingController();
|
|
||||||
TextEditingController deliveryboyAlterPhoneController = TextEditingController();
|
|
||||||
TextEditingController deliveryboyAddress = TextEditingController();
|
|
||||||
TextEditingController deliveryboyStatus = TextEditingController();
|
|
||||||
|
|
||||||
|
|
||||||
bool isLoading=false;
|
|
||||||
|
|
||||||
Future<void> readJson() async {
|
|
||||||
var response1= await AppSettings.getAllDeliverboy();
|
|
||||||
print(response1);
|
|
||||||
setState(() {
|
|
||||||
modeldeliveryboyList =
|
|
||||||
((jsonDecode(response1)['deliveryBoys']) as List).map((dynamic model) {
|
|
||||||
return GetDeliveryboyDetailsModel.fromJson(model);
|
|
||||||
}).toList();
|
|
||||||
isLoading=false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
isLoading=true;
|
|
||||||
readJson();
|
|
||||||
super.initState();
|
|
||||||
}
|
|
||||||
|
|
||||||
showUpdateDeliveryDialog(var object) async {
|
|
||||||
deliveryboyNameController.text=object.deliveryboy_name??'';
|
|
||||||
deliveryboyPhoneController.text=object.deliveryboy_phone??'';
|
|
||||||
deliveryboyAlterPhoneController.text=object.deliveryboy_alternativeContactNumber??'';
|
|
||||||
deliveryboyAddress.text=object.deliveryboy_address??'';
|
|
||||||
return showDialog(
|
|
||||||
context: context,
|
|
||||||
barrierDismissible: false,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return StatefulBuilder(
|
|
||||||
builder: (BuildContext context, StateSetter setState) {
|
|
||||||
return AlertDialog(
|
|
||||||
title: const Text('Update Deliveryboy'),
|
|
||||||
content: SingleChildScrollView(
|
|
||||||
child: ListBody(
|
|
||||||
children: <Widget>[
|
|
||||||
Container(
|
|
||||||
padding: const EdgeInsets.fromLTRB(10, 10, 10, 0),
|
|
||||||
child: TextFormField(
|
|
||||||
cursorColor: greyColor,
|
|
||||||
controller: deliveryboyNameController,
|
|
||||||
textCapitalization: TextCapitalization.characters,
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
prefixIcon: Icon(
|
|
||||||
Icons.ac_unit_outlined,
|
|
||||||
color: greyColor,
|
|
||||||
),
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: greyColor)),
|
|
||||||
focusedBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: greyColor),
|
|
||||||
),
|
|
||||||
enabledBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: greyColor),
|
|
||||||
),
|
|
||||||
labelText: 'Enter name',
|
|
||||||
labelStyle: TextStyle(
|
|
||||||
color: greyColor, //<-- SEE HERE
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
padding: const EdgeInsets.fromLTRB(10, 10, 10, 0),
|
|
||||||
child: TextFormField(
|
|
||||||
cursorColor: greyColor,
|
|
||||||
controller: deliveryboyPhoneController,
|
|
||||||
keyboardType: TextInputType.number,
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
prefixIcon: Icon(
|
|
||||||
Icons.phone,
|
|
||||||
color: greyColor,
|
|
||||||
),
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: greyColor)),
|
|
||||||
focusedBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: greyColor),
|
|
||||||
),
|
|
||||||
enabledBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: greyColor),
|
|
||||||
),
|
|
||||||
labelText: 'Enter phone number',
|
|
||||||
labelStyle: TextStyle(
|
|
||||||
color: greyColor, //<-- SEE HERE
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
padding: const EdgeInsets.fromLTRB(10, 10, 10, 0),
|
|
||||||
child: TextFormField(
|
|
||||||
cursorColor: greyColor,
|
|
||||||
controller: deliveryboyAlterPhoneController,
|
|
||||||
keyboardType: TextInputType.number,
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
prefixIcon: Icon(
|
|
||||||
Icons.phone,
|
|
||||||
color: greyColor,
|
|
||||||
),
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: greyColor)),
|
|
||||||
focusedBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: greyColor),
|
|
||||||
),
|
|
||||||
enabledBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: greyColor),
|
|
||||||
),
|
|
||||||
labelText: 'Enter Alternative phone number',
|
|
||||||
labelStyle: TextStyle(
|
|
||||||
color: greyColor, //<-- SEE HERE
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
actions: <Widget>[
|
|
||||||
TextButton(
|
|
||||||
child: Text('Cancel',style:textButtonStyle()),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
child: Text('Update',style:textButtonStyle()),
|
|
||||||
onPressed: () async{
|
|
||||||
if (deliveryboyNameController.text != '' ) {
|
|
||||||
AppSettings.preLoaderDialog(context);
|
|
||||||
|
|
||||||
Map<String, dynamic> payload = {
|
|
||||||
"pharmacyname": "string",
|
|
||||||
"name": deliveryboyNameController.text.toString(),
|
|
||||||
"alternativeContactNumber": deliveryboyAlterPhoneController.text.toString(),
|
|
||||||
"phone": deliveryboyPhoneController.text.toString(),
|
|
||||||
"address": deliveryboyAddress.text.toString(),
|
|
||||||
"city": "string",
|
|
||||||
"state": "string",
|
|
||||||
"zip": "string",
|
|
||||||
"status": "active",
|
|
||||||
"longitude": 0,
|
|
||||||
"latitude": 0,
|
|
||||||
"fcmId": "string"
|
|
||||||
};
|
|
||||||
|
|
||||||
bool offerStatus = await AppSettings.updateDeliveryboy(object.deliveryboy_phone, payload);
|
|
||||||
try {
|
|
||||||
if (offerStatus) {
|
|
||||||
Navigator.of(context, rootNavigator: true).pop();
|
|
||||||
AppSettings.longSuccessToast(
|
|
||||||
"Deliveryboy Updated Successfully");
|
|
||||||
deliveryboyNameController.text = '';
|
|
||||||
deliveryboyAlterPhoneController.text = '';
|
|
||||||
deliveryboyPhoneController.text = '';
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
await readJson();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Navigator.of(context, rootNavigator: true).pop();
|
|
||||||
AppSettings.longFailedToast(
|
|
||||||
"Deliveryboy upadtion failed");
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
}
|
|
||||||
} catch (exception) {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
print(exception);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
AppSettings.longFailedToast("enter details");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Widget renderzUi(){
|
|
||||||
if(modeldeliveryboyList.length!=0){
|
|
||||||
|
|
||||||
return Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
|
||||||
children: [
|
|
||||||
Expanded(child:ListView.builder(
|
|
||||||
padding: EdgeInsets.all(0),
|
|
||||||
itemCount: modeldeliveryboyList .length,
|
|
||||||
itemBuilder: (context,index){
|
|
||||||
var data=modeldeliveryboyList[index];
|
|
||||||
return GestureDetector(
|
|
||||||
onTap: () {
|
|
||||||
|
|
||||||
},
|
|
||||||
child: Card(
|
|
||||||
child: ListTile(
|
|
||||||
title: RichText(
|
|
||||||
text: TextSpan(
|
|
||||||
style: DefaultTextStyle.of(context).style,
|
|
||||||
children: <TextSpan>[
|
|
||||||
TextSpan(
|
|
||||||
text: 'Name: ',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.black,
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TextSpan(
|
|
||||||
text: modeldeliveryboyList[index].deliveryboy_name,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
color: primaryColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
subtitle: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
SizedBox(height:5),
|
|
||||||
RichText(
|
|
||||||
text: TextSpan(
|
|
||||||
style: DefaultTextStyle.of(context).style,
|
|
||||||
children: <TextSpan>[
|
|
||||||
TextSpan(
|
|
||||||
text: 'phone: ',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
color: Colors.black, // Change the color for "Description" text
|
|
||||||
fontWeight: FontWeight.bold, // You can apply other styles too
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TextSpan(
|
|
||||||
text: modeldeliveryboyList[index].deliveryboy_phone,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
color: primaryColor, // Change the color for description content
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(height:5),
|
|
||||||
RichText(
|
|
||||||
text: TextSpan(
|
|
||||||
style: DefaultTextStyle.of(context).style,
|
|
||||||
children: <TextSpan>[
|
|
||||||
TextSpan(
|
|
||||||
text: 'alternative phone: ',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
color: Colors.black, // Change the color for "Description" text
|
|
||||||
fontWeight: FontWeight.bold, // You can apply other styles too
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TextSpan(
|
|
||||||
text: modeldeliveryboyList[index].deliveryboy_alternativeContactNumber,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
color:primaryColor, // Change the color for description content
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(height:5),
|
|
||||||
RichText(
|
|
||||||
text: TextSpan(
|
|
||||||
style: DefaultTextStyle.of(context).style,
|
|
||||||
children: <TextSpan>[
|
|
||||||
TextSpan(
|
|
||||||
text: 'address: ',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
color: Colors.black, // Change the color for "Description" text
|
|
||||||
fontWeight: FontWeight.bold, // You can apply other styles too
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TextSpan(
|
|
||||||
text: modeldeliveryboyList[index].deliveryboy_address,
|
|
||||||
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
color:primaryColor, // Change the color for description content
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(height:10),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
IconButton(
|
|
||||||
icon: Icon(Icons.edit),
|
|
||||||
onPressed: () {
|
|
||||||
showUpdateDeliveryDialog(modeldeliveryboyList[index]);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.delete,color: primaryColor,),
|
|
||||||
|
|
||||||
onPressed: () async{
|
|
||||||
showDialog(
|
|
||||||
//if set to true allow to close popup by tapping out of the popup
|
|
||||||
//barrierDismissible: false,
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) => AlertDialog(
|
|
||||||
title: const Text('Do you want to delete Delivery Boy?',
|
|
||||||
style: TextStyle(
|
|
||||||
color: primaryColor,
|
|
||||||
fontSize: 20,
|
|
||||||
)),
|
|
||||||
actionsAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: ()async {
|
|
||||||
bool deleteDeliveryboyStatus = await AppSettings.deleteDeliveryboy(modeldeliveryboyList[index].deliveryboy_phone);
|
|
||||||
|
|
||||||
|
|
||||||
if(deleteDeliveryboyStatus){
|
|
||||||
readJson();
|
|
||||||
AppSettings.longSuccessToast('Deliveryboy deleted successfully');
|
|
||||||
Navigator.of(context).pop(true);
|
|
||||||
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
AppSettings.longFailedToast('Deliveryboy deletion failed');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: const Text('Yes',
|
|
||||||
style: TextStyle(
|
|
||||||
color: primaryColor,
|
|
||||||
fontSize: 20,
|
|
||||||
)),
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop(true);
|
|
||||||
},
|
|
||||||
child: const Text('No',
|
|
||||||
style: TextStyle(
|
|
||||||
color: primaryColor,
|
|
||||||
fontSize: 20,
|
|
||||||
)),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}) ),
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.fromLTRB(8, 8, 8, 8),
|
|
||||||
child: CircleAvatar(
|
|
||||||
backgroundColor: primaryColor,
|
|
||||||
radius: 40,
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: <Widget>[
|
|
||||||
IconButton(
|
|
||||||
iconSize: 40,
|
|
||||||
icon: const Icon(
|
|
||||||
Icons.add,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
onPressed: () async{
|
|
||||||
Navigator.pop(context);
|
|
||||||
await Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => Deliverboy()),
|
|
||||||
);
|
|
||||||
//showBoreAddingDialog();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
/* Padding(
|
|
||||||
padding: EdgeInsets.fromLTRB(5, 0, 5, 5),
|
|
||||||
child: Text(
|
|
||||||
'Add Tanks ',
|
|
||||||
style: TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
)*/
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
return Center(
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.fromLTRB(0, 40, 0, 0),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
SizedBox(height: MediaQuery.of(context).size.height * .25,),
|
|
||||||
Text('Click below icon to add new Delivery Boy'),
|
|
||||||
SizedBox(
|
|
||||||
height: 20,
|
|
||||||
),
|
|
||||||
CircleAvatar(
|
|
||||||
backgroundColor: primaryColor,
|
|
||||||
radius: 40,
|
|
||||||
child: IconButton(
|
|
||||||
iconSize: 40,
|
|
||||||
icon: const Icon(
|
|
||||||
Icons.add,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
onPressed: () async {
|
|
||||||
Navigator.pop(context);
|
|
||||||
await Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => Deliverboy()),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return SafeArea(
|
|
||||||
child: Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
title: Text('Delivery Boy'),
|
|
||||||
backgroundColor: primaryColor,
|
|
||||||
leading: IconButton(
|
|
||||||
icon: Icon(Icons.arrow_back),
|
|
||||||
onPressed: () async {
|
|
||||||
await Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => const Dashboard()),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
body: isLoading?Center(
|
|
||||||
child: CircularProgressIndicator(
|
|
||||||
color: primaryColor,
|
|
||||||
strokeWidth: 5.0,
|
|
||||||
),
|
|
||||||
):renderzUi(),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
import 'package:meta/meta.dart';
|
|
||||||
import 'dart:convert';
|
|
||||||
|
|
||||||
// Define chatMessageFromJson and chatMessageToJson at the top level
|
|
||||||
ChatMessage chatMessageFromJson(String str) => ChatMessage.fromJson(json.decode(str));
|
|
||||||
|
|
||||||
String chatMessageToJson(ChatMessage data) => json.encode(data.toJson());
|
|
||||||
|
|
||||||
class ChatMessage {
|
|
||||||
String senderId;
|
|
||||||
String receiverId;
|
|
||||||
String messageType;
|
|
||||||
String messageContent;
|
|
||||||
|
|
||||||
ChatMessage({
|
|
||||||
required this.senderId,
|
|
||||||
required this.receiverId,
|
|
||||||
required this.messageType,
|
|
||||||
required this.messageContent,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory ChatMessage.fromJson(Map<String, dynamic> json) => ChatMessage(
|
|
||||||
senderId: json["senderId"],
|
|
||||||
receiverId: json["receiverId"],
|
|
||||||
messageType: json["messageType"],
|
|
||||||
messageContent: json["messageContent"],
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => {
|
|
||||||
"senderId": senderId,
|
|
||||||
"receiverId": receiverId,
|
|
||||||
"messageType": messageType,
|
|
||||||
"messageContent": messageContent,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,69 +0,0 @@
|
|||||||
import 'dart:convert';
|
|
||||||
|
|
||||||
List<GetOffersDetailsModel> listdadFromJson(String str) => List<GetOffersDetailsModel >.from(json.decode(str).map((x) => GetOffersDetailsModel .fromJson(x)));
|
|
||||||
|
|
||||||
String listdadToJson(List<GetOffersDetailsModel > data) => json.encode(List<dynamic>.from(data.map((x) => x.toJson())));
|
|
||||||
|
|
||||||
class GetOffersDetailsModel {
|
|
||||||
String ? description;
|
|
||||||
String ? starting_date;
|
|
||||||
String ? ending_date;
|
|
||||||
String ? offer_code;
|
|
||||||
List<Picture> picture;
|
|
||||||
String ? offer_name;
|
|
||||||
String ? category;
|
|
||||||
|
|
||||||
|
|
||||||
GetOffersDetailsModel ({
|
|
||||||
required this.description,
|
|
||||||
required this.starting_date,
|
|
||||||
required this.ending_date,
|
|
||||||
required this.offer_code,
|
|
||||||
required this.picture,
|
|
||||||
required this.offer_name ,
|
|
||||||
required this.category ,
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
factory GetOffersDetailsModel .fromJson(Map<String, dynamic> json) => GetOffersDetailsModel (
|
|
||||||
description: json["description"],
|
|
||||||
starting_date: json["starting_date"],
|
|
||||||
ending_date: json["ending_date"],
|
|
||||||
offer_code: json["offer_code"],
|
|
||||||
category: json["category"],
|
|
||||||
|
|
||||||
picture: List<Picture>.from(json["picture"].map((x) => Picture.fromJson(x))),
|
|
||||||
offer_name : json["offer_name"],
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => {
|
|
||||||
"description": description,
|
|
||||||
"starting_date": starting_date,
|
|
||||||
"ending_date": ending_date,
|
|
||||||
"offer_code": offer_code,
|
|
||||||
"picture": List<dynamic>.from(picture.map((x) => x.toJson())),
|
|
||||||
"offer_name": offer_name,
|
|
||||||
"category": category,
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
class Picture {
|
|
||||||
String id;
|
|
||||||
String url;
|
|
||||||
|
|
||||||
Picture({
|
|
||||||
required this.id,
|
|
||||||
required this.url,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory Picture.fromJson(Map<String, dynamic> json) => Picture(
|
|
||||||
id: json["_id"],
|
|
||||||
url: json["url"],
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => {
|
|
||||||
"_id": id,
|
|
||||||
"url": url,
|
|
||||||
};
|
|
||||||
}
|
|
@ -1,69 +0,0 @@
|
|||||||
import 'dart:convert';
|
|
||||||
|
|
||||||
List<GetApprovedOffersDetailsModel> listdadFromJson(String str) => List<GetApprovedOffersDetailsModel >.from(json.decode(str).map((x) => GetApprovedOffersDetailsModel .fromJson(x)));
|
|
||||||
|
|
||||||
String listdadToJson(List<GetApprovedOffersDetailsModel > data) => json.encode(List<dynamic>.from(data.map((x) => x.toJson())));
|
|
||||||
|
|
||||||
class GetApprovedOffersDetailsModel {
|
|
||||||
String ? description;
|
|
||||||
String ? starting_date;
|
|
||||||
String ? ending_date;
|
|
||||||
String ? offer_code;
|
|
||||||
List<Picture> picture;
|
|
||||||
String ? offer_name;
|
|
||||||
String ? category;
|
|
||||||
|
|
||||||
|
|
||||||
GetApprovedOffersDetailsModel ({
|
|
||||||
required this.description,
|
|
||||||
required this.starting_date,
|
|
||||||
required this.ending_date,
|
|
||||||
required this.offer_code,
|
|
||||||
required this.picture,
|
|
||||||
required this.offer_name ,
|
|
||||||
required this.category ,
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
factory GetApprovedOffersDetailsModel .fromJson(Map<String, dynamic> json) => GetApprovedOffersDetailsModel (
|
|
||||||
description: json["description"],
|
|
||||||
starting_date: json["starting_date"],
|
|
||||||
ending_date: json["ending_date"],
|
|
||||||
offer_code: json["offer_code"],
|
|
||||||
category: json["category"],
|
|
||||||
|
|
||||||
picture: List<Picture>.from(json["picture"].map((x) => Picture.fromJson(x))),
|
|
||||||
offer_name : json["offer_name"],
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => {
|
|
||||||
"description": description,
|
|
||||||
"starting_date": starting_date,
|
|
||||||
"ending_date": ending_date,
|
|
||||||
"offer_code": offer_code,
|
|
||||||
"picture": List<dynamic>.from(picture.map((x) => x.toJson())),
|
|
||||||
"offer_name": offer_name,
|
|
||||||
"category": category,
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
class Picture {
|
|
||||||
String id;
|
|
||||||
String url;
|
|
||||||
|
|
||||||
Picture({
|
|
||||||
required this.id,
|
|
||||||
required this.url,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory Picture.fromJson(Map<String, dynamic> json) => Picture(
|
|
||||||
id: json["_id"],
|
|
||||||
url: json["url"],
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => {
|
|
||||||
"_id": id,
|
|
||||||
"url": url,
|
|
||||||
};
|
|
||||||
}
|
|
@ -1,67 +1,27 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:healthcare_pharmacy/settings.dart';
|
|
||||||
|
|
||||||
class PrescriptionPicture {
|
|
||||||
late String id;
|
|
||||||
late String url;
|
|
||||||
|
|
||||||
PrescriptionPicture({
|
|
||||||
required this.id,
|
|
||||||
required this.url,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory PrescriptionPicture.fromJson(Map<String, dynamic> json) {
|
|
||||||
return PrescriptionPicture(
|
|
||||||
id: json['_id'],
|
|
||||||
url: json['url'],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class BiddingRequestsModel {
|
class BiddingRequestsModel {
|
||||||
String? customerId = '';
|
String custumerid_bidding = '';
|
||||||
String? pharmacyId = '';
|
String pharmacyid_bidding='';
|
||||||
String? amount = '';
|
String amount_bidding='';
|
||||||
String? bookingId = '';
|
String bidding_bookingid='';
|
||||||
String? profilePicture = '';
|
|
||||||
String? firstName = '';
|
|
||||||
String? address = '';
|
|
||||||
String orderStatus = '';
|
|
||||||
String status = '';
|
|
||||||
|
|
||||||
List<PrescriptionPicture> PrescriptionPictures = [];
|
|
||||||
|
|
||||||
Color cardColor=Colors.white;
|
Color cardColor=Colors.white;
|
||||||
Color textColor = Colors.black;
|
|
||||||
|
|
||||||
BiddingRequestsModel();
|
BiddingRequestsModel();
|
||||||
|
|
||||||
factory BiddingRequestsModel.fromJson(Map<String, dynamic> json){
|
factory BiddingRequestsModel.fromJson(Map<String, dynamic> json){
|
||||||
BiddingRequestsModel rtvm = BiddingRequestsModel();
|
BiddingRequestsModel rtvm = new BiddingRequestsModel();
|
||||||
|
|
||||||
rtvm.customerId = json['customerId'].toString() ?? '';
|
rtvm.custumerid_bidding = json['customerId'].toString() ??'';
|
||||||
rtvm.pharmacyId = json['pharmacyId'].toString() ?? '';
|
rtvm.pharmacyid_bidding = json['pharmacyId'].toString() ?? '';
|
||||||
rtvm.amount = json['biddingAmount'].toString() ?? '';
|
rtvm.amount_bidding = json['biddingAmount'].toString() ?? '';
|
||||||
rtvm.bookingId = json['bookingId'].toString() ?? '';
|
rtvm.bidding_bookingid = json['bookingId'].toString() ?? '';
|
||||||
rtvm.profilePicture = json['profilePicture'] ?? '';
|
|
||||||
rtvm.firstName = json['customerDetails']["firstName"].toString() ?? '';
|
|
||||||
rtvm.address = json['customerDetails']["address1"].toString() ?? '';
|
|
||||||
rtvm.status = json['status'];
|
|
||||||
|
|
||||||
if (json['PrescriptionPictures'] != null) {
|
// rtvm.prescription_url = json['pictureUrl'][0] ?? '';
|
||||||
var pictures = json['PrescriptionPictures'] as List;
|
|
||||||
rtvm.PrescriptionPictures =
|
|
||||||
pictures.map((picture) => PrescriptionPicture.fromJson(picture)).toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rtvm.status.toString().toLowerCase() == 'accepted') {
|
|
||||||
rtvm.textColor = Colors.green;
|
|
||||||
} else if (rtvm.status.toString().toLowerCase() == 'rejected') {
|
|
||||||
rtvm.textColor = Colors.red;
|
|
||||||
} else {
|
|
||||||
rtvm.textColor = primaryColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
return rtvm;
|
return rtvm;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,22 +0,0 @@
|
|||||||
import 'dart:convert';
|
|
||||||
|
|
||||||
List<GetCoversatitonIdModel> listdadFromJson(String str) => List<GetCoversatitonIdModel >.from(json.decode(str).map((x) => GetCoversatitonIdModel .fromJson(x)));
|
|
||||||
|
|
||||||
String listdadToJson(List<GetCoversatitonIdModel > data) => json.encode(List<dynamic>.from(data.map((x) => x.toJson())));
|
|
||||||
|
|
||||||
class GetCoversatitonIdModel {
|
|
||||||
String ? conversation_id;
|
|
||||||
|
|
||||||
GetCoversatitonIdModel ({
|
|
||||||
required this.conversation_id,
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
factory GetCoversatitonIdModel .fromJson(Map<String, dynamic> json) => GetCoversatitonIdModel (
|
|
||||||
conversation_id: json["conversation_id"],
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => {
|
|
||||||
"conversation_id": conversation_id,
|
|
||||||
};
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
|
|
||||||
class GetDeliveryboyDetailsModel {
|
|
||||||
String deliveryboy_name = '';
|
|
||||||
String deliveryboy_phone = '';
|
|
||||||
String deliveryboy_alternativeContactNumber = '';
|
|
||||||
String deliveryboy_address='';
|
|
||||||
// String deliveryboy_status='';
|
|
||||||
|
|
||||||
|
|
||||||
Color cardColor=Colors.white;
|
|
||||||
|
|
||||||
GetDeliveryboyDetailsModel();
|
|
||||||
|
|
||||||
factory GetDeliveryboyDetailsModel.fromJson(Map<String, dynamic> json){
|
|
||||||
GetDeliveryboyDetailsModel rtvm = new GetDeliveryboyDetailsModel();
|
|
||||||
|
|
||||||
rtvm.deliveryboy_name = json['name'] ?? '';
|
|
||||||
rtvm.deliveryboy_phone = json['phone'] ?? '';
|
|
||||||
rtvm.deliveryboy_alternativeContactNumber = json['alternativeContactNumber'] ?? '';
|
|
||||||
rtvm.deliveryboy_address = json['address'] ??'';
|
|
||||||
// rtvm.deliveryboy_status = json['status'] ??'';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return rtvm;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,79 +1,30 @@
|
|||||||
import 'dart:convert';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
List<GetOffersDetailsModel> listdadFromJson(String str) => List<GetOffersDetailsModel >.from(json.decode(str).map((x) => GetOffersDetailsModel .fromJson(x)));
|
|
||||||
|
|
||||||
String listdadToJson(List<GetOffersDetailsModel > data) => json.encode(List<dynamic>.from(data.map((x) => x.toJson())));
|
|
||||||
|
|
||||||
class GetOffersDetailsModel {
|
class GetOffersDetailsModel {
|
||||||
String ? description;
|
String offer_name = '';
|
||||||
String ? starting_date;
|
String offer_code = '';
|
||||||
String ? ending_date;
|
String description = '';
|
||||||
String ? offer_code;
|
String offer='';
|
||||||
List<Picture> picture;
|
String starting_date='';
|
||||||
String ? offer_name;
|
Color cardColor=Colors.white;
|
||||||
String ? category;
|
String ending_date='';
|
||||||
String ? pharmacyId;
|
|
||||||
String request_status='';
|
|
||||||
|
|
||||||
|
|
||||||
GetOffersDetailsModel ({
|
|
||||||
required this.description,
|
|
||||||
required this.starting_date,
|
|
||||||
required this.ending_date,
|
|
||||||
required this.offer_code,
|
|
||||||
required this.picture,
|
|
||||||
required this.offer_name ,
|
|
||||||
required this.category ,
|
|
||||||
required this.pharmacyId ,
|
|
||||||
required this.request_status ,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory GetOffersDetailsModel .fromJson(Map<String, dynamic> json) => GetOffersDetailsModel (
|
|
||||||
description: json["description"],
|
|
||||||
starting_date: json["starting_date"],
|
|
||||||
ending_date: json["ending_date"],
|
|
||||||
offer_code: json["offer_code"],
|
|
||||||
category: json["category"],
|
|
||||||
|
|
||||||
picture: List<Picture>.from(json["picture"].map((x) => Picture.fromJson(x))),
|
|
||||||
offer_name : json["offer_name"],
|
|
||||||
pharmacyId : json["pharmacyId"],
|
|
||||||
request_status : json["request_status"],
|
|
||||||
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => {
|
GetOffersDetailsModel();
|
||||||
"description": description,
|
|
||||||
"starting_date": starting_date,
|
|
||||||
"ending_date": ending_date,
|
|
||||||
"offer_code": offer_code,
|
|
||||||
"picture": List<dynamic>.from(picture.map((x) => x.toJson())),
|
|
||||||
"offer_name": offer_name,
|
|
||||||
"category": category,
|
|
||||||
"pharmacyId": pharmacyId,
|
|
||||||
"request_status": request_status,
|
|
||||||
|
|
||||||
|
factory GetOffersDetailsModel.fromJson(Map<String, dynamic> json){
|
||||||
|
GetOffersDetailsModel rtvm = new GetOffersDetailsModel();
|
||||||
|
|
||||||
|
rtvm.offer_name = json['offer_name'] ?? '';
|
||||||
|
rtvm.offer_code = json['offer_code'] ?? '';
|
||||||
|
rtvm.description = json['description'] ?? '';
|
||||||
|
rtvm.offer = json['offer'] ?? '';
|
||||||
|
rtvm.starting_date = json['starting_date'] ??'';
|
||||||
|
rtvm.ending_date = json['ending_date'] ??'';
|
||||||
|
|
||||||
};
|
return rtvm;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Picture {
|
|
||||||
String id;
|
|
||||||
String url;
|
|
||||||
|
|
||||||
Picture({
|
|
||||||
required this.id,
|
|
||||||
required this.url,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory Picture.fromJson(Map<String, dynamic> json) => Picture(
|
|
||||||
id: json["_id"],
|
|
||||||
url: json["url"],
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => {
|
|
||||||
"_id": id,
|
|
||||||
"url": url,
|
|
||||||
};
|
|
||||||
}
|
}
|
@ -1,60 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:healthcare_pharmacy/settings.dart';
|
|
||||||
class PharmacyAccountsModel {
|
|
||||||
|
|
||||||
String pharmacyId = '';
|
|
||||||
String customerId = '';
|
|
||||||
String bookingId = '';
|
|
||||||
String biddingAmount = '';
|
|
||||||
String date = '';
|
|
||||||
String orderStatus = '';
|
|
||||||
String acceptedCount = '';
|
|
||||||
String pendingRejectedCount = '';
|
|
||||||
String deliveredCount = '';
|
|
||||||
String deliveredTotalPrice = '';
|
|
||||||
String deliveredTotalAmountPaid = '';
|
|
||||||
String deliveredTotalAmountDue = '';
|
|
||||||
Color payment_color=Colors.grey;
|
|
||||||
String displayText = '';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PharmacyAccountsModel();
|
|
||||||
|
|
||||||
|
|
||||||
factory PharmacyAccountsModel.fromJson(Map<String, dynamic> json){
|
|
||||||
PharmacyAccountsModel rtvm = new PharmacyAccountsModel();
|
|
||||||
|
|
||||||
rtvm.pharmacyId = json['pharmacyId'] ?? '';
|
|
||||||
|
|
||||||
rtvm.customerId = json['customerId'] ?? '';
|
|
||||||
rtvm.bookingId = json['bookingId'] ?? '';
|
|
||||||
rtvm.biddingAmount = json['biddingAmount'] ?? '';
|
|
||||||
rtvm.date = json['date'] ?? '';
|
|
||||||
rtvm.orderStatus = json['status'] ?? '';
|
|
||||||
|
|
||||||
rtvm.acceptedCount = json['acceptedCount'] ?? '';
|
|
||||||
rtvm.pendingRejectedCount = json['pendingRejectedCount'] ?? '';
|
|
||||||
rtvm.deliveredCount = json['deliveredCount'] ?? '';
|
|
||||||
rtvm.deliveredTotalPrice = json['deliveredTotalPrice'] ?? '';
|
|
||||||
rtvm.deliveredTotalAmountPaid = json['deliveredTotalAmountPaid'] ?? '';
|
|
||||||
rtvm.deliveredTotalAmountDue = json['deliveredTotalAmountDue'] ?? '';
|
|
||||||
|
|
||||||
/* if(rtvm.orderStatus=='delivered' && rtvm.payment_status=='paid'){
|
|
||||||
rtvm.payment_color=Colors.green;
|
|
||||||
rtvm.displayText='Payment Completed';
|
|
||||||
}
|
|
||||||
else if(rtvm.orderStatus=='delivered' && rtvm.payment_status=='due'){
|
|
||||||
rtvm.payment_color=primaryColor;
|
|
||||||
rtvm.displayText='Due';
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
return rtvm;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,271 +0,0 @@
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:healthcare_pharmacy/settings.dart';
|
|
||||||
import 'dart:async';
|
|
||||||
import 'package:permission_handler/permission_handler.dart';
|
|
||||||
|
|
||||||
import 'package:agora_rtc_engine/rtc_engine.dart';
|
|
||||||
import 'package:agora_rtc_engine/rtc_engine.dart' as rtc_engine;
|
|
||||||
import 'package:agora_rtc_engine/rtc_local_view.dart' as rtc_local_view;
|
|
||||||
import 'package:agora_rtc_engine/rtc_remote_view.dart' as rtc_remote_view;
|
|
||||||
|
|
||||||
class CallPage extends StatefulWidget {
|
|
||||||
final String? channelName;
|
|
||||||
final ClientRole? role;
|
|
||||||
const CallPage({Key? key, this.channelName, this.role}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<CallPage> createState() => _CallPageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _CallPageState extends State<CallPage> {
|
|
||||||
final _users = <int>[];
|
|
||||||
final _infoString = <String>[];
|
|
||||||
late RtcEngine _engine;
|
|
||||||
bool muted = false; // Define the muted variable
|
|
||||||
bool viewPanel = true;
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_users.clear();
|
|
||||||
_engine.leaveChannel();
|
|
||||||
_engine.destroy();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> initialize() async {
|
|
||||||
if (appId.isEmpty) {
|
|
||||||
setState(() {
|
|
||||||
_infoString.add('AppId is missing please provide AppId');
|
|
||||||
_infoString.add('Agora Engine is not starting');
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_engine = await rtc_engine.RtcEngine.create(appId);
|
|
||||||
await _engine.enableVideo();
|
|
||||||
await _engine.setChannelProfile(ChannelProfile.LiveBroadcasting);
|
|
||||||
await _engine.setClientRole(widget.role!);
|
|
||||||
_addAgoraEventHandler();
|
|
||||||
VideoEncoderConfiguration configuration = VideoEncoderConfiguration(
|
|
||||||
dimensions: VideoDimensions(width: 1920, height: 1080),
|
|
||||||
);
|
|
||||||
await _engine.setVideoEncoderConfiguration(configuration);
|
|
||||||
await _engine.joinChannel(token, widget.channelName!, null, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _addAgoraEventHandler() {
|
|
||||||
_engine.setEventHandler(
|
|
||||||
rtc_engine.RtcEngineEventHandler(
|
|
||||||
error: (code) {
|
|
||||||
setState(() {
|
|
||||||
final info = 'Error: $code';
|
|
||||||
_infoString.add(info);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
joinChannelSuccess: (channel, uid, elapsed) {
|
|
||||||
setState(() {
|
|
||||||
final info = 'Join Channel: $channel, uid:$uid';
|
|
||||||
_infoString.add(info);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
leaveChannel: (stats) {
|
|
||||||
setState(() {
|
|
||||||
_infoString.add('Leave Channel');
|
|
||||||
_users.clear();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
userJoined: (uid, elapsed) {
|
|
||||||
setState(() {
|
|
||||||
final info = 'User joined: $uid';
|
|
||||||
_infoString.add(info);
|
|
||||||
_users.add(uid);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
userOffline: (uid, elapsed) {
|
|
||||||
setState(() {
|
|
||||||
final info = 'User Offline: $uid';
|
|
||||||
_infoString.add(info);
|
|
||||||
_users.remove(uid);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
firstRemoteVideoFrame: (uid, width, height, elapsed) {
|
|
||||||
setState(() {
|
|
||||||
final info = 'First Remote Video: $uid $width*$height';
|
|
||||||
_infoString.add(info);
|
|
||||||
_users.remove(uid);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Widget _viewRows() {
|
|
||||||
final List<StatefulWidget> list = [];
|
|
||||||
if (widget.role == ClientRole.Broadcaster) {
|
|
||||||
list.add(const rtc_local_view.SurfaceView());
|
|
||||||
}
|
|
||||||
for (var uid in _users) {
|
|
||||||
list.add(rtc_remote_view.SurfaceView(
|
|
||||||
uid: uid,
|
|
||||||
channelId: widget.channelName!,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
final views=list;
|
|
||||||
return Column(
|
|
||||||
children: List.generate(
|
|
||||||
views.length,
|
|
||||||
(index) => Expanded(
|
|
||||||
child: views[index],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Widget _toolbar() {
|
|
||||||
if (widget.role == ClientRole.Audience) return SizedBox();
|
|
||||||
|
|
||||||
return Container(
|
|
||||||
alignment: Alignment.bottomCenter,
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 48),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: <Widget>[
|
|
||||||
RawMaterialButton(
|
|
||||||
onPressed: () {
|
|
||||||
setState(() {
|
|
||||||
muted = !muted;
|
|
||||||
});
|
|
||||||
_engine.muteLocalAudioStream(muted);
|
|
||||||
},
|
|
||||||
child: Icon(
|
|
||||||
muted ? Icons.mic_off : Icons.mic,
|
|
||||||
color: muted ? Colors.white : Colors.blueAccent,
|
|
||||||
size: 20.0,
|
|
||||||
),
|
|
||||||
shape: CircleBorder(),
|
|
||||||
elevation: 2.0,
|
|
||||||
fillColor: muted ? Colors.blueAccent : Colors.white,
|
|
||||||
padding: EdgeInsets.all(12.0),
|
|
||||||
),
|
|
||||||
RawMaterialButton(
|
|
||||||
onPressed: () => Navigator.pop(context),
|
|
||||||
child: Icon(
|
|
||||||
Icons.call_end,
|
|
||||||
color: Colors.white,
|
|
||||||
size: 35.0,
|
|
||||||
),
|
|
||||||
shape: CircleBorder(),
|
|
||||||
elevation: 2.0,
|
|
||||||
fillColor: Colors.redAccent,
|
|
||||||
padding: EdgeInsets.all(15.0),
|
|
||||||
),
|
|
||||||
RawMaterialButton(
|
|
||||||
onPressed: () {
|
|
||||||
_engine.switchCamera();
|
|
||||||
},
|
|
||||||
child: Icon(
|
|
||||||
Icons.switch_camera,
|
|
||||||
color: Colors.blueAccent,
|
|
||||||
size: 20.0,
|
|
||||||
),
|
|
||||||
shape: CircleBorder(),
|
|
||||||
elevation: 2.0,
|
|
||||||
fillColor: Colors.white,
|
|
||||||
padding: EdgeInsets.all(12.0),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Widget _panel()
|
|
||||||
{
|
|
||||||
return Visibility(
|
|
||||||
visible: viewPanel,
|
|
||||||
child: Container(
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 48),
|
|
||||||
alignment: Alignment.bottomCenter,
|
|
||||||
child: FractionallySizedBox(
|
|
||||||
heightFactor: 0.5,
|
|
||||||
child: Container(
|
|
||||||
padding: EdgeInsets.symmetric(vertical: 48),
|
|
||||||
child: ListView.builder(
|
|
||||||
reverse: true,
|
|
||||||
itemCount: _infoString.length,
|
|
||||||
itemBuilder:(BuildContext context,int index)
|
|
||||||
{
|
|
||||||
if(_infoString.isEmpty)
|
|
||||||
{
|
|
||||||
return const Text("null");
|
|
||||||
}
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 3,horizontal: 10),
|
|
||||||
child: Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Flexible(
|
|
||||||
child: Container(
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 2, horizontal: 5),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.white,
|
|
||||||
borderRadius: BorderRadius.circular(5)
|
|
||||||
),
|
|
||||||
child: Text(
|
|
||||||
_infoString[index],
|
|
||||||
style: const TextStyle(color:Colors.blueGrey),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
title: const Text("VideoCall"),
|
|
||||||
centerTitle: true,
|
|
||||||
actions: [
|
|
||||||
IconButton(onPressed:()
|
|
||||||
{
|
|
||||||
setState(() {
|
|
||||||
viewPanel=!viewPanel;
|
|
||||||
});
|
|
||||||
}, icon: const Icon(Icons.ice_skating))
|
|
||||||
],
|
|
||||||
),
|
|
||||||
backgroundColor: Colors.black,
|
|
||||||
body: Center(
|
|
||||||
child: Stack(
|
|
||||||
children: <Widget>[
|
|
||||||
_viewRows(),
|
|
||||||
_panel(),
|
|
||||||
_toolbar(),
|
|
||||||
]
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
import 'package:agora_rtc_engine/rtc_engine.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:async/async.dart';
|
|
||||||
import 'dart:developer';
|
|
||||||
import 'package:permission_handler/permission_handler.dart';
|
|
||||||
import './call.dart';
|
|
||||||
import 'package:flutter/material.dart' hide Size;
|
|
||||||
import 'dart:ui' as ui;
|
|
||||||
|
|
||||||
class IndexPage extends StatefulWidget {
|
|
||||||
const IndexPage({Key? key}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<IndexPage> createState() => _IndexPageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _IndexPageState extends State<IndexPage> {
|
|
||||||
|
|
||||||
TextEditingController _channelController = TextEditingController(text: 'call');
|
|
||||||
|
|
||||||
bool _validateError=false;
|
|
||||||
ClientRole? _role= ClientRole.Broadcaster;
|
|
||||||
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_channelController.dispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
title: const Text("VideoCall"),
|
|
||||||
centerTitle: true,
|
|
||||||
),
|
|
||||||
body: SingleChildScrollView(
|
|
||||||
child: Container(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
|
||||||
child: Column(
|
|
||||||
children:<Widget> [
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
TextField(
|
|
||||||
controller: _channelController,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
errorText: _validateError ? 'Chanel Name is Mondatory' : null,
|
|
||||||
border: UnderlineInputBorder(borderSide: BorderSide(width: 1),),
|
|
||||||
hintText: 'channel name',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
RadioListTile(
|
|
||||||
title: const Text('Broadcaster'),
|
|
||||||
onChanged: (ClientRole? value)
|
|
||||||
{
|
|
||||||
setState(() {
|
|
||||||
_role=value;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
value: ClientRole.Broadcaster,
|
|
||||||
groupValue: _role,
|
|
||||||
),
|
|
||||||
RadioListTile(
|
|
||||||
title: const Text('Audience'),
|
|
||||||
onChanged: (ClientRole? value)
|
|
||||||
{
|
|
||||||
setState(() {
|
|
||||||
_role=value;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
value: ClientRole.Audience,
|
|
||||||
groupValue: _role,
|
|
||||||
),
|
|
||||||
ElevatedButton(
|
|
||||||
onPressed: onjoin,
|
|
||||||
child: const Text('Join'),
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
minimumSize: const ui.Size(double.infinity, 40),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> onjoin() async {
|
|
||||||
setState(() {
|
|
||||||
_channelController.text.isEmpty
|
|
||||||
? _validateError=true:
|
|
||||||
_validateError=false; // This line doesn't actually update any state
|
|
||||||
});
|
|
||||||
|
|
||||||
if(_channelController.text.isNotEmpty)
|
|
||||||
{
|
|
||||||
await _handlecameraAndMic(Permission.camera);
|
|
||||||
await _handlecameraAndMic(Permission.microphone);
|
|
||||||
await Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (__) => CallPage(
|
|
||||||
channelName: _channelController.text, // Passes the text from _channelController as channelName
|
|
||||||
role: _role, // Passes the value of _role as role
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future <void> _handlecameraAndMic(Permission permission) async
|
|
||||||
{
|
|
||||||
final status=await permission.request();
|
|
||||||
log(status.toString());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,509 +0,0 @@
|
|||||||
import 'dart:convert';
|
|
||||||
import 'dart:ffi';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:healthcare_pharmacy/models/pharmacy_accounts_model.dart';
|
|
||||||
import 'package:healthcare_pharmacy/settings.dart';
|
|
||||||
|
|
||||||
|
|
||||||
class PharmacyAccounts extends StatefulWidget {
|
|
||||||
const PharmacyAccounts({Key? key}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<PharmacyAccounts> createState() => _PharmacyAccountsState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _PharmacyAccountsState extends State<PharmacyAccounts> {
|
|
||||||
List<PharmacyAccountsModel> accountsList = [];
|
|
||||||
String acceptedCount = '';
|
|
||||||
String pendingRejectedCount = '';
|
|
||||||
String deliveredCount = '';
|
|
||||||
String deliveredTotalPrice = '';
|
|
||||||
String deliveredTotalAmountPaid = '';
|
|
||||||
String deliveredTotalAmountDue = '';
|
|
||||||
|
|
||||||
bool isLoading = false;
|
|
||||||
bool isSereverIssue = false;
|
|
||||||
|
|
||||||
Future<void> readJson() async {
|
|
||||||
isLoading = true;
|
|
||||||
|
|
||||||
try {
|
|
||||||
var pharmaResponse = await AppSettings.getPharmacyAccounts();
|
|
||||||
print("pharmaResponse"+pharmaResponse);
|
|
||||||
setState(() {
|
|
||||||
accountsList =
|
|
||||||
((jsonDecode(pharmaResponse)['data']) as List).map((dynamic model) {
|
|
||||||
return PharmacyAccountsModel.fromJson(model);
|
|
||||||
}).toList();
|
|
||||||
acceptedCount = jsonDecode(pharmaResponse)['acceptedCount'].toString();
|
|
||||||
pendingRejectedCount =
|
|
||||||
jsonDecode(pharmaResponse)['pendingRejectedCount'].toString();
|
|
||||||
deliveredCount =
|
|
||||||
jsonDecode(pharmaResponse)['deliveredCount'].toString();
|
|
||||||
deliveredTotalPrice =
|
|
||||||
jsonDecode(pharmaResponse)['deliveredTotalPrice'].toString();
|
|
||||||
deliveredTotalAmountPaid =
|
|
||||||
jsonDecode(pharmaResponse)['deliveredTotalAmountPaid'].toString();
|
|
||||||
deliveredTotalAmountDue =
|
|
||||||
jsonDecode(pharmaResponse)['deliveredTotalAmountDue'].toString();
|
|
||||||
|
|
||||||
isLoading = false;
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
setState(() {
|
|
||||||
isLoading = false;
|
|
||||||
isSereverIssue = true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
// TODO: implement initState
|
|
||||||
readJson();
|
|
||||||
super.initState();
|
|
||||||
}
|
|
||||||
|
|
||||||
modelBottomSheet(var obj) {
|
|
||||||
showModalBottomSheet<void>(
|
|
||||||
backgroundColor: Colors.white,
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.only(topLeft: Radius.circular(15.0), topRight: Radius.circular(15.0)),
|
|
||||||
),
|
|
||||||
isScrollControlled: true,
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return SizedBox(
|
|
||||||
height: MediaQuery.of(context).size.height * .300,
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.all(10),
|
|
||||||
child: Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
children: <Widget>[
|
|
||||||
Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text('Supplier Name', style: labelTextStyle()),
|
|
||||||
Text('Delivery Agent', style: labelTextStyle()),
|
|
||||||
Text('Tanker Name', style: labelTextStyle()),
|
|
||||||
Text('Capacity Of Tanker', style: labelTextStyle()),
|
|
||||||
Text('Booking Id', style: labelTextStyle()),
|
|
||||||
Text('Date Of Order', style: labelTextStyle()),
|
|
||||||
Text('Type Of Water', style: labelTextStyle()),
|
|
||||||
Text('Start Time', style: labelTextStyle()),
|
|
||||||
Text('Stop Time', style: labelTextStyle()),
|
|
||||||
Text('Initial Water Level', style: labelTextStyle()),
|
|
||||||
Text('Final Water Level', style: labelTextStyle()),
|
|
||||||
Text('Delivered Water', style: labelTextStyle()),
|
|
||||||
Text('Actual Price', style: labelTextStyle()),
|
|
||||||
Text('Amount Paid', style: labelTextStyle()),
|
|
||||||
Text('Amount Due', style: labelTextStyle()),
|
|
||||||
Text('Payment Mode', style: labelTextStyle()),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
SizedBox(width:5),
|
|
||||||
Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(':', style: labelTextStyle()),
|
|
||||||
Text(':', style: labelTextStyle()),
|
|
||||||
Text(':', style: labelTextStyle()),
|
|
||||||
Text(':', style: labelTextStyle()),
|
|
||||||
Text(':', style: labelTextStyle()),
|
|
||||||
Text(':', style: labelTextStyle()),
|
|
||||||
Text(':', style: labelTextStyle()),
|
|
||||||
Text(':', style: labelTextStyle()),
|
|
||||||
Text(':', style: labelTextStyle()),
|
|
||||||
Text(':', style: labelTextStyle()),
|
|
||||||
Text(':', style: labelTextStyle()),
|
|
||||||
Text(':', style: labelTextStyle()),
|
|
||||||
Text(':', style: labelTextStyle()),
|
|
||||||
Text(':', style: labelTextStyle()),
|
|
||||||
Text(':', style: labelTextStyle()),
|
|
||||||
Text(':', style: labelTextStyle()),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
SizedBox(width:5),
|
|
||||||
Expanded(
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(obj.supplierName, style: valuesTextStyle()),
|
|
||||||
Text(obj.delivery_agent, style: valuesTextStyle()),
|
|
||||||
Text(obj.tanker_name, style: valuesTextStyle()),
|
|
||||||
Text(obj.capacity + ' Ltrs', style: valuesTextStyle()),
|
|
||||||
Text(obj.bookingid,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
)),
|
|
||||||
Text(obj.dateOfOrder,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
)),
|
|
||||||
Text(obj.typeofwater,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
)),
|
|
||||||
Text(obj.start_time,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
)),
|
|
||||||
Text(obj.stop_time,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
)),
|
|
||||||
Text(obj.initial_water_level + ' Ltrs',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
)),
|
|
||||||
Text(obj.final_water_level + ' Ltrs',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
)),
|
|
||||||
Text(obj.quantityDelivered + ' Ltrs',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
)),
|
|
||||||
Text(obj.price,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
)),
|
|
||||||
Text(obj.amount_paid,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
)),
|
|
||||||
Text(obj.amount_due,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
)),
|
|
||||||
Text(obj.payment_mode,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
Expanded(child: Column(
|
|
||||||
children: [
|
|
||||||
Icon(Icons.payment_outlined, color: obj.payment_color, size: 40,),
|
|
||||||
Text(obj.displayText,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
)),
|
|
||||||
],
|
|
||||||
))
|
|
||||||
],
|
|
||||||
),
|
|
||||||
));
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _accounsList() {
|
|
||||||
if (accountsList.length != 0) {
|
|
||||||
return Column(crossAxisAlignment: CrossAxisAlignment.center, children: [
|
|
||||||
Container(
|
|
||||||
width: double.infinity,
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.fromLTRB(8, 8, 8, 0),
|
|
||||||
child: Card(
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.all(8),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'acceptedCount',
|
|
||||||
style: labelTextStyle(),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'pendingRejectedCount',
|
|
||||||
style: labelTextStyle(),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'deliveredCount',
|
|
||||||
style: labelTextStyle(),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'deliveredTotalPrice',
|
|
||||||
style: labelTextStyle(),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'deliveredTotalAmountPaid',
|
|
||||||
style: labelTextStyle(),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'deliveredTotalAmountDue',
|
|
||||||
style: labelTextStyle(),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
': ',
|
|
||||||
style: labelTextStyle(),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
': ',
|
|
||||||
style: labelTextStyle(),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
': ',
|
|
||||||
style: labelTextStyle(),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
': ',
|
|
||||||
style: labelTextStyle(),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
': ',
|
|
||||||
style: labelTextStyle(),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
': ',
|
|
||||||
style: labelTextStyle(),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
acceptedCount,
|
|
||||||
style: valuesTextStyle(),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
deliveredCount,
|
|
||||||
style: valuesTextStyle(),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
pendingRejectedCount,
|
|
||||||
style: valuesTextStyle(),
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Icon(
|
|
||||||
Icons.currency_rupee,
|
|
||||||
color: Colors.black,
|
|
||||||
size: 10,
|
|
||||||
),
|
|
||||||
SizedBox(width: 5),
|
|
||||||
Text(
|
|
||||||
AppSettings.formNum(deliveredTotalPrice),
|
|
||||||
style: valuesTextStyle(),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Icon(
|
|
||||||
Icons.currency_rupee,
|
|
||||||
color: Colors.black,
|
|
||||||
size: 10,
|
|
||||||
),
|
|
||||||
SizedBox(width: 5),
|
|
||||||
Text(
|
|
||||||
AppSettings.formNum(
|
|
||||||
deliveredTotalAmountPaid),
|
|
||||||
style: valuesTextStyle(),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Icon(
|
|
||||||
Icons.currency_rupee,
|
|
||||||
color: Colors.black,
|
|
||||||
size: 10,
|
|
||||||
),
|
|
||||||
SizedBox(width: 5),
|
|
||||||
Text(deliveredTotalAmountDue=='null'?
|
|
||||||
'':AppSettings.formNum(
|
|
||||||
deliveredTotalAmountDue),
|
|
||||||
style: valuesTextStyle(),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
))),
|
|
||||||
)),
|
|
||||||
Expanded(
|
|
||||||
child: ListView.builder(
|
|
||||||
padding: EdgeInsets.all(8),
|
|
||||||
itemCount: accountsList.length,
|
|
||||||
itemBuilder: (BuildContext context, int index) {
|
|
||||||
return Card(
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.all(8),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
// width: MediaQuery.of(context).size.width * .75,
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text('pharmacyId', style: labelTextStyle()),
|
|
||||||
Text('bookingId',
|
|
||||||
style: labelTextStyle()),
|
|
||||||
Text('biddingAmount',
|
|
||||||
style: labelTextStyle()),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
SizedBox(width: 5),
|
|
||||||
Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(':', style: labelTextStyle()),
|
|
||||||
Text(':', style: labelTextStyle()),
|
|
||||||
Text(':', style: labelTextStyle()),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
SizedBox(width: 5),
|
|
||||||
Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
accountsList[index]
|
|
||||||
.pharmacyId
|
|
||||||
.toUpperCase(),
|
|
||||||
style: valuesTextStyle()),
|
|
||||||
Text(
|
|
||||||
accountsList[index]
|
|
||||||
.bookingId
|
|
||||||
.toUpperCase(),
|
|
||||||
style: valuesTextStyle()),
|
|
||||||
Text(
|
|
||||||
accountsList[index]
|
|
||||||
.biddingAmount
|
|
||||||
.toUpperCase()+' Ltrs',
|
|
||||||
style: valuesTextStyle()),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Visibility(
|
|
||||||
visible: accountsList[index].orderStatus=='delivered' ,
|
|
||||||
child: Expanded(
|
|
||||||
child: TextButton(
|
|
||||||
onPressed: () {
|
|
||||||
//modelBottomSheet(accountsList[index]);
|
|
||||||
},
|
|
||||||
child: const Text(
|
|
||||||
'More Details',
|
|
||||||
style: TextStyle(
|
|
||||||
color: primaryColor,
|
|
||||||
fontSize: 15,
|
|
||||||
decoration: TextDecoration.underline,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
})),
|
|
||||||
]);
|
|
||||||
} else {
|
|
||||||
return Center(
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.fromLTRB(0, 40, 0, 0),
|
|
||||||
child: isSereverIssue
|
|
||||||
? Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Image(
|
|
||||||
image: AssetImage('images/updatepin.png.png'),
|
|
||||||
// height: MediaQuery.of(context).size.height * .10,
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: 20,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'There is an issue at server please try after some time',
|
|
||||||
style: serverIssueTextStyle(),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Image(
|
|
||||||
image: AssetImage('images/no_data.png'),
|
|
||||||
// height: MediaQuery.of(context).size.height * .10,
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: 20,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'No Data',
|
|
||||||
style: serverIssueTextStyle(),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppSettings.appBar('Accounts'),
|
|
||||||
body: isLoading
|
|
||||||
? Center(
|
|
||||||
child: CircularProgressIndicator(
|
|
||||||
color: primaryColor,
|
|
||||||
strokeWidth: 5.0,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: _accounsList(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,124 +0,0 @@
|
|||||||
import 'dart:convert';
|
|
||||||
import 'dart:io';
|
|
||||||
import 'dart:ui';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/rendering.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:flutter_share/flutter_share.dart';
|
|
||||||
import 'package:healthcare_pharmacy/settings.dart';
|
|
||||||
import 'package:share/share.dart';
|
|
||||||
import 'dart:typed_data';
|
|
||||||
import 'package:path_provider/path_provider.dart';
|
|
||||||
import 'package:http/http.dart' as http;
|
|
||||||
import 'package:qr_flutter/qr_flutter.dart';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class DisplayQrCode extends StatefulWidget {
|
|
||||||
const DisplayQrCode({Key? key}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<DisplayQrCode> createState() => _DisplayQrCodeState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _DisplayQrCodeState extends State<DisplayQrCode> {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Future<void> share(var qr) async {
|
|
||||||
await FlutterShare.share(
|
|
||||||
title: 'Example share',
|
|
||||||
text: 'Example share text',
|
|
||||||
linkUrl: qr,
|
|
||||||
chooserTitle: 'Example Chooser Title');
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> shareQRCodeImage1(qrData) async {
|
|
||||||
|
|
||||||
final tempDir = await getTemporaryDirectory();
|
|
||||||
final file = File('${tempDir.path}/qr_code.png');
|
|
||||||
await file.writeAsBytes(Uint8List.fromList(base64.decode(qrData)));
|
|
||||||
|
|
||||||
// Share the image using the share package
|
|
||||||
Share.shareFiles([file.path], text: 'Check out this QR code');
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
String imagePath = '';
|
|
||||||
|
|
||||||
Future<void> downloadQRImage() async {
|
|
||||||
final response = await http.get(Uri.parse(AppSettings.qrCode));
|
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
|
||||||
final directory = await getApplicationDocumentsDirectory();
|
|
||||||
final filePath = '${directory.path}/qr_image.png';
|
|
||||||
|
|
||||||
final File file = File(filePath);
|
|
||||||
await file.writeAsBytes(response.bodyBytes);
|
|
||||||
|
|
||||||
setState(() {
|
|
||||||
imagePath = filePath;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppSettings.appBar('Qr Code'),
|
|
||||||
body: Container(
|
|
||||||
child: Padding(padding: EdgeInsets.all(10),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Center(
|
|
||||||
child: Container(
|
|
||||||
padding: EdgeInsets.fromLTRB(0, 20, 0, 0),
|
|
||||||
width: MediaQuery.of(context).size.width * .60, // Set the desired width
|
|
||||||
height: MediaQuery.of(context).size.height * .35, // Set the desired height
|
|
||||||
child:
|
|
||||||
Image.memory(Uint8List.fromList(base64.decode(AppSettings.qrCode),),
|
|
||||||
fit: BoxFit.fill),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height:MediaQuery.of(context).size.height * .05,
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
IconButton(
|
|
||||||
onPressed: () {
|
|
||||||
//share(AppSettings.qrCode);
|
|
||||||
shareQRCodeImage1(AppSettings.qrCode);
|
|
||||||
},
|
|
||||||
icon: Icon(
|
|
||||||
Icons.share,
|
|
||||||
color: primaryColor,
|
|
||||||
size: 40,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
/*IconButton(
|
|
||||||
onPressed: () {
|
|
||||||
downloadQRImage();
|
|
||||||
},
|
|
||||||
icon: Icon(
|
|
||||||
Icons.download,
|
|
||||||
color: primaryColor,
|
|
||||||
size: 40,
|
|
||||||
),
|
|
||||||
),*/
|
|
||||||
],
|
|
||||||
)
|
|
||||||
/*Container(
|
|
||||||
padding: EdgeInsets.fromLTRB(0, 20, 0, 0),
|
|
||||||
child: Center(child: Image.memory(Uint8List.fromList(base64.decode(AppSettings.qrCode),),),),
|
|
||||||
)*/
|
|
||||||
|
|
||||||
],
|
|
||||||
),),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,966 +0,0 @@
|
|||||||
import 'dart:convert';
|
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:healthcare_pharmacy/ZoomedImageView.dart';
|
|
||||||
import 'package:healthcare_pharmacy/models/offersview_model.dart';
|
|
||||||
import 'package:healthcare_pharmacy/offerstabdata.dart';
|
|
||||||
import 'package:healthcare_pharmacy/settings.dart';
|
|
||||||
import 'package:intl/intl.dart';
|
|
||||||
import 'package:image_picker/image_picker.dart';
|
|
||||||
import 'package:photo_view/photo_view.dart';
|
|
||||||
|
|
||||||
import 'package:flutter_cupertino_datetime_picker/flutter_cupertino_datetime_picker.dart';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Viewpager extends StatefulWidget {
|
|
||||||
List<GetOffersDetailsModel> userdata;
|
|
||||||
int position;
|
|
||||||
Viewpager(this.userdata, this.position);
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<Viewpager> createState() => _ViewpagerState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ViewpagerState extends State<Viewpager> {
|
|
||||||
late PageController _pageController;
|
|
||||||
int _currentPageIndex = 0;
|
|
||||||
String selectedOption = 'Option 1';
|
|
||||||
bool isActiveDataLoading=false;
|
|
||||||
bool isSereverIssue = false;
|
|
||||||
bool isSereverIssueConnected = false;
|
|
||||||
bool isSereverIssuePending = false;
|
|
||||||
|
|
||||||
bool switchValue = false;
|
|
||||||
TextEditingController updateOfferNameController = TextEditingController();
|
|
||||||
TextEditingController updateOfferCodeController = TextEditingController();
|
|
||||||
TextEditingController updateOfferDescriptionController = TextEditingController();
|
|
||||||
TextEditingController updateDiscountController = TextEditingController();
|
|
||||||
TextEditingController updateOfferStartDateController = TextEditingController();
|
|
||||||
TextEditingController updateOfferEndDateController = TextEditingController();
|
|
||||||
String dropdownTypeOfCategory = 'A {1 - 500}';
|
|
||||||
var typeOfCategoryItems = [
|
|
||||||
'A {1 - 500}',
|
|
||||||
'B {501 - 1000}',
|
|
||||||
'C {1001 - 2000}',
|
|
||||||
'D {Above 2000}',
|
|
||||||
'S {Special offer}',
|
|
||||||
];
|
|
||||||
|
|
||||||
List updateCategoryTypes = [];
|
|
||||||
|
|
||||||
var startdate;
|
|
||||||
var enddate;
|
|
||||||
String updateofferUrl='';
|
|
||||||
|
|
||||||
final ImagePicker _picker = ImagePicker();
|
|
||||||
List<GetOffersDetailsModel> activeOffersList = [];
|
|
||||||
|
|
||||||
|
|
||||||
Future pickImageFromGallery(var offerCode) async {
|
|
||||||
|
|
||||||
try {
|
|
||||||
final image = await _picker.pickImage(source: ImageSource.gallery);
|
|
||||||
if (image == null) return '';
|
|
||||||
|
|
||||||
final imageTemp = File(image.path);
|
|
||||||
AppSettings.preLoaderDialog(context);
|
|
||||||
var res = await AppSettings.offerupdateuploadImageHTTPNew(image, offerCode);
|
|
||||||
print(jsonDecode(res));
|
|
||||||
|
|
||||||
setState(() {
|
|
||||||
updateofferUrl = jsonDecode(res)['picture'][0]['url'];
|
|
||||||
print("update url: $updateofferUrl");
|
|
||||||
});
|
|
||||||
|
|
||||||
Navigator.of(context, rootNavigator: true).pop();
|
|
||||||
if(res.contains("error")){
|
|
||||||
return 'some thing went wrong please try again';
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
return jsonDecode(res)['picture'][0]['url'];
|
|
||||||
}
|
|
||||||
|
|
||||||
} on PlatformException catch (e) {
|
|
||||||
print('Failed to pick image: $e');
|
|
||||||
return 'some thing went wrong please try again';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<String> takeImageFromCamera(String offerCode) async {
|
|
||||||
try {
|
|
||||||
final image = await _picker.pickImage(source: ImageSource.camera);
|
|
||||||
if (image == null) return '';
|
|
||||||
|
|
||||||
final imageTemp = File(image.path);
|
|
||||||
AppSettings.preLoaderDialog(context);
|
|
||||||
var res = await AppSettings.offerupdateuploadImageHTTPNew(image, offerCode);
|
|
||||||
print(jsonDecode(res));
|
|
||||||
|
|
||||||
setState(() {
|
|
||||||
updateofferUrl = jsonDecode(res)['picture'][0]['url'];
|
|
||||||
print("update url: $updateofferUrl");
|
|
||||||
});
|
|
||||||
|
|
||||||
Navigator.of(context, rootNavigator: true).pop();
|
|
||||||
if(res.contains("error")){
|
|
||||||
return 'some thing went wrong please try again';
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
return jsonDecode(res)['picture'][0]['url'];
|
|
||||||
}
|
|
||||||
|
|
||||||
} on PlatformException catch (e) {
|
|
||||||
print('Failed to pick image: $e');
|
|
||||||
return 'some thing went wrong please try again';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
showUpdateOfferDialog(GetOffersDetailsModel object, int index) async {
|
|
||||||
updateOfferNameController.text = object.offer_name!;
|
|
||||||
updateOfferCodeController.text = object.offer_code!;
|
|
||||||
updateOfferDescriptionController.text = object.description!;
|
|
||||||
updateOfferStartDateController.text=object.starting_date!;
|
|
||||||
updateOfferEndDateController.text=object.ending_date!;
|
|
||||||
updateofferUrl=object.picture[0].url;
|
|
||||||
return showDialog(
|
|
||||||
context: context,
|
|
||||||
barrierDismissible: false,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return StatefulBuilder(
|
|
||||||
builder: (BuildContext context, StateSetter setState) {
|
|
||||||
var data=activeOffersList[index];
|
|
||||||
print("result$updateofferUrl");
|
|
||||||
return AlertDialog(
|
|
||||||
title: const Text('Update Offer'),
|
|
||||||
content: SingleChildScrollView(
|
|
||||||
child: ListBody(
|
|
||||||
children: <Widget>[
|
|
||||||
// ImageView
|
|
||||||
InkWell(
|
|
||||||
onTap: () {
|
|
||||||
showModalBottomSheet<void>(
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return SizedBox(
|
|
||||||
height: 200,
|
|
||||||
child: Center(
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: <Widget>[
|
|
||||||
GestureDetector(
|
|
||||||
child: Icon(
|
|
||||||
Icons.camera_alt_outlined,
|
|
||||||
size: 100,
|
|
||||||
color: primaryColor,
|
|
||||||
),
|
|
||||||
onTap: () async {
|
|
||||||
await takeImageFromCamera(object.offer_code!).then((value) {
|
|
||||||
print("datatatttta$value");
|
|
||||||
setState(() {
|
|
||||||
updateofferUrl = value;
|
|
||||||
// print(updateofferUrl);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
width:
|
|
||||||
MediaQuery.of(context).size.width * .20,
|
|
||||||
),
|
|
||||||
GestureDetector(
|
|
||||||
child: Icon(
|
|
||||||
Icons.photo,
|
|
||||||
size: 100,
|
|
||||||
color: primaryColor,
|
|
||||||
),
|
|
||||||
onTap: () async {
|
|
||||||
await pickImageFromGallery(object.offer_code).then((value) {
|
|
||||||
print("datatatttta$value");
|
|
||||||
setState(() {
|
|
||||||
updateofferUrl = value;
|
|
||||||
// print(updateofferUrl);
|
|
||||||
});
|
|
||||||
});;
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
child: Container(
|
|
||||||
width: MediaQuery.of(context).size.width,
|
|
||||||
height: 150,
|
|
||||||
child: updateofferUrl.isEmpty
|
|
||||||
? Image.network(
|
|
||||||
"https://assets.aboutamazon.com/dims4/default/1db03c8/2147483647/strip/false/crop/2000x1125+0+0/resize/1200x675!/quality/90/?url=https%3A%2F%2Famazon-blogs-brightspot.s3.amazonaws.com%2Fa3%2Fc2%2F5c0b93db41d789be1bec015003bd%2Fpharmacy-hero-2000x1125.jpg",
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
)
|
|
||||||
: Image.network(
|
|
||||||
updateofferUrl,
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 20,
|
|
||||||
),
|
|
||||||
|
|
||||||
// Offer Name
|
|
||||||
Container(
|
|
||||||
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
|
|
||||||
child: TextFormField(
|
|
||||||
cursorColor: greyColor,
|
|
||||||
controller: updateOfferNameController,
|
|
||||||
textCapitalization: TextCapitalization.words,
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
prefixIcon: Icon(
|
|
||||||
Icons.person,
|
|
||||||
color: primaryColor,
|
|
||||||
),
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: greyColor)),
|
|
||||||
focusedBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: greyColor),
|
|
||||||
),
|
|
||||||
enabledBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: greyColor),
|
|
||||||
),
|
|
||||||
labelText: 'Offer name',
|
|
||||||
labelStyle: TextStyle(
|
|
||||||
color: greyColor, //<-- SEE HERE
|
|
||||||
),
|
|
||||||
),
|
|
||||||
), //tanker name
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 20,
|
|
||||||
),
|
|
||||||
|
|
||||||
Container(
|
|
||||||
//padding: const EdgeInsets.fromLTRB(10, 10, 10, 0),
|
|
||||||
child: TextFormField(
|
|
||||||
cursorColor: greyColor,
|
|
||||||
controller: updateOfferCodeController,
|
|
||||||
textCapitalization: TextCapitalization.words,
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
prefixIcon: Icon(
|
|
||||||
Icons.numbers,
|
|
||||||
color: primaryColor,
|
|
||||||
),
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: greyColor)),
|
|
||||||
focusedBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: greyColor),
|
|
||||||
),
|
|
||||||
enabledBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: greyColor),
|
|
||||||
),
|
|
||||||
labelText: 'Offer Code',
|
|
||||||
labelStyle: TextStyle(
|
|
||||||
color: greyColor, //<-- SEE HERE
|
|
||||||
),
|
|
||||||
),
|
|
||||||
), //tanker name
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 20,
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
//padding: const EdgeInsets.fromLTRB(10, 10, 10, 0),
|
|
||||||
child: TextFormField(
|
|
||||||
cursorColor: greyColor,
|
|
||||||
controller: updateOfferDescriptionController,
|
|
||||||
textCapitalization: TextCapitalization.words,
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
prefixIcon: Icon(
|
|
||||||
Icons.description,
|
|
||||||
color: primaryColor,
|
|
||||||
),
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: greyColor)),
|
|
||||||
focusedBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: greyColor),
|
|
||||||
),
|
|
||||||
enabledBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: greyColor),
|
|
||||||
),
|
|
||||||
labelText: 'Offer Description',
|
|
||||||
labelStyle: TextStyle(
|
|
||||||
color: greyColor, //<-- SEE HERE
|
|
||||||
),
|
|
||||||
),
|
|
||||||
), //tanker name
|
|
||||||
),
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const SizedBox(
|
|
||||||
height: 30,
|
|
||||||
),
|
|
||||||
|
|
||||||
|
|
||||||
Container(
|
|
||||||
child: DropdownButtonFormField(
|
|
||||||
// Initial Value
|
|
||||||
value: dropdownTypeOfCategory,
|
|
||||||
isExpanded: true,
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
prefixIcon: Icon(
|
|
||||||
Icons.type_specimen,
|
|
||||||
color: primaryColor,
|
|
||||||
),
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: greyColor)),
|
|
||||||
focusedBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: greyColor),
|
|
||||||
),
|
|
||||||
enabledBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: greyColor),
|
|
||||||
),
|
|
||||||
labelText: 'Type of category',
|
|
||||||
labelStyle: TextStyle(
|
|
||||||
color: greyColor, //<-- SEE HERE
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
hint: Text('Select Type of category'),
|
|
||||||
// Down Arrow Icon
|
|
||||||
icon: const Icon(Icons.keyboard_arrow_down),
|
|
||||||
|
|
||||||
// Array list of items
|
|
||||||
items: typeOfCategoryItems.map((String items) {
|
|
||||||
return DropdownMenuItem(
|
|
||||||
value: items,
|
|
||||||
child: Text(items),
|
|
||||||
);
|
|
||||||
}).toList(),
|
|
||||||
// After selecting the desired option,it will
|
|
||||||
// change button value to selected value
|
|
||||||
onChanged: (String? newValue) {
|
|
||||||
setState(() {
|
|
||||||
dropdownTypeOfCategory = newValue!;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const SizedBox(
|
|
||||||
height: 20,
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
child: TextFormField(
|
|
||||||
readOnly: true,
|
|
||||||
cursorColor: greyColor,
|
|
||||||
controller: updateOfferStartDateController,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
labelText: 'Select Start Date',
|
|
||||||
prefixIcon: IconButton(
|
|
||||||
icon: Icon(
|
|
||||||
Icons.date_range,
|
|
||||||
color: primaryColor,
|
|
||||||
),
|
|
||||||
onPressed: () async {
|
|
||||||
DatePicker.showDatePicker(
|
|
||||||
context,
|
|
||||||
dateFormat: 'dd MMMM yyyy',
|
|
||||||
initialDateTime: DateTime.now(),
|
|
||||||
minDateTime:DateTime.now(),
|
|
||||||
maxDateTime: DateTime.now().add(Duration(days: 365)),
|
|
||||||
onMonthChangeStartWithFirstDate: true,
|
|
||||||
pickerMode: DateTimePickerMode.datetime,
|
|
||||||
pickerTheme: DateTimePickerTheme(
|
|
||||||
// backgroundColor: Colors.white,
|
|
||||||
cancelTextStyle: labelTextStyle(),
|
|
||||||
confirmTextStyle: labelTextStyle(),
|
|
||||||
// showTitle: true,
|
|
||||||
//title: Text('Pick date and time'),
|
|
||||||
itemTextStyle: valuesTextStyle(),
|
|
||||||
),
|
|
||||||
onConfirm: (dateTime, List<int> index)async {
|
|
||||||
DateTime selectdate = dateTime;
|
|
||||||
setState(() {
|
|
||||||
startdate = DateFormat('dd-MMM-yyyy').format(selectdate);
|
|
||||||
});
|
|
||||||
|
|
||||||
if(startdate!=''){
|
|
||||||
setState(() {
|
|
||||||
updateOfferStartDateController.text=startdate.toString();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
AppSettings.longFailedToast('Select start date');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
|
|
||||||
labelStyle: const TextStyle(
|
|
||||||
color: greyColor, //<-- SEE HERE
|
|
||||||
),
|
|
||||||
border: const OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: primaryColor)),
|
|
||||||
focusedBorder: const OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: primaryColor),
|
|
||||||
),
|
|
||||||
enabledBorder: const OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: primaryColor),
|
|
||||||
),
|
|
||||||
|
|
||||||
),
|
|
||||||
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
const SizedBox(
|
|
||||||
height: 20,
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
child: TextFormField(
|
|
||||||
readOnly: true,
|
|
||||||
cursorColor: greyColor,
|
|
||||||
controller: updateOfferEndDateController,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
labelText: 'Select end Date',
|
|
||||||
prefixIcon: IconButton(
|
|
||||||
icon: Icon(
|
|
||||||
Icons.date_range,
|
|
||||||
color: primaryColor,
|
|
||||||
),
|
|
||||||
onPressed: () async {
|
|
||||||
DatePicker.showDatePicker(
|
|
||||||
context,
|
|
||||||
dateFormat: 'dd MMMM yyyy',
|
|
||||||
initialDateTime: DateTime.now(),
|
|
||||||
minDateTime:DateTime.now(),
|
|
||||||
maxDateTime: DateTime.now().add(Duration(days: 365)),
|
|
||||||
onMonthChangeStartWithFirstDate: true,
|
|
||||||
pickerMode: DateTimePickerMode.datetime,
|
|
||||||
pickerTheme: DateTimePickerTheme(
|
|
||||||
// backgroundColor: Colors.white,
|
|
||||||
cancelTextStyle: labelTextStyle(),
|
|
||||||
confirmTextStyle: labelTextStyle(),
|
|
||||||
// showTitle: true,
|
|
||||||
//title: Text('Pick date and time'),
|
|
||||||
itemTextStyle: valuesTextStyle(),
|
|
||||||
),
|
|
||||||
onConfirm: (dateTime, List<int> index)async {
|
|
||||||
DateTime selectdate = dateTime;
|
|
||||||
setState(() {
|
|
||||||
enddate = DateFormat('dd-MMM-yyyy').format(selectdate);
|
|
||||||
});
|
|
||||||
|
|
||||||
if(enddate!=''){
|
|
||||||
setState(() {
|
|
||||||
updateOfferEndDateController.text=enddate.toString();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
AppSettings.longFailedToast('Select end date');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
|
|
||||||
labelStyle: const TextStyle(
|
|
||||||
color: greyColor, //<-- SEE HERE
|
|
||||||
),
|
|
||||||
border: const OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: primaryColor)),
|
|
||||||
focusedBorder: const OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: primaryColor),
|
|
||||||
),
|
|
||||||
enabledBorder: const OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: primaryColor),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
),
|
|
||||||
),//address description
|
|
||||||
|
|
||||||
const SizedBox(
|
|
||||||
height: 30,
|
|
||||||
),
|
|
||||||
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
actions: <Widget>[
|
|
||||||
TextButton(
|
|
||||||
child: Text('Cancel', style: textButtonStyle()),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
child: Text('Update', style: textButtonStyle()),
|
|
||||||
onPressed: () async {
|
|
||||||
if (updateOfferNameController.text != '' ) {
|
|
||||||
AppSettings.preLoaderDialog(context);
|
|
||||||
|
|
||||||
Map<String, dynamic> payload = {
|
|
||||||
"offer_name": updateOfferNameController.text.toString(),
|
|
||||||
"offer_code": updateOfferCodeController.text.toString(),
|
|
||||||
"description":updateOfferDescriptionController.text.toString(),
|
|
||||||
"category":dropdownTypeOfCategory.toString(),
|
|
||||||
"starting_date":updateOfferStartDateController.text.toString(),
|
|
||||||
"ending_date": updateOfferEndDateController.text.toString(),
|
|
||||||
"picture": [
|
|
||||||
{
|
|
||||||
"url":updateofferUrl
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"offer_status": "active",
|
|
||||||
};
|
|
||||||
|
|
||||||
bool offerStatus = await AppSettings.updateOffers(object.offer_code, payload);
|
|
||||||
try {
|
|
||||||
if (offerStatus) {
|
|
||||||
Navigator.of(context, rootNavigator: true).pop();
|
|
||||||
AppSettings.longSuccessToast(
|
|
||||||
"Offer Updated Successfully");
|
|
||||||
updateOfferNameController.text = '';
|
|
||||||
updateOfferCodeController.text = '';
|
|
||||||
updateOfferDescriptionController.text = '';
|
|
||||||
updateOfferStartDateController.text = '';
|
|
||||||
updateOfferEndDateController.text = '';
|
|
||||||
await getActiveOffersViewData();
|
|
||||||
await Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => const OffersData()),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
Navigator.of(context, rootNavigator: true).pop();
|
|
||||||
AppSettings.longFailedToast(
|
|
||||||
"Offer upadtion failed");
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
}
|
|
||||||
} catch (exception) {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
print(exception);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
AppSettings.longFailedToast("enter details");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> getActiveOffersViewData() async {
|
|
||||||
isActiveDataLoading = true;
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
|
||||||
var data = await AppSettings.getOffers();
|
|
||||||
setState(() {
|
|
||||||
List<dynamic> responseData = jsonDecode(data)['data'];
|
|
||||||
activeOffersList = responseData
|
|
||||||
.map((jsonObject) => GetOffersDetailsModel.fromJson(jsonObject))
|
|
||||||
.toList();
|
|
||||||
isActiveDataLoading = false;
|
|
||||||
});
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
setState(() {
|
|
||||||
isActiveDataLoading = false;
|
|
||||||
isSereverIssueConnected = true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
getActiveOffersViewData();
|
|
||||||
_pageController = PageController(initialPage: widget.position);
|
|
||||||
}
|
|
||||||
void removeItem(int index) {
|
|
||||||
setState(() {
|
|
||||||
widget.userdata.removeAt(index);
|
|
||||||
if (_currentPageIndex > 0) {
|
|
||||||
_currentPageIndex--;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
_pageController = PageController(initialPage: _currentPageIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
title: Text('Offers Details'),
|
|
||||||
backgroundColor: primaryColor,
|
|
||||||
leading: IconButton(
|
|
||||||
icon: Icon(Icons.arrow_back),
|
|
||||||
onPressed: () async {
|
|
||||||
await Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => const OffersData()),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
body: PageView.builder(
|
|
||||||
controller: _pageController,
|
|
||||||
itemCount: widget.userdata.length,
|
|
||||||
onPageChanged: (int index) {
|
|
||||||
setState(() {
|
|
||||||
_currentPageIndex = index;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
itemBuilder: (BuildContext context, int index) {
|
|
||||||
var object = widget.userdata[index];
|
|
||||||
return Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Stack(
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
width: MediaQuery.of(context).size.width, // Set width to screen width
|
|
||||||
height: 350, // Set your desired height
|
|
||||||
child: GestureDetector(
|
|
||||||
onTap: () {
|
|
||||||
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => ZoomedImageView(
|
|
||||||
imageUrl: widget.userdata[index].picture.isEmpty
|
|
||||||
? "https://assets.aboutamazon.com/dims4/default/1db03c8/2147483647/strip/false/crop/2000x1125+0+0/resize/1200x675!/quality/90/?url=https%3A%2F%2Famazon-blogs-brightspot.s3.amazonaws.com%2Fa3%2Fc2%2F5c0b93db41d789be1bec015003bd%2Fpharmacy-hero-2000x1125.jpg"
|
|
||||||
: widget.userdata[index].picture[0].url,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
},
|
|
||||||
child: widget.userdata[index].picture.isEmpty
|
|
||||||
? Image.network(
|
|
||||||
"https://assets.aboutamazon.com/dims4/default/1db03c8/2147483647/strip/false/crop/2000x1125+0+0/resize/1200x675!/quality/90/?url=https%3A%2F%2Famazon-blogs-brightspot.s3.amazonaws.com%2Fa3%2Fc2%2F5c0b93db41d789be1bec015003bd%2Fpharmacy-hero-2000x1125.jpg",
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
)
|
|
||||||
: Image.network(
|
|
||||||
widget.userdata[index].picture[0].url,
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
|
|
||||||
Positioned(
|
|
||||||
left: 5.0, // Adjust this value as needed
|
|
||||||
top: MediaQuery.of(context).size.height / 5 - 16.0, // Center vertically
|
|
||||||
child: IconButton(
|
|
||||||
icon: Icon(Icons.arrow_back_ios, color: Colors.white),
|
|
||||||
onPressed: () {
|
|
||||||
if (_pageController.page! > 0) {
|
|
||||||
_pageController.previousPage(
|
|
||||||
duration: Duration(milliseconds: 300),
|
|
||||||
curve: Curves.easeInOut,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Positioned(
|
|
||||||
right: 5.0, // Adjust this value as needed
|
|
||||||
top: MediaQuery.of(context).size.height / 5 - 16.0, // Center vertically
|
|
||||||
child: IconButton(
|
|
||||||
icon: Icon(Icons.arrow_forward_ios, color: Colors.white),
|
|
||||||
onPressed: () {
|
|
||||||
if (_pageController.page! < widget.userdata.length - 1) {
|
|
||||||
_pageController.nextPage(
|
|
||||||
duration: Duration(milliseconds: 300),
|
|
||||||
curve: Curves.easeInOut,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 10,
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.only(left: 16.0), // Add left padding to all RichText widgets
|
|
||||||
child: RichText(
|
|
||||||
text: TextSpan(
|
|
||||||
style: DefaultTextStyle.of(context).style,
|
|
||||||
children: <TextSpan>[
|
|
||||||
TextSpan(
|
|
||||||
text: 'Name: ',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.black,
|
|
||||||
fontSize: 20,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TextSpan(
|
|
||||||
text: widget.userdata[index].offer_name,
|
|
||||||
style: TextStyle(
|
|
||||||
color: primaryColor,
|
|
||||||
fontSize: 20,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 5,
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.only(left: 16.0), // Add left padding to all RichText widgets
|
|
||||||
child: RichText(
|
|
||||||
text: TextSpan(
|
|
||||||
style: DefaultTextStyle.of(context).style,
|
|
||||||
children: <TextSpan>[
|
|
||||||
TextSpan(
|
|
||||||
text: 'Code: ',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.black,
|
|
||||||
fontSize: 20,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TextSpan(
|
|
||||||
text: widget.userdata[index].offer_code,
|
|
||||||
style: TextStyle(
|
|
||||||
color: primaryColor,
|
|
||||||
fontSize: 20,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 5,
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.only(left: 16.0), // Add left padding to all RichText widgets
|
|
||||||
child: RichText(
|
|
||||||
text: TextSpan(
|
|
||||||
style: DefaultTextStyle.of(context).style,
|
|
||||||
children: <TextSpan>[
|
|
||||||
TextSpan(
|
|
||||||
text: 'Description: ',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.black,
|
|
||||||
fontSize: 20,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TextSpan(
|
|
||||||
text: widget.userdata[index].description ?? "",
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 20,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: primaryColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 5,
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.only(left: 16.0), // Add left padding to all RichText widgets
|
|
||||||
child: RichText(
|
|
||||||
text: TextSpan(
|
|
||||||
style: DefaultTextStyle.of(context).style,
|
|
||||||
children: <TextSpan>[
|
|
||||||
TextSpan(
|
|
||||||
text: 'Category: ',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.black,
|
|
||||||
fontSize: 20,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TextSpan(
|
|
||||||
text: widget.userdata[index].category ?? "",
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 20,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: primaryColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 5,
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.only(left: 16.0), // Add left padding to all RichText widgets
|
|
||||||
child: RichText(
|
|
||||||
text: TextSpan(
|
|
||||||
style: DefaultTextStyle.of(context).style,
|
|
||||||
children: <TextSpan>[
|
|
||||||
TextSpan(
|
|
||||||
text: 'StartDate: ',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 20,
|
|
||||||
color: Colors.black,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TextSpan(
|
|
||||||
text: widget.userdata[index].starting_date ?? "",
|
|
||||||
style: TextStyle(
|
|
||||||
color: primaryColor,
|
|
||||||
fontSize: 20,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 5,
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.only(left: 16.0), // Add left padding to all RichText widgets
|
|
||||||
child: RichText(
|
|
||||||
text: TextSpan(
|
|
||||||
style: DefaultTextStyle.of(context).style,
|
|
||||||
children: <TextSpan>[
|
|
||||||
TextSpan(
|
|
||||||
text: 'EndDate: ',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 20,
|
|
||||||
color: Colors.black,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TextSpan(
|
|
||||||
text: widget.userdata[index].ending_date ?? "",
|
|
||||||
style: TextStyle(
|
|
||||||
color: primaryColor,
|
|
||||||
fontSize: 20,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
const SizedBox(
|
|
||||||
height: 15,
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.only(left: 16.0), // Add left padding
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Switch(
|
|
||||||
value: false,
|
|
||||||
onChanged: (value) {
|
|
||||||
setState(() {
|
|
||||||
switchValue = value;
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return AlertDialog(
|
|
||||||
title: const Text('Are you sure you want to in_active this Offer?',
|
|
||||||
style: TextStyle(
|
|
||||||
color: primaryColor,
|
|
||||||
fontSize: 20,
|
|
||||||
)),
|
|
||||||
actionsAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: () async {
|
|
||||||
// Perform the action
|
|
||||||
print("offercode${widget.userdata[index].offer_code}");
|
|
||||||
bool deleteOfferStatus =
|
|
||||||
await AppSettings.deleteOffers(
|
|
||||||
widget.userdata[index].offer_code);
|
|
||||||
if(deleteOfferStatus){
|
|
||||||
widget.userdata.remove(widget.userdata[index]);
|
|
||||||
switchValue=false;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
switchValue=false;
|
|
||||||
}
|
|
||||||
await Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => const OffersData()),
|
|
||||||
); // Close the dialog
|
|
||||||
},
|
|
||||||
child: const Text('Yes',
|
|
||||||
style: TextStyle(
|
|
||||||
color: primaryColor,
|
|
||||||
fontSize: 20,
|
|
||||||
)),
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop(false);
|
|
||||||
},
|
|
||||||
child: const Text('No',
|
|
||||||
style: TextStyle(
|
|
||||||
color: primaryColor,
|
|
||||||
fontSize: 20,
|
|
||||||
)),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
width: 100,
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
icon: Icon(Icons.edit),
|
|
||||||
onPressed: () {
|
|
||||||
showUpdateOfferDialog(object, index);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:healthcare_pharmacy/settings.dart';
|
|
||||||
import 'package:photo_view/photo_view.dart';
|
|
||||||
|
|
||||||
class ZoomableImage extends StatelessWidget {
|
|
||||||
final String imageUrl;
|
|
||||||
|
|
||||||
ZoomableImage(this.imageUrl);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
backgroundColor: primaryColor, // Set the background color
|
|
||||||
title: Text('Preview Image'), // Set the title text
|
|
||||||
actions: [
|
|
||||||
IconButton(
|
|
||||||
icon: Icon(Icons.close),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
body: Center(
|
|
||||||
child: imageUrl.isNotEmpty
|
|
||||||
? PhotoView(
|
|
||||||
imageProvider: NetworkImage(imageUrl),
|
|
||||||
minScale: PhotoViewComputedScale.contained,
|
|
||||||
maxScale: PhotoViewComputedScale.contained * 3.0,
|
|
||||||
)
|
|
||||||
: Image.asset(
|
|
||||||
'images/mobilebg.png', // Path to your default image
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in new issue