Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added SafeText App #29

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
434 changes: 434 additions & 0 deletions Swift/SafeText/SafeText.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"pins" : [
{
"identity" : "iqkeyboardmanager",
"kind" : "remoteSourceControl",
"location" : "https://github.com/hackiftekhar/IQKeyboardManager.git",
"state" : {
"revision" : "9ab144a1a6c6ae8dad25840610c072709b15d8b5",
"version" : "6.5.10"
}
},
{
"identity" : "lottie-ios",
"kind" : "remoteSourceControl",
"location" : "https://github.com/airbnb/lottie-ios.git",
"state" : {
"revision" : "314537ec697719fa33a9d48210f4d06a463286d3",
"version" : "3.4.3"
}
}
],
"version" : 2
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>SafeText.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"images" : [
{
"filename" : "crop.png",
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions Swift/SafeText/SafeText/Assets/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
1 change: 1 addition & 0 deletions Swift/SafeText/SafeText/Assets/secure.json

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions Swift/SafeText/SafeText/Logic/Authentication.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// Authentication.swift
// SafeText
//
// Created by Shaurya Gupta on 2022-09-25.
//

import LocalAuthentication
import SwiftUI

struct Authentication {
@Binding var isUnlocked: Bool
func Authenticate() {
let localAuthenticationContext = LAContext()
localAuthenticationContext.localizedFallbackTitle = "Please use your Passcode"

var authorizationError: NSError?
let reason = "Authentication is required to continue."
if localAuthenticationContext.canEvaluatePolicy(LAPolicy.deviceOwnerAuthentication, error: &authorizationError) {

localAuthenticationContext.evaluatePolicy(LAPolicy.deviceOwnerAuthentication, localizedReason: reason) { (success, evaluationError) in
if success {
// Set isUnlocked to true so that we can switch screens
print("Success!")
isUnlocked = true

} else {
// Error
print("Error \(evaluationError!.localizedDescription)")
}
}

} else {
// No biometrics
print("User has not enrolled into using Biometrics")
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
28 changes: 28 additions & 0 deletions Swift/SafeText/SafeText/SafeTextApp.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// SafeTextApp.swift
// SafeText
//
// Created by Shaurya Gupta on 2022-09-21.
//

import SwiftUI
import IQKeyboardManagerSwift

@main
struct SafeTextApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene {
WindowGroup {
ContentView()
}
}
}

class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
IQKeyboardManager.shared.enable = true
IQKeyboardManager.shared.enableAutoToolbar = false
IQKeyboardManager.shared.shouldResignOnTouchOutside = true
return true
}
}
68 changes: 68 additions & 0 deletions Swift/SafeText/SafeText/Views/ConfidencialInfoView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
//
// SecretStuff.swift
// SafeText
//
// Created by Shaurya Gupta on 2022-09-25.
//

import SwiftUI

struct ConfidencialInfoView: View {
@Binding var isUnlocked: Bool
@Binding var needAuth: Bool
@Binding var presentAlert: Bool
@Binding var confidencialInfo: String

var body: some View {
NavigationStack {
VStack {
Text("Your text goes here:")
.foregroundColor(.black.opacity(0.7))
.padding(.bottom, -40)
.padding(.leading, -130)

TextEditor(text: $confidencialInfo)
.scrollContentBackground(.hidden)
.background(Color.clear)
.padding(.leading, 5)
.frame(height: 400)
.border(LinearGradient(colors: [.yellow, .orange], startPoint: .topLeading, endPoint: .bottomTrailing), width: 2)
.padding()
.autocorrectionDisabled(false)
.textInputAutocapitalization(.never)
.foregroundColor(.black)
Button {
// Save Data
UserDefaults.standard.set(confidencialInfo, forKey: "info")
presentAlert = true
} label: {
HStack {
Text("Save")
.foregroundColor(.white)
}
}
.alert(isPresented: $presentAlert, content: {
Alert(title: Text("Saved Successfully!"), dismissButton: .default(Text("OK"), action: {
isUnlocked = false
}))
})
.font(.title3)
.padding(.horizontal, 160)
.padding(.vertical, 10)
.background(.blue)
.cornerRadius(5)

Toggle("Ask for biometry next time?", isOn: $needAuth)
.padding(.horizontal, 70)
.padding(.top, 15)
.font(.headline)
.fontWeight(.medium)
}
}
.background(.blue)
.scrollContentBackground(.hidden)
.navigationTitle("SafeText")
.preferredColorScheme(.light)
.toolbarColorScheme(.light, for: .navigationBar)
}
}
39 changes: 39 additions & 0 deletions Swift/SafeText/SafeText/Views/ContentView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// ContentView.swift
// SafeText
//
// Created by Shaurya Gupta on 2022-09-21.
//

import SwiftUI
import Lottie
import LocalAuthentication

struct ContentView: View {
@State private var isUnlocked = true
@AppStorage("info") private var confidencialInfo = ""
@AppStorage("needAuth") private var needAuth = true
@State private var presentAlert = false
var body: some View {
ZStack {
Color(UIColor(red: 1.00, green: 0.98, blue: 0.90, alpha: 1.00))
.ignoresSafeArea()

if isUnlocked == false && needAuth == true {
withAnimation(.easeInOut) {
HomepageView(isUnlocked: $isUnlocked)
}
} else {
withAnimation(.easeInOut) {
ConfidencialInfoView(isUnlocked: $isUnlocked, needAuth: $needAuth, presentAlert: $presentAlert, confidencialInfo: $confidencialInfo)
}
}
}
}

struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
}
47 changes: 47 additions & 0 deletions Swift/SafeText/SafeText/Views/HomepageView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//
// Homepage.swift
// SafeText
//
// Created by Shaurya Gupta on 2022-09-25.
//

import SwiftUI

struct HomepageView: View {
@Binding var isUnlocked: Bool
var body: some View {
NavigationStack {
// MARK: Title
VStack(alignment: .leading) {
Text("Welcome,")
.font(.largeTitle)
.fontWeight(.semibold)
.foregroundColor(.black.opacity(0.5))
Text("Authenticate to begin")
.font(.largeTitle)
.fontWeight(.semibold)
.foregroundColor(.black.opacity(0.8))
.padding(.top, -25)
}
LottieAnimationView(animationName: "secure", loopMode: .loop)
.frame(width: 400, height: 400)
Button {
// MARK: Authenticate User
Authentication(isUnlocked: $isUnlocked).Authenticate()
} label: {
// MARK: Auth button label
Text("Authenticate")
.font(.title3)
.foregroundColor(.white)
.padding(.horizontal, 100)
.padding(.vertical, 10)
}
.background(.blue)
.cornerRadius(5)
}
.background(.blue)
.scrollContentBackground(.hidden)
.preferredColorScheme(.light)
.toolbarColorScheme(.light, for: .navigationBar)
}
}
40 changes: 40 additions & 0 deletions Swift/SafeText/SafeText/Views/LottieView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// LottieView.swift
// SafeText
//
// Created by Shaurya Gupta on 2022-09-21.
//

import SwiftUI
import Lottie

struct LottieAnimationView: UIViewRepresentable {
var animationName: String
var loopMode = LottieLoopMode.playOnce

func makeUIView(context: UIViewRepresentableContext<LottieAnimationView>) -> UIView {
let view = UIView(frame: .zero)

if animationName.isEmpty {
fatalError("animationName can not be empty")
}

let animatedView = AnimationView()
let animation = Animation.named(animationName)
animatedView.animation = animation
animatedView.contentMode = .scaleAspectFit
animatedView.loopMode = loopMode
animatedView.play()

animatedView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(animatedView)
NSLayoutConstraint.activate([
animatedView.heightAnchor.constraint(equalTo: view.heightAnchor),
animatedView.widthAnchor.constraint(equalTo: view.widthAnchor)
])

return view
}

func updateUIView(_ uiView: UIViewType, context: Context) {}
}
11 changes: 11 additions & 0 deletions Swift/TwitterMenti/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Uncomment the next line to define a global platform for your project
platform :ios, '15.0'

target 'TwitterMenti' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!

# Pods for TwitterMenti

pod 'SwiftyJSON'
end
16 changes: 16 additions & 0 deletions Swift/TwitterMenti/Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
PODS:
- SwiftyJSON (5.0.1)

DEPENDENCIES:
- SwiftyJSON

SPEC REPOS:
trunk:
- SwiftyJSON

SPEC CHECKSUMS:
SwiftyJSON: 2f33a42c6fbc52764d96f13368585094bfd8aa5e

PODFILE CHECKSUM: d2219032f3560a4cd25431a0bc5748dc921153cf

COCOAPODS: 1.11.3
Loading