Profile UI & Product manual api integrate
This commit is contained in:
parent
91912fcc95
commit
b4bf13214a
@ -36,8 +36,6 @@ class ProductProvider extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getProducts() async {
|
Future<void> getProducts() async {
|
||||||
// setLoading(true);
|
|
||||||
// try {
|
|
||||||
Response response = await _apiClient.get(ApiUrls.getProducts);
|
Response response = await _apiClient.get(ApiUrls.getProducts);
|
||||||
debugPrint('Response: $response');
|
debugPrint('Response: $response');
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
@ -49,10 +47,6 @@ class ProductProvider extends ChangeNotifier {
|
|||||||
.toList();
|
.toList();
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
// } catch (e) {
|
|
||||||
// setLoading(false);
|
|
||||||
// debugPrint("Error: $e");
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> submitProducts(
|
Future<void> submitProducts(
|
||||||
|
45
lib/provider/userprofile_provider.dart
Normal file
45
lib/provider/userprofile_provider.dart
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import 'package:cheminova/models/profile_response.dart';
|
||||||
|
import 'package:cheminova/services/api_client.dart';
|
||||||
|
import 'package:cheminova/services/api_urls.dart';
|
||||||
|
import 'package:cheminova/services/secure__storage_service.dart';
|
||||||
|
import 'package:dio/dio.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import '../screens/login_screen.dart';
|
||||||
|
|
||||||
|
class UserprofileProvider extends ChangeNotifier {
|
||||||
|
final _apiClient = ApiClient();
|
||||||
|
ProfileResponse? profileResponse;
|
||||||
|
bool _isLoading = false;
|
||||||
|
|
||||||
|
bool get isLoading => _isLoading;
|
||||||
|
|
||||||
|
void setLoading(bool loading) {
|
||||||
|
_isLoading = loading;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> getProfile() async {
|
||||||
|
setLoading(true);
|
||||||
|
try {
|
||||||
|
Response response = await _apiClient.get(ApiUrls.profileUrl);
|
||||||
|
setLoading(false);
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
profileResponse = ProfileResponse.fromJson(response.data);
|
||||||
|
} else {}
|
||||||
|
} catch (e) {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> logOut(BuildContext context) async {
|
||||||
|
Response response = await _apiClient.get(ApiUrls.logOutUrl);
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(content: Text(response.data['message'].toString())));
|
||||||
|
SecureStorageService().clear();
|
||||||
|
Navigator.pushReplacement(
|
||||||
|
context, MaterialPageRoute(builder: (context) => const LoginPage()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -178,7 +178,7 @@ class _AddProductsScreenState extends State<AddProductsScreen> {
|
|||||||
product.inventory != null)) {
|
product.inventory != null)) {
|
||||||
value.submitProducts(
|
value.submitProducts(
|
||||||
distributorType: widget.distributorType,
|
distributorType: widget.distributorType,
|
||||||
pdRdId: widget.pdRdId, inventoryId: widget.inventoryId!
|
pdRdId: widget.pdRdId, inventoryId: widget.inventoryId
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
@ -63,22 +63,35 @@ class _UpdateInventoryTaskScreenState extends State<UpdateInventoryTaskScreen> {
|
|||||||
|
|
||||||
Widget _buildTaskList() {
|
Widget _buildTaskList() {
|
||||||
return Consumer<DailyTaskProvider>(
|
return Consumer<DailyTaskProvider>(
|
||||||
builder: (context, value, child) =>
|
builder: (context, value, child) {
|
||||||
value.isLoading
|
if (value.isLoading) {
|
||||||
? const Center(child: CircularProgressIndicator())
|
return const Center(child: CircularProgressIndicator());
|
||||||
: ListView.separated(
|
}
|
||||||
padding: const EdgeInsets.all(16),
|
|
||||||
itemCount: value.newTasksList.length,
|
final inventoryTasks = value.newTasksList
|
||||||
separatorBuilder: (context, index) => const SizedBox(height: 8),
|
.where((task) => task.task?.toLowerCase() == 'update inventory data')
|
||||||
itemBuilder: (context, index) {
|
.toList();
|
||||||
final task = value.newTasksList[index];
|
|
||||||
if (task.task?.toLowerCase() == 'update inventory data') {
|
if (inventoryTasks.isEmpty) {
|
||||||
return _buildTaskCard(task);
|
return const Center(
|
||||||
} else {
|
child: Text(
|
||||||
return const SizedBox.shrink();
|
'NO TASK',
|
||||||
}
|
style: TextStyle(
|
||||||
},
|
fontSize: 18,
|
||||||
),
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Colors.black87,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ListView.separated(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
itemCount: inventoryTasks.length,
|
||||||
|
separatorBuilder: (context, index) => const SizedBox(height: 8),
|
||||||
|
itemBuilder: (context, index) => _buildTaskCard(inventoryTasks[index]),
|
||||||
|
);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +132,6 @@ class _UpdateInventoryTaskScreenState extends State<UpdateInventoryTaskScreen> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
trailing: const Icon(Icons.arrow_forward_ios, color: Colors.black87),
|
trailing: const Icon(Icons.arrow_forward_ios, color: Colors.black87),
|
||||||
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -203,8 +203,8 @@ class _DailyTasksScreenState extends State<DailyTasksScreen> {
|
|||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => AddProductsScreen(
|
builder: (context) => AddProductsScreen(
|
||||||
distributorType: tasksList.addedFor!,
|
distributorType: tasksList.addedFor!,
|
||||||
tradeName: tasksList.tradeName ?? '',
|
tradeName: tasksList.tradeName?? '',
|
||||||
pdRdId: tasksList.sId!, inventoryId:tasksList.sId!)));
|
pdRdId: tasksList.addedForId!, inventoryId:tasksList.sId)));
|
||||||
} else if (tasksList.task == 'Update Sales Data') {
|
} else if (tasksList.task == 'Update Sales Data') {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
@ -215,7 +215,7 @@ class _DailyTasksScreenState extends State<DailyTasksScreen> {
|
|||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => VisitDealersScreen(
|
builder: (context) => VisitDealersScreen(
|
||||||
tradeName: tasksList.tradeName??'',id: tasksList.sId!,
|
tradeName: tasksList.tradeName??'',
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -46,17 +46,6 @@ class RetailerDetailsScreenState extends State<RetailerDetailsScreen> {
|
|||||||
Column(
|
Column(
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(height: 15),
|
const SizedBox(height: 15),
|
||||||
CommonTextFormField(
|
|
||||||
title: 'Trade Name',
|
|
||||||
fillColor: Colors.white,
|
|
||||||
validator: (String? value) {
|
|
||||||
if (value!.isEmpty) {
|
|
||||||
return 'Trade Name cannot be empty';
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
controller: value.tradeNameController),
|
|
||||||
const SizedBox(height: 15),
|
|
||||||
CommonTextFormField(
|
CommonTextFormField(
|
||||||
title: 'Name',
|
title: 'Name',
|
||||||
fillColor: Colors.white,
|
fillColor: Colors.white,
|
||||||
|
@ -27,51 +27,65 @@ class SelectTaskkycScreenState extends State<SelectTaskkycScreen> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ChangeNotifierProvider(
|
return ChangeNotifierProvider(
|
||||||
create: (context) => _selectTaskProvider,
|
create: (context) => _selectTaskProvider,
|
||||||
child: CommonBackground(
|
child: CommonBackground(
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
appBar: CommonAppBar(
|
||||||
|
title: const Text('Select Task'),
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
appBar: CommonAppBar(
|
elevation: 0,
|
||||||
title: const Text('Select Task'),
|
actions: [
|
||||||
backgroundColor: Colors.transparent,
|
IconButton(
|
||||||
elevation: 0,
|
onPressed: () => Navigator.pop(context),
|
||||||
actions: [
|
icon: Image.asset('assets/Back_attendance.png'),
|
||||||
IconButton(
|
padding: const EdgeInsets.only(right: 20),
|
||||||
onPressed: () => Navigator.pop(context),
|
),
|
||||||
icon: Image.asset('assets/Back_attendance.png'),
|
],
|
||||||
padding: const EdgeInsets.only(right: 20),
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
drawer: const CommonDrawer(),
|
|
||||||
body: Consumer<SelectTaskProvider>(
|
|
||||||
builder: (context, value, child) =>
|
|
||||||
value.isLoading
|
|
||||||
? const Center(child: CircularProgressIndicator())
|
|
||||||
: _buildTaskList(),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
));
|
drawer: const CommonDrawer(),
|
||||||
|
body: Consumer<SelectTaskProvider>(
|
||||||
|
builder: (context, value, child) =>
|
||||||
|
value.isLoading
|
||||||
|
? const Center(child: CircularProgressIndicator())
|
||||||
|
: _buildTaskList(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildTaskList() {
|
Widget _buildTaskList() {
|
||||||
return Consumer<SelectTaskProvider>(builder: (context, value, child) {
|
return Consumer<SelectTaskProvider>(
|
||||||
if (value.tasksList.isEmpty) {
|
builder: (context, value, child) {
|
||||||
return const Center(child: Text('No tasks available'));
|
if (value.tasksList.isEmpty) {
|
||||||
}
|
return const Center(
|
||||||
return ListView.builder(
|
child: Text(
|
||||||
itemCount: value.tasksList.length,
|
'NO TASK',
|
||||||
itemBuilder: (context, index) => _buildTaskCard(value.tasksList[index]),
|
style: TextStyle(
|
||||||
);
|
fontSize: 18,
|
||||||
});
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Colors.black87,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return ListView.builder(
|
||||||
|
itemCount: value.tasksList.length,
|
||||||
|
itemBuilder: (context, index) => _buildTaskCard(value.tasksList[index]),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildTaskCard(Tasks task) {
|
Widget _buildTaskCard(Tasks task) {
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () => Navigator.push(
|
onTap: () => Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) =>
|
builder: (context) => CollectKycScreen(id: task.taskId ?? ''),
|
||||||
CollectKycScreen(id: task.taskId ?? ''))),
|
),
|
||||||
|
),
|
||||||
child: Card(
|
child: Card(
|
||||||
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
@ -90,10 +104,7 @@ class SelectTaskkycScreenState extends State<SelectTaskkycScreen> {
|
|||||||
fontFamily: 'Anek',
|
fontFamily: 'Anek',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
trailing:
|
trailing: const Icon(Icons.arrow_forward_ios, color: Colors.black87),
|
||||||
const Icon(Icons.arrow_forward_ios, color: Colors.black87),
|
|
||||||
|
|
||||||
|
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
@ -103,10 +114,9 @@ class SelectTaskkycScreenState extends State<SelectTaskkycScreen> {
|
|||||||
Text('Note: ${task.note}'),
|
Text('Note: ${task.note}'),
|
||||||
if (task.taskDueDate != null)
|
if (task.taskDueDate != null)
|
||||||
Text(
|
Text(
|
||||||
'Date: ${task.taskDueDate == null ? '' : DateFormat(
|
'Date: ${task.taskDueDate == null ? '' : DateFormat('dd/MM/yyyy').format(DateTime.parse(task.taskDueDate ?? ''))}',
|
||||||
'dd/MM/yyyy').format(
|
),
|
||||||
DateTime.parse(task.taskDueDate ?? ''))}'),
|
Text('Priority: ${task.taskPriority}'),
|
||||||
Text('Priority: ${task.taskPriority}')
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -87,116 +87,113 @@ class VisitDealersScreenState extends State<VisitDealersScreen> {
|
|||||||
elevation: 0,
|
elevation: 0,
|
||||||
),
|
),
|
||||||
drawer: const CommonDrawer(),
|
drawer: const CommonDrawer(),
|
||||||
body: Padding(
|
body: SingleChildScrollView(
|
||||||
padding: const EdgeInsets.all(16.0),
|
physics: const BouncingScrollPhysics(),
|
||||||
child: SingleChildScrollView(
|
child: Column(
|
||||||
physics: const BouncingScrollPhysics(),
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
child: Column(
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
children: <Widget>[
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
const SizedBox(height: 16),
|
||||||
children: <Widget>[
|
Container(
|
||||||
const SizedBox(height: 16),
|
padding:
|
||||||
Container(
|
const EdgeInsets.all(20.0).copyWith(top: 30, bottom: 30),
|
||||||
padding:
|
margin: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||||
const EdgeInsets.all(20.0).copyWith(top: 30, bottom: 30),
|
decoration: BoxDecoration(
|
||||||
// margin: const EdgeInsets.symmetric(horizontal: 30.0),
|
border: Border.all(color: Colors.white),
|
||||||
decoration: BoxDecoration(
|
color: const Color(0xffB4D1E5).withOpacity(0.9),
|
||||||
border: Border.all(color: Colors.white),
|
borderRadius: BorderRadius.circular(26.0)),
|
||||||
color: const Color(0xffB4D1E5).withOpacity(0.9),
|
child: Column(
|
||||||
borderRadius: BorderRadius.circular(26.0)),
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
child: Column(
|
children: <Widget>[
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
CommonTextFormField(
|
||||||
children: <Widget>[
|
readOnly: true,
|
||||||
CommonTextFormField(
|
title: 'Select Retailer',
|
||||||
|
fillColor: Colors.white,
|
||||||
|
controller: retailerController),
|
||||||
|
const SizedBox(height: 15),
|
||||||
|
CommonTextFormField(
|
||||||
|
title: 'Visit date',
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
title: 'Select Retailer',
|
fillColor: Colors.white,
|
||||||
fillColor: Colors.white,
|
controller: dateController),
|
||||||
controller: retailerController),
|
const SizedBox(height: 15),
|
||||||
const SizedBox(height: 15),
|
CommonTextFormField(
|
||||||
CommonTextFormField(
|
title: 'Time',
|
||||||
title: 'Visit date',
|
readOnly: true,
|
||||||
readOnly: true,
|
fillColor: Colors.white,
|
||||||
fillColor: Colors.white,
|
controller: timeController),
|
||||||
controller: dateController),
|
const SizedBox(height: 15),
|
||||||
const SizedBox(height: 15),
|
DropdownButtonFormField<String>(
|
||||||
CommonTextFormField(
|
decoration: const InputDecoration(
|
||||||
title: 'Time',
|
labelText: 'Purpose of visit',
|
||||||
readOnly: true,
|
fillColor: Colors.white,
|
||||||
fillColor: Colors.white,
|
filled: true,
|
||||||
controller: timeController),
|
),
|
||||||
const SizedBox(height: 15),
|
value: selectedPurpose,
|
||||||
DropdownButtonFormField<String>(
|
items: purposeOptions.map((String value) {
|
||||||
decoration: const InputDecoration(
|
return DropdownMenuItem<String>(
|
||||||
labelText: 'Purpose of visit',
|
value: value,
|
||||||
fillColor: Colors.white,
|
child: Text(value),
|
||||||
filled: true,
|
);
|
||||||
|
}).toList(),
|
||||||
|
onChanged: (String? newValue) {
|
||||||
|
setState(() {
|
||||||
|
selectedPurpose = newValue!;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 15),
|
||||||
|
CommonTextFormField(
|
||||||
|
title: 'Meeting Summary:',
|
||||||
|
fillColor: Colors.white,
|
||||||
|
maxLines: 4,
|
||||||
|
controller: meetingSummaryController),
|
||||||
|
const SizedBox(height: 15),
|
||||||
|
CommonTextFormField(
|
||||||
|
title: 'Follow-up Actions:',
|
||||||
|
fillColor: Colors.white,
|
||||||
|
maxLines: 4,
|
||||||
|
controller: followUpActionsController),
|
||||||
|
const SizedBox(height: 15),
|
||||||
|
CommonTextFormField(
|
||||||
|
title: 'Next visit date:',
|
||||||
|
readOnly: true,
|
||||||
|
fillColor: Colors.white,
|
||||||
|
controller: nextVisitDateController),
|
||||||
|
const SizedBox(height: 15),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: CommonTextFormField(
|
||||||
|
title: 'Attach Documents/Photos',
|
||||||
|
fillColor: Colors.white,
|
||||||
|
controller: notesController),
|
||||||
),
|
),
|
||||||
value: selectedPurpose,
|
IconButton(
|
||||||
items: purposeOptions.map((String value) {
|
icon: const Icon(Icons.camera_alt),
|
||||||
return DropdownMenuItem<String>(
|
onPressed: _pickImage,
|
||||||
value: value,
|
),
|
||||||
child: Text(value),
|
],
|
||||||
);
|
),
|
||||||
}).toList(),
|
const SizedBox(height: 15),
|
||||||
onChanged: (String? newValue) {
|
Consumer<VisitPdRdProvider>(builder: (context, value, child) => Align(
|
||||||
setState(() {
|
alignment: Alignment.center,
|
||||||
selectedPurpose = newValue!;
|
child: CommonElevatedButton(
|
||||||
});
|
borderRadius: 30,
|
||||||
},
|
width: double.infinity,
|
||||||
),
|
height: kToolbarHeight - 10,
|
||||||
const SizedBox(height: 15),
|
text: 'SUBMIT',
|
||||||
CommonTextFormField(
|
backgroundColor: const Color(0xff004791),
|
||||||
title: 'Meeting Summary:',
|
onPressed: () {
|
||||||
fillColor: Colors.white,
|
value.submitVisitPdRd(widget.id ?? '');
|
||||||
maxLines: 4,
|
},
|
||||||
controller: meetingSummaryController),
|
|
||||||
const SizedBox(height: 15),
|
|
||||||
CommonTextFormField(
|
|
||||||
title: 'Follow-up Actions:',
|
|
||||||
fillColor: Colors.white,
|
|
||||||
maxLines: 4,
|
|
||||||
controller: followUpActionsController),
|
|
||||||
const SizedBox(height: 15),
|
|
||||||
CommonTextFormField(
|
|
||||||
title: 'Next visit date:',
|
|
||||||
readOnly: true,
|
|
||||||
fillColor: Colors.white,
|
|
||||||
controller: nextVisitDateController),
|
|
||||||
const SizedBox(height: 15),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: CommonTextFormField(
|
|
||||||
title: 'Attach Documents/Photos',
|
|
||||||
fillColor: Colors.white,
|
|
||||||
controller: notesController),
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.camera_alt),
|
|
||||||
onPressed: _pickImage,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 15),
|
|
||||||
Consumer<VisitPdRdProvider>(builder: (context, value, child) => Align(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
child: CommonElevatedButton(
|
|
||||||
borderRadius: 30,
|
|
||||||
width: double.infinity,
|
|
||||||
height: kToolbarHeight - 10,
|
|
||||||
text: 'SUBMIT',
|
|
||||||
backgroundColor: const Color(0xff004791),
|
|
||||||
onPressed: () {
|
|
||||||
value.submitVisitPdRd(widget.id ?? '');
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user