'Code module
#Region Project Attributes
#ApplicationLabel: Tavos
#Version: 1.0.0
'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
#iPhoneOrientations: Portrait
#iPadOrientations: Portrait
#Target: iPhone, iPad
#ATSEnabled: False
#MinVersion: 8
#AppFont: font.ttf
#AppFont: fontb.ttf
#AppFont: fontavosium.ttf
#PlistExtra:<key>NSContactsUsageDescription</key><string>Contact</string>
#PlistExtra:<key>NSPhotoLibraryUsageDescription</key><string>Picture</string>
#PlistExtra:<key>NSCameraUsageDescription</key><string>Camera</string>
#PlistExtra:<key>NSMicrophoneUsageDescription</key><string>Record video</string>
#PlistExtra:<key>UIBackgroundModes</key><array><string>location</string><string>audio</string><string>remote-notification</string></array>
#PlistExtra:<key>NSLocationWhenInUseUsageDescription</key><string>Location</string>
#PlistExtra:<key>NSLocationUsageDescription</key><string>Used to display the current navigation data.</string>
#PlistExtra: <key>UIApplicationShortcutItems</key><array><dict><key>UIApplicationShortcutItemType</key><string>cart</string><key>UIApplicationShortcutItemTitle</key><string>Cart</string></dict><dict><key>UIApplicationShortcutItemType</key><string>profile</string><key>UIApplicationShortcutItemTitle</key><string>Profile</string></dict><dict><key>UIApplicationShortcutItemType</key><string>shop</string><key>UIApplicationShortcutItemTitle</key><string>Shop</string></dict><dict><key>UIApplicationShortcutItemType</key><string>search</string><key>UIApplicationShortcutItemTitle</key><string>Search</string></dict></array>
#CertificateFile: ios_development.cer
#ProvisionFile: user.mobileprovision
#PlistExtra: <key>UIBackgroundModes</key><array><string>remote-notification</string></array>
#Entitlement: <key>aps-environment</key><string>development</string>
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public App As Application
Public NavControl As NavigationController
Private Page1 As Page
Private txtusername As TextField
Private txtpassword As TextField
Private btnlogin As Button
Private MyToast As MyToastMessageShow
Private MyProgress As MyProgessDialogShow
Private lblshow As Label
Private username,password As String
Private lblregister As Label
Private pnlcontainer As Panel
Private push As FirebaseMessaging
Private logo As Label
Private ana As FirebaseAnalytics
End Sub
Private Sub Application_Start (Nav As NavigationController)
ana.Initialize
NavControl = Nav
NavControl.NavigationBarVisible = False
Library.SettingManager.Initialize
push.Initialize("push")
App.RegisterUserNotifications(True,True,True)
App.RegisterForRemoteNotifications
CallSubDelayed(Me,"Application_Active")
GetPushData
Dim no As NativeObject = NavControl
no.GetField("navigationBar").RunMethod("setTintColor:", Array(no.ColorToUIColor(Colors.Gray)))
QuickActions.StartSettings
Dim username,password As String
username = Library.SettingManager.GetString("username")
password = Library.SettingManager.GetString("password")
If username.Length > 4 And password.Length > 4 Then
Configuration.Username = username
Configuration.Password = password
actShop.Show
Return
End If
Page1.Initialize("Page1")
Page1.RootPanel.LoadLayout("frmlogin")
NavControl.ShowPage(Page1)
Page1.RootPanel.Color = Colors.White
logo.Font = Library.GetFontIcon(logo.Font.Size)
Show
End Sub
Sub Page1_Resize(Width As Int,Height As Int)
MyToast.Initialize(Page1.RootPanel,Me)
MyToast.ChangedStatusColor = False
MyProgress.Initialize(Page1.RootPanel)
End Sub
Sub Show
Dim username,password As String
username = Library.SettingManager.GetString("username")
password = Library.SettingManager.GetString("password")
txtusername.Color = Colors.RGB(250, 250, 250)
txtpassword.Color = Colors.RGB(250, 250, 250)
username = Library.SettingManager.GetString("username")
password = Library.SettingManager.GetString("password")
If Library.SettingManager.GetString("username").Length > 0 Then
txtusername.Text = Library.SettingManager.GetString("username")
End If
If Library.SettingManager.GetString("password").Length > 0 Then
txtpassword.Text = Library.SettingManager.GetString("password")
End If
Dim cs As CSBuilder
cs.Initialize
cs.Font(Font.CreateNew2("iranyekanmobile",lblregister.Font.Size)).Color(Colors.RGB(173,173,173)).Append("؟").Pop
cs.Font(Font.CreateNew2("iranyekanmobile",lblregister.Font.Size)).Color(Colors.RGB(125,125,125)).Append("").PopAll
lblregister.AttributedText = cs
End Sub
Sub txtusername_TextChanged (Old As String, New As String)
If txtusername.Text.Length > 1 And txtpassword.Text.Length > 1 Then
Library.EnableButton(btnlogin)
Else
Library.DisableButton(btnlogin)
End If
End Sub
Sub txtpassword_TextChanged (Old As String, New As String)
If txtusername.Text.Length > 1 And txtpassword.Text.Length > 1 Then
Library.EnableButton(btnlogin)
Else
Library.DisableButton(btnlogin)
End If
End Sub
Sub lblregister_Click
NavControl.RemoveCurrentPage
actRegister.Show
End Sub
Sub btnlogin_Click
Page1.ResignFocus
Wait For (Library.CheckInternet) Complete(State As Boolean)
If State = False Then
NavControl.RemoveCurrentPage
actNoInternet.Show
Return
End If
If txtusername.Text.Length < 5 Then
Return
End If
If Regex.IsMatch("\w{5,}",txtusername.Text) = False Then
Return
End If
If txtpassword.Text.Length < 5 Then
Return
End If
Configuration.Username = txtusername.Text
Configuration.Password = txtpassword.Text
Dim ws2 As OnstagramWS
ws2.Initialize(Me)
ws2.User_Login("Login_User")
End Sub
Sub Login_User(Data As Map,Status As Boolean)
MyProgress.HideProgress
If Status = False Then
If Data.Get("data") = "NOT_FOUND_USER" Then
Else If Data.Get("status_code") = "INCORRECT_USERNAME" Or Data.Get("status_code") = "INCORRECT_PASSWORD" Then
Else If Data.Get("status_code") = "NOT_VERIFY_USER" Then
Else If Data.Get("status_code") = "BLOCK_USER" Then
Else If Data.Get("status_code") = "NOT_ENABLE_USER" Then
Else If Data.Get("status_code") = "NOT_ACTIVE_USER" Then
Else
End If
Return
End If
If Status = True Then
Library.SettingManager.SetString("username",txtusername.Text)
Library.SettingManager.SetString("password",txtpassword.Text)
actShop.Show
End If
End Sub
Sub OnShowLoginForm_Event
Library.SettingManager.SetString("username",txtusername.Text)
Library.SettingManager.SetString("password",txtpassword.Text)
NavControl.RemoveCurrentPage
QuickActions.Logined = True
actShop.Show
End Sub
Sub lblshow_Click
If txtpassword.Tag = "" Then
txtpassword.PasswordMode = False
txtpassword.Tag = "show"
lblshow.TextColor = Colors.RGB(144,144,144)
Else
txtpassword.PasswordMode = True
lblshow.TextColor = Colors.RGB(36,36,36)
txtpassword.Tag = ""
End If
End Sub
Sub lblforget_Click
NavControl.RemoveCurrentPage
actForget.Show
End Sub
Sub lblinstagram_Click
End Sub
Sub StopConnection
MyProgress.HideProgress
End Sub
Sub btnclose_Click
NavControl.RemoveCurrentPage
End Sub
Sub ShowNoInternet
MyProgress.HideProgress
End Sub
Private Sub Application_Background
QuickActions.InactiveSettings
push.FCMDisconnect
End Sub
#region FirebaseMessage Service
Sub Application_RemoteNotification (Message As Map, CompletionHandler As CompletionHandler)
Dim sType As String
sType = Message.Get("type")
If sType.ToLowerCase = "null" Then Return
Dim notifi As Notifications
notifi.Initialize
notifi.AddNotification(Message.Get("body"),DateTime.Now)
If actShop.StateVisiablePage Then CallSubDelayed2(actShop,"UpdateNotification",notifi.GetNotificationCount)
CompletionHandler.Complete
End Sub
Sub Application_PushToken (Success As Boolean, Token() As Byte)
End Sub
Sub push_FCMConnected
push.SubscribeToTopic("users")
push.SubscribeToTopic("ios_general")
push.SubscribeToTopic(Library.GetDeviceID)
End Sub
Sub SubscribeToTopics2(Topic As String,State As Boolean)
If State Then
push.SubscribeToTopic(Topic)
Else
push.UnsubscribeFromTopic(Topic)
End If
End Sub
Sub Application_Active
push.FCMConnect
QuickActions.ActiveSettings
End Sub
Sub GetPushData
If App.LaunchOptions.IsInitialized And _
App.LaunchOptions.ContainsKey("UIApplicationLaunchOptionsRemoteNotificationKey") Then
Dim data As Object = App.LaunchOptions.Get("UIApplicationLaunchOptionsRemoteNotificationKey")
Dim no As NativeObject = App
no.GetField("delegate").RunMethod("application:didReceiveRemoteNotification:", _
Array(App, data))
End If
End Sub
#End Region
Sub Application_ShortcutItemClicked (ItemType As String)
If QuickActions.Logined = True Then
If ItemType = "cart" Then
actCart.Show
Else if ItemType = "profile" Then
actProfile.Show
Else if ItemType = "search" Then
actSearch.Show
Else if ItemType = "shop" Then
actShop.Show
End If
Return
End If
actShop.QuickActionType = ItemType
End Sub