forked from Poonamsh06/afgan12
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from RaghvindYadav/user-integration
User integration
- Loading branch information
Showing
20 changed files
with
998 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" | ||
#include "Generated.xcconfig" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" | ||
#include "Generated.xcconfig" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Uncomment this line to define a global platform for your project | ||
# platform :ios, '11.0' | ||
|
||
# CocoaPods analytics sends network stats synchronously affecting flutter build latency. | ||
ENV['COCOAPODS_DISABLE_STATS'] = 'true' | ||
|
||
project 'Runner', { | ||
'Debug' => :debug, | ||
'Profile' => :release, | ||
'Release' => :release, | ||
} | ||
|
||
def flutter_root | ||
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) | ||
unless File.exist?(generated_xcode_build_settings_path) | ||
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" | ||
end | ||
|
||
File.foreach(generated_xcode_build_settings_path) do |line| | ||
matches = line.match(/FLUTTER_ROOT\=(.*)/) | ||
return matches[1].strip if matches | ||
end | ||
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" | ||
end | ||
|
||
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) | ||
|
||
flutter_ios_podfile_setup | ||
|
||
target 'Runner' do | ||
use_frameworks! | ||
use_modular_headers! | ||
|
||
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) | ||
target 'RunnerTests' do | ||
inherit! :search_paths | ||
end | ||
end | ||
|
||
post_install do |installer| | ||
installer.pods_project.targets.each do |target| | ||
flutter_additional_ios_build_settings(target) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:afghan_net/services/app_remote_routes.dart'; | ||
import 'package:get/get.dart'; | ||
import 'package:get_storage/get_storage.dart'; | ||
|
||
import '../modal/user.dart'; | ||
import '../services/api_provider.dart'; | ||
|
||
class UserController extends GetxController{ | ||
final apiProvider = ApiProvider(); | ||
GetStorage sr = GetStorage(); | ||
late User user; | ||
late List<User> listUsers; | ||
|
||
userLogin({required String email, required String pass}) async{ | ||
final data = await apiProvider.post("login",{"email":email,"password":pass}); | ||
user = User.fromJson(data); | ||
GetStorage sr = GetStorage(); | ||
await sr.write('token',user.token); | ||
await sr.write("user", user); | ||
print(sr.read('user')); | ||
} | ||
|
||
Future<String> createUser(Map<String,dynamic> userData)async{ | ||
final data = await apiProvider.post('createUser', userData); | ||
|
||
print("message ${data['message']}"); | ||
return data['message']; | ||
} | ||
|
||
User getUser(){ | ||
if(sr.read('user') is User){ | ||
user = sr.read('user'); | ||
}else{ | ||
user = User.fromJson(sr.read('user')); | ||
} | ||
return user; | ||
} | ||
|
||
deleteUser({required String userId}) async{ | ||
final data = await apiProvider.delete("user", {"id":userId}); | ||
print(data); | ||
|
||
} | ||
|
||
Future<List<User>> getAllUsers()async{ | ||
// listUsers.clear(); | ||
final data = await apiProvider.get(AppRemoteRoutes.allUser); | ||
final List listData = json.decode(jsonEncode(data['data'])); | ||
listUsers = | ||
listData.map((x)=>User.fromJson(x)).toList(); | ||
return listUsers; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
class User { | ||
String id; | ||
String firstName; | ||
String lastName; | ||
String email; | ||
int mobile; | ||
String district; | ||
String province; | ||
String currency; | ||
bool isVerified; | ||
String userType; | ||
bool isDeleted; | ||
DateTime createdAt; | ||
DateTime updatedAt; | ||
int v; | ||
String? token; | ||
|
||
User({ | ||
required this.id, | ||
required this.firstName, | ||
required this.lastName, | ||
required this.email, | ||
required this.mobile, | ||
required this.district, | ||
required this.province, | ||
required this.currency, | ||
required this.isVerified, | ||
required this.userType, | ||
required this.isDeleted, | ||
required this.createdAt, | ||
required this.updatedAt, | ||
required this.v, | ||
this.token, | ||
}); | ||
|
||
factory User.fromJson(Map<String, dynamic> json) => User( | ||
id: json["_id"], | ||
firstName: json["firstName"], | ||
lastName: json["lastName"], | ||
email: json["email"], | ||
mobile: json["mobile"], | ||
district: json["district"], | ||
province: json["province"], | ||
currency: json["currency"], | ||
isVerified: json["isVerified"], | ||
userType: json["userType"], | ||
isDeleted: json["isDeleted"], | ||
createdAt: DateTime.parse(json["createdAt"]), | ||
updatedAt: DateTime.parse(json["updatedAt"]), | ||
v: json["__v"], | ||
token: json["token"], | ||
); | ||
|
||
Map<String, dynamic> toJson() => { | ||
"_id": id, | ||
"firstName": firstName, | ||
"lastName": lastName, | ||
"email": email, | ||
"mobile": mobile, | ||
"district": district, | ||
"province": province, | ||
"currency": currency, | ||
"isVerified": isVerified, | ||
"userType": userType, | ||
"isDeleted": isDeleted, | ||
"createdAt": createdAt.toIso8601String(), | ||
"updatedAt": updatedAt.toIso8601String(), | ||
"__v": v, | ||
"token": token, | ||
}; | ||
} |
Oops, something went wrong.