- Added API for proceed login
- Added guest login api - Handled response error - Created a dummy project for home side bar - Added alamofire logger.
This commit is contained in:
@@ -89,6 +89,7 @@
|
||||
52D774EF2BDFC50D001D87DE /* StringValidations.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52D774EE2BDFC50D001D87DE /* StringValidations.swift */; };
|
||||
52D774F12BDFC53B001D87DE /* StringSubScript.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52D774F02BDFC53B001D87DE /* StringSubScript.swift */; };
|
||||
52FB2D8F2BDF898F0009B0C7 /* TextFieldPadding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52FB2D8E2BDF898F0009B0C7 /* TextFieldPadding.swift */; };
|
||||
52FDDAB52BF34DC300E037C1 /* YesNoAlertVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52FDDAB42BF34DC300E037C1 /* YesNoAlertVC.swift */; };
|
||||
619A5A1BD8BD968ADC83C106 /* Pods_WOKA.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BBA543A4216400A2864E3D3E /* Pods_WOKA.framework */; };
|
||||
9C0A853F2BEE35340093783D /* ForgotPassDM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C0A853E2BEE35340093783D /* ForgotPassDM.swift */; };
|
||||
9C0A85412BEE35670093783D /* ResetPassUserNameVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C0A85402BEE35670093783D /* ResetPassUserNameVM.swift */; };
|
||||
@@ -222,6 +223,7 @@
|
||||
52E7E0F62BDF7DD500C86E10 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/AuthenticationSB.strings; sourceTree = "<group>"; };
|
||||
52E7E0F82BDF7DD900C86E10 /* hi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = hi; path = hi.lproj/AuthenticationSB.strings; sourceTree = "<group>"; };
|
||||
52FB2D8E2BDF898F0009B0C7 /* TextFieldPadding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextFieldPadding.swift; sourceTree = "<group>"; };
|
||||
52FDDAB42BF34DC300E037C1 /* YesNoAlertVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YesNoAlertVC.swift; sourceTree = "<group>"; };
|
||||
9C0A853E2BEE35340093783D /* ForgotPassDM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForgotPassDM.swift; sourceTree = "<group>"; };
|
||||
9C0A85402BEE35670093783D /* ResetPassUserNameVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResetPassUserNameVM.swift; sourceTree = "<group>"; };
|
||||
9C0A85422BEE3EC90093783D /* NewPasswordVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewPasswordVM.swift; sourceTree = "<group>"; };
|
||||
@@ -488,6 +490,7 @@
|
||||
children = (
|
||||
5259542D2BEA393700191286 /* AlertCustomVC.swift */,
|
||||
5259542F2BEA394300191286 /* CustomAlerts.storyboard */,
|
||||
52FDDAB42BF34DC300E037C1 /* YesNoAlertVC.swift */,
|
||||
);
|
||||
path = Alerts;
|
||||
sourceTree = "<group>";
|
||||
@@ -879,6 +882,7 @@
|
||||
5272FCE32BDFDB05000ECB1D /* UserDetailsRegisterVC.swift in Sources */,
|
||||
525954102BE8B72900191286 /* FontCustom.swift in Sources */,
|
||||
5202AAFE2BDF90590043B7BD /* TextFieldImage.swift in Sources */,
|
||||
52FDDAB52BF34DC300E037C1 /* YesNoAlertVC.swift in Sources */,
|
||||
52C6E0232BE3B3E300E22D59 /* SelectAvatarVC.swift in Sources */,
|
||||
5259545C2BEBB80400191286 /* AvatarDM.swift in Sources */,
|
||||
52C8B06C2BDA6E87003B51D0 /* LocalizedString.swift in Sources */,
|
||||
|
||||
@@ -74,6 +74,13 @@
|
||||
ReferencedContainer = "container:WOKA.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
<EnvironmentVariables>
|
||||
<EnvironmentVariable
|
||||
key = "IDEPreferLogStreaming"
|
||||
value = "YES"
|
||||
isEnabled = "YES">
|
||||
</EnvironmentVariable>
|
||||
</EnvironmentVariables>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
|
||||
@@ -6,9 +6,13 @@
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22684"/>
|
||||
<capability name="Named colors" minToolsVersion="9.0"/>
|
||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||
<capability name="System colors in document resources" minToolsVersion="11.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<customFonts key="customFonts">
|
||||
<array key="Exo2-Bold.ttf">
|
||||
<string>Exo2-Bold</string>
|
||||
</array>
|
||||
<array key="Exo2-Regular.ttf">
|
||||
<string>Exo2-Regular</string>
|
||||
</array>
|
||||
@@ -117,13 +121,152 @@
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-877" y="4"/>
|
||||
</scene>
|
||||
<!--Yes No AlertVC-->
|
||||
<scene sceneID="fxT-Y0-vkS">
|
||||
<objects>
|
||||
<viewController storyboardIdentifier="YesNoAlertVC" id="jQp-jI-mVn" customClass="YesNoAlertVC" customModule="WOKA" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<view key="view" contentMode="scaleToFill" id="Ycu-3M-HNP">
|
||||
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<view alpha="0.5" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="AZi-Ac-1Jx">
|
||||
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
</view>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="25" translatesAutoresizingMaskIntoConstraints="NO" id="krK-cg-Oil">
|
||||
<rect key="frame" x="20" y="355.66666666666669" width="353" height="166.00000000000006"/>
|
||||
<subviews>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="2aC-DO-6DC">
|
||||
<rect key="frame" x="10" y="15" width="333" height="41"/>
|
||||
<subviews>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ium-M5-1Q9">
|
||||
<rect key="frame" x="0.0" y="0.0" width="333" height="30"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="WOKA" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="jJ7-vb-Tw5">
|
||||
<rect key="frame" x="0.0" y="0.0" width="333" height="30"/>
|
||||
<fontDescription key="fontDescription" name="Exo2-Bold" family="Exo 2" pointSize="18"/>
|
||||
<color key="textColor" name="TextDarkBlue"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="FQZ-wu-DL8">
|
||||
<rect key="frame" x="303" y="0.0" width="30" height="30"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" secondItem="FQZ-wu-DL8" secondAttribute="height" multiplier="1:1" id="fU5-4r-4IE"/>
|
||||
</constraints>
|
||||
<color key="tintColor" name="TextDarkBlue"/>
|
||||
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
|
||||
<state key="normal" image="xmark.circle" catalog="system"/>
|
||||
<connections>
|
||||
<action selector="closeBtnTapped:" destination="jQp-jI-mVn" eventType="touchUpInside" id="mGW-yf-3Qn"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="bottom" secondItem="jJ7-vb-Tw5" secondAttribute="bottom" id="4zZ-a9-S2g"/>
|
||||
<constraint firstItem="jJ7-vb-Tw5" firstAttribute="leading" secondItem="ium-M5-1Q9" secondAttribute="leading" id="KAU-ar-yOz"/>
|
||||
<constraint firstAttribute="height" constant="30" id="N7Q-OV-uze"/>
|
||||
<constraint firstAttribute="trailing" secondItem="jJ7-vb-Tw5" secondAttribute="trailing" id="PPb-0w-YOa"/>
|
||||
<constraint firstAttribute="trailing" secondItem="FQZ-wu-DL8" secondAttribute="trailing" id="VDy-Zz-DA8"/>
|
||||
<constraint firstItem="FQZ-wu-DL8" firstAttribute="top" secondItem="ium-M5-1Q9" secondAttribute="top" id="d88-SX-mKU"/>
|
||||
<constraint firstItem="jJ7-vb-Tw5" firstAttribute="top" secondItem="ium-M5-1Q9" secondAttribute="top" id="oUD-yA-Iga"/>
|
||||
<constraint firstAttribute="bottom" secondItem="FQZ-wu-DL8" secondAttribute="bottom" id="vt0-hC-Yux"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="6ut-1P-FdB">
|
||||
<rect key="frame" x="0.0" y="40" width="333" height="1"/>
|
||||
<color key="backgroundColor" name="WelcomeBlue"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="1" id="r8A-Sj-Pc4"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</subviews>
|
||||
</stackView>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2hO-Cj-GYn">
|
||||
<rect key="frame" x="10" y="81" width="333" height="0.0"/>
|
||||
<fontDescription key="fontDescription" name="Exo2-Regular" family="Exo 2" pointSize="16"/>
|
||||
<color key="textColor" red="0.035294117649999998" green="0.0" blue="0.36470588240000001" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<stackView opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" distribution="fillEqually" spacing="40" translatesAutoresizingMaskIntoConstraints="NO" id="vHX-v2-EPI">
|
||||
<rect key="frame" x="10" y="106" width="333" height="50"/>
|
||||
<subviews>
|
||||
<button opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Mtd-2O-WKd" customClass="LocalisedElementsButton" customModule="WOKA" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="0.0" width="146.66666666666666" height="50"/>
|
||||
<color key="backgroundColor" name="TextDarkBlue"/>
|
||||
<color key="tintColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<state key="normal" title="Button"/>
|
||||
<buttonConfiguration key="configuration" style="plain" title="No">
|
||||
<fontDescription key="titleFontDescription" name="Exo2-Medium" family="Exo 2" pointSize="18"/>
|
||||
</buttonConfiguration>
|
||||
<connections>
|
||||
<action selector="btnTapped:" destination="jQp-jI-mVn" eventType="touchUpInside" id="sco-zQ-q06"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="FnX-50-KNX" customClass="LocalisedElementsButton" customModule="WOKA" customModuleProvider="target">
|
||||
<rect key="frame" x="186.66666666666663" y="0.0" width="146.33333333333337" height="50"/>
|
||||
<color key="backgroundColor" name="TextDarkBlue"/>
|
||||
<color key="tintColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<state key="normal" title="Button"/>
|
||||
<buttonConfiguration key="configuration" style="plain" title="Yes">
|
||||
<fontDescription key="titleFontDescription" name="Exo2-Medium" family="Exo 2" pointSize="18"/>
|
||||
</buttonConfiguration>
|
||||
<connections>
|
||||
<action selector="btnTapped:" destination="jQp-jI-mVn" eventType="touchUpInside" id="LYt-P9-2aT"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="50" id="XCf-xM-Aoe"/>
|
||||
</constraints>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
|
||||
<integer key="value" value="10"/>
|
||||
</userDefinedRuntimeAttribute>
|
||||
</userDefinedRuntimeAttributes>
|
||||
</stackView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<edgeInsets key="layoutMargins" top="15" left="10" bottom="10" right="10"/>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
|
||||
<integer key="value" value="10"/>
|
||||
</userDefinedRuntimeAttribute>
|
||||
</userDefinedRuntimeAttributes>
|
||||
</stackView>
|
||||
</subviews>
|
||||
<viewLayoutGuide key="safeArea" id="NcU-EP-VRw"/>
|
||||
<constraints>
|
||||
<constraint firstItem="krK-cg-Oil" firstAttribute="centerY" secondItem="NcU-EP-VRw" secondAttribute="centerY" id="9WM-10-JJk"/>
|
||||
<constraint firstItem="AZi-Ac-1Jx" firstAttribute="leading" secondItem="NcU-EP-VRw" secondAttribute="leading" id="Dr1-1h-xjO"/>
|
||||
<constraint firstItem="NcU-EP-VRw" firstAttribute="trailing" secondItem="krK-cg-Oil" secondAttribute="trailing" constant="20" id="YHd-Mf-uJG"/>
|
||||
<constraint firstAttribute="bottom" secondItem="AZi-Ac-1Jx" secondAttribute="bottom" id="cpE-GC-lsq"/>
|
||||
<constraint firstItem="krK-cg-Oil" firstAttribute="leading" secondItem="NcU-EP-VRw" secondAttribute="leading" constant="20" id="oym-Wj-cJn"/>
|
||||
<constraint firstItem="AZi-Ac-1Jx" firstAttribute="trailing" secondItem="NcU-EP-VRw" secondAttribute="trailing" id="woH-87-Rxd"/>
|
||||
<constraint firstItem="AZi-Ac-1Jx" firstAttribute="top" secondItem="Ycu-3M-HNP" secondAttribute="top" id="zdv-Pw-dIo"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<connections>
|
||||
<outlet property="content" destination="2hO-Cj-GYn" id="OjT-jJ-MJq"/>
|
||||
<outlet property="noBtn" destination="Mtd-2O-WKd" id="Ix4-wL-cBy"/>
|
||||
<outlet property="yesBtn" destination="FnX-50-KNX" id="Gwm-fs-pkg"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="LKc-1j-pLd" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-82" y="4"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<resources>
|
||||
<image name="xmark.circle" catalog="system" width="128" height="123"/>
|
||||
<namedColor name="TextDarkBlue">
|
||||
<color red="0.10599999874830246" green="0.050999999046325684" blue="0.60399997234344482" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</namedColor>
|
||||
<namedColor name="WelcomeBlue">
|
||||
<color red="0.32899999618530273" green="0.32400000095367432" blue="0.4779999852180481" alpha="0.33000001311302185" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</namedColor>
|
||||
<systemColor name="systemBackgroundColor">
|
||||
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
</systemColor>
|
||||
</resources>
|
||||
</document>
|
||||
|
||||
73
WOKA/Alerts/YesNoAlertVC.swift
Normal file
73
WOKA/Alerts/YesNoAlertVC.swift
Normal file
@@ -0,0 +1,73 @@
|
||||
//
|
||||
// YesNoAlertVC.swift
|
||||
// WOKA
|
||||
//
|
||||
// Created by MacBook Pro on 14/05/24.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
enum YesNoMode{
|
||||
case yes
|
||||
case no
|
||||
}
|
||||
|
||||
class YesNoAlertVC: UIViewController {
|
||||
|
||||
@IBOutlet weak var yesBtn: UIButton!
|
||||
@IBOutlet weak var noBtn: UIButton!
|
||||
@IBOutlet weak var content: UILabel!
|
||||
|
||||
// Properties
|
||||
var contentLabel = String()
|
||||
var yesBtnText: String?
|
||||
var noBtnText: String?
|
||||
var mainTitleText: String?
|
||||
|
||||
// Completion block to be executed when the alert is dismissed
|
||||
var onDoneBlock: ((YesNoMode) -> Void)?
|
||||
|
||||
// MARK: - View LifeCycle
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
yesBtn.roundCorner()
|
||||
noBtn.roundCorner()
|
||||
self.content.text = contentLabel
|
||||
|
||||
if let yesBtnText{
|
||||
self.yesBtn.setTitle(yesBtnText, for: .normal)
|
||||
}
|
||||
if let noBtnText{
|
||||
self.yesBtn.setTitle(noBtnText, for: .normal)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Button Handler
|
||||
|
||||
@IBAction func closeBtnTapped(_ sender: UIButton) {
|
||||
self.dismiss()
|
||||
}
|
||||
|
||||
@IBAction func btnTapped(_ sender: UIButton) {
|
||||
switch sender{
|
||||
case yesBtn:
|
||||
self.onDoneBlock?(.yes)
|
||||
self.dismiss()
|
||||
case noBtn:
|
||||
self.onDoneBlock?(.no)
|
||||
self.dismiss()
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// Dismiss the alert with fade transition
|
||||
private func dismiss() {
|
||||
let transition = CATransition().fadeTransition()
|
||||
self.view.layer.add(transition, forKey: kCATransition)
|
||||
self.dismiss(animated: true)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,6 +24,9 @@ class LoginVC: UIViewController {
|
||||
super.viewDidLoad()
|
||||
vm.vc = self
|
||||
vm.initView()
|
||||
|
||||
self.userNameTF.text = "tests104"
|
||||
self.passwordTF.text = "123456"
|
||||
}
|
||||
|
||||
@IBAction func loginBtnTapped(_ sender: LocalisedElementsButton) {
|
||||
@@ -47,6 +50,7 @@ class LoginVC: UIViewController {
|
||||
|
||||
vcPush.contentLabel = "Password is too short.".localized(loc: AuthFunc.shareInstance.languageSelected.rawValue)
|
||||
vcPush.mainTitleText = "Error".localized(loc: AuthFunc.shareInstance.languageSelected.rawValue)
|
||||
|
||||
// vcPush.onDoneBlock = { isDone in }
|
||||
vcPush.modalPresentationStyle = .overCurrentContext
|
||||
vcPush.modalTransitionStyle = .crossDissolve
|
||||
@@ -63,6 +67,7 @@ class LoginVC: UIViewController {
|
||||
}
|
||||
|
||||
@IBAction func continueGuestBtnTapped(_ sender: UIButton) {
|
||||
vm.guestLogin()
|
||||
}
|
||||
|
||||
@IBAction func forgotPasswordBtnTapped(_ sender: UIButton) {
|
||||
|
||||
@@ -70,7 +70,94 @@ class LoginVM{
|
||||
"Accept-Language" : AuthFunc.shareInstance.languageSelected == .english ? "English" : "Hindi"]
|
||||
|
||||
Utilities.startProgressHUD()
|
||||
NetworkManager.shareInstance.apiRequest(url: APIEndPoints.Auth.login, method: .post ,parameters: params, headers: header) {(result : Result<BaseResponseModel<UserDataDM?>, NetworkManager.APIError>) in
|
||||
NetworkManager.shareInstance.apiRequest(url: APIEndPoints.Auth.login, method: .post ,parameters: params, headers: header) {(result : Result<BaseResponseModel<UserDataDM>, NetworkManager.APIError>) in
|
||||
switch result{
|
||||
case .success(let data):
|
||||
switch data.success{
|
||||
case 0:
|
||||
Utilities.dismissProgressHUD()
|
||||
self.vc.toast(msg: data.message ?? "Unrecognised error" , time: 2)
|
||||
case 1:
|
||||
Utilities.dismissProgressHUD()
|
||||
guard let dataResult = data.data?.result, let loginStatus = dataResult.alreadyLoggedIn else{return}
|
||||
if loginStatus == true{ // user is already loginned in other device
|
||||
let sb = UIStoryboard(name: K.StoryBoard.customAlerts, bundle: nil)
|
||||
let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.CustomAlerts.yesNoAlertVC) as! YesNoAlertVC
|
||||
vcPush.contentLabel = data.message ?? K.ConstantString.unRecognised
|
||||
vcPush.onDoneBlock = { mode in
|
||||
switch mode{
|
||||
case .yes:
|
||||
//If user clicked to proceed on login. Call the api.
|
||||
self.proceedLogin()
|
||||
case .no:
|
||||
print("no")
|
||||
}
|
||||
}
|
||||
vcPush.modalPresentationStyle = .overCurrentContext
|
||||
vcPush.modalTransitionStyle = .crossDissolve
|
||||
self.vc.present(vcPush, animated: true)
|
||||
}else{ // fresh login
|
||||
/*
|
||||
if user is not logined on other device directly nav him to home
|
||||
*/
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
case .failure(let error):
|
||||
Utilities.dismissProgressHUD()
|
||||
self.vc.toast(msg: error.localizedDescription, time: 2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
After all checks do the api call
|
||||
*/
|
||||
func proceedLogin(){
|
||||
let params: Parameters = [
|
||||
"username": vc.userNameTF.text!,
|
||||
"password": vc.passwordTF.text!
|
||||
]
|
||||
let header : HTTPHeaders = ["device-id" : AuthFunc.shareInstance.getDeviceUUID(),
|
||||
"Accept-Language" : AuthFunc.shareInstance.languageSelected == .english ? "English" : "Hindi"]
|
||||
|
||||
Utilities.startProgressHUD()
|
||||
NetworkManager.shareInstance.apiRequest(url: APIEndPoints.Auth.login_proceed, method: .post ,parameters: params, headers: header) {(result : Result<BaseResponseModel<UserDataDM>, NetworkManager.APIError>) in
|
||||
switch result{
|
||||
case .success(let data):
|
||||
switch data.success{
|
||||
case 0:
|
||||
Utilities.dismissProgressHUD()
|
||||
self.vc.toast(msg: data.message ?? "Unrecognised error" , time: 2)
|
||||
case 1:
|
||||
Utilities.dismissProgressHUD()
|
||||
self.vc.toast(msg: data.message ?? "Unrecognised error" , time: 2)
|
||||
default:
|
||||
break
|
||||
}
|
||||
case .failure(let error):
|
||||
Utilities.dismissProgressHUD()
|
||||
self.vc.toast(msg: error.localizedDescription, time: 2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Guest Login
|
||||
*/
|
||||
func guestLogin(){
|
||||
let params: Parameters = [
|
||||
"user_type": 3, // 1- kid , 2 - guardian , 3 - guest
|
||||
"one_signal_player_id": "Test",
|
||||
"language_id": AuthFunc.shareInstance.languageSelected == .english ? 1 : 2, //1-eng, 2 - hindi
|
||||
"device_type": 1 // 1- android , 2 - iOS
|
||||
]
|
||||
let header : HTTPHeaders = ["device-id" : AuthFunc.shareInstance.getDeviceUUID(),
|
||||
"Accept-Language" : AuthFunc.shareInstance.languageSelected == .english ? "English" : "Hindi"]
|
||||
|
||||
Utilities.startProgressHUD()
|
||||
NetworkManager.shareInstance.apiRequest(url: APIEndPoints.Auth.guest_login, method: .post ,parameters: params, headers: header) {(result : Result<BaseResponseModel<UserDataDM>, NetworkManager.APIError>) in
|
||||
switch result{
|
||||
case .success(let data):
|
||||
switch data.success{
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
import UIKit
|
||||
import Lottie
|
||||
import Alamofire
|
||||
|
||||
class OnBoardVM{
|
||||
|
||||
@@ -105,4 +106,40 @@ class OnBoardVM{
|
||||
func resumeBackGroundAnimationJSON(){
|
||||
animationView?.play()
|
||||
}
|
||||
|
||||
// MARK: - Create Guest
|
||||
/*
|
||||
Guest Login
|
||||
*/
|
||||
func guestLogin(){
|
||||
let params: Parameters = [
|
||||
"user_type": 3, // 1- kid , 2 - guardian , 3 - guest
|
||||
"one_signal_player_id": "Test",
|
||||
"language_id": AuthFunc.shareInstance.languageSelected == .english ? 1 : 2, //1-eng, 2 - hindi
|
||||
"device_type": 1 // 1- android , 2 - iOS
|
||||
]
|
||||
let header : HTTPHeaders = ["device-id" : AuthFunc.shareInstance.getDeviceUUID(),
|
||||
"Accept-Language" : AuthFunc.shareInstance.languageSelected == .english ? "English" : "Hindi"]
|
||||
|
||||
Utilities.startProgressHUD()
|
||||
NetworkManager.shareInstance.apiRequest(url: APIEndPoints.Auth.guest_login, method: .post ,parameters: params, headers: header) {(result : Result<BaseResponseModel<UserDataDM>, NetworkManager.APIError>) in
|
||||
switch result{
|
||||
case .success(let data):
|
||||
switch data.success{
|
||||
case 0:
|
||||
Utilities.dismissProgressHUD()
|
||||
self.vc.toast(msg: data.message ?? "Unrecognised error" , time: 2)
|
||||
case 1:
|
||||
Utilities.dismissProgressHUD()
|
||||
self.vc.toast(msg: data.message ?? "Unrecognised error" , time: 2)
|
||||
default:
|
||||
break
|
||||
}
|
||||
case .failure(let error):
|
||||
Utilities.dismissProgressHUD()
|
||||
self.vc.toast(msg: error.localizedDescription, time: 2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ extension K{
|
||||
|
||||
struct CustomAlerts{
|
||||
static let alertCustomVC = "AlertCustomVC"
|
||||
static let yesNoAlertVC = "YesNoAlertVC"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
|
||||
"Hello" = "नमस्ते";
|
||||
"Yes" = "हाँ";
|
||||
"No" = "नहीं";
|
||||
"Error" = "गलती";
|
||||
"Retry?" = "पुनः प्रयास करें?";
|
||||
"Please wait..." = "कृपया प्रतीक्षा करें";
|
||||
|
||||
@@ -30,6 +30,15 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
LottieConfiguration.shared.renderingEngine = .mainThread
|
||||
return true
|
||||
}
|
||||
|
||||
// func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
|
||||
// print("URL-> " ,url)
|
||||
//// if let referralCode = getReferralCode(from: url) {
|
||||
//// // Do something with the referral code
|
||||
//// print("Referral code: \(referralCode)")
|
||||
//// }
|
||||
// return true
|
||||
// }
|
||||
|
||||
// MARK: UISceneSession Lifecycle
|
||||
|
||||
|
||||
@@ -25,8 +25,15 @@ struct APIEndPoints {
|
||||
|
||||
struct Auth {
|
||||
static let check_exist_email = makeURL(path: "check_exist_email")
|
||||
|
||||
/*
|
||||
Login User
|
||||
*/
|
||||
static let login = makeURL(path: "login")
|
||||
static let login_proceed = makeURL(path: "login_proceed")
|
||||
static let guest_login = makeURL(path: "guest_login")
|
||||
|
||||
|
||||
static let user_email_verification = makeURL(path: "user_email_verification")
|
||||
static let validate_otp = makeURL(path: "validate_otp")
|
||||
static let interest_topic_listing = makeURL(path: "interest_topic_listing")
|
||||
|
||||
@@ -10,7 +10,8 @@ import Alamofire
|
||||
class NetworkManager{
|
||||
|
||||
static let shareInstance = NetworkManager()
|
||||
|
||||
private let alamofireLogger = AlamofireLogger()
|
||||
|
||||
private init() {}
|
||||
|
||||
enum APIError: Error {
|
||||
@@ -46,13 +47,14 @@ class NetworkManager{
|
||||
) {
|
||||
// Stop monitoring network reachability
|
||||
NetworkReachibility.shared.stopMonitoring()
|
||||
|
||||
|
||||
// Execute the request on the specified queue
|
||||
queue.async {
|
||||
AF.request(url, method: method, parameters: parameters, encoding: encoding, headers: headers, requestModifier: { $0.timeoutInterval = 30 })
|
||||
.authenticate(username: "admin", password: "Woka@1234")
|
||||
.validate(statusCode: 200..<300)
|
||||
.responseDecodable(of: T.self) { response in
|
||||
// alamofireLogger.request(response.da, didParseResponse: response)
|
||||
switch response.result {
|
||||
case .success(let value):
|
||||
// Handle successful response on the main thread
|
||||
@@ -107,3 +109,31 @@ class NetworkManager{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final class AlamofireLogger: EventMonitor {
|
||||
|
||||
func requestDidResume(_ request: Request) {
|
||||
|
||||
let allHeaders = request.request.flatMap { $0.allHTTPHeaderFields.map { $0.description } } ?? "None"
|
||||
let headers = """
|
||||
⚡️⚡️⚡️⚡️ Request Started: \(request)
|
||||
⚡️⚡️⚡️⚡️ Headers: \(allHeaders)
|
||||
"""
|
||||
NSLog(headers)
|
||||
|
||||
|
||||
let body = request.request.flatMap { $0.httpBody.map { String(decoding: $0, as: UTF8.self) } } ?? "None"
|
||||
let message = """
|
||||
⚡️⚡️⚡️⚡️ Request Started: \(request)
|
||||
⚡️⚡️⚡️⚡️ Body Data: \(body)
|
||||
"""
|
||||
NSLog(message)
|
||||
}
|
||||
|
||||
func request<Value>(_ request: DataRequest, didParseResponse response: AFDataResponse<Value>) {
|
||||
|
||||
NSLog("⚡️⚡️⚡️⚡️ Response Received: \(response.debugDescription)")
|
||||
NSLog("⚡️⚡️⚡️⚡️ Response All Headers: \(String(describing: response.response?.allHeaderFields))")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +67,7 @@ class OnBoardVC: UIViewController {
|
||||
|
||||
|
||||
@IBAction func guestLoginBtnTapped(_ sender: UIButton) {
|
||||
vm.guestLogin()
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user