Skip to content

Commit

Permalink
push data
Browse files Browse the repository at this point in the history
  • Loading branch information
furkancingoz committed Jan 28, 2024
1 parent 3d2a873 commit 2359183
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GitHub Followers/Extension/String+Ext.swift
4 changes: 4 additions & 0 deletions GitHub Followers.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
6591106F2B646FE8003D7713 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6591106E2B646FE8003D7713 /* Assets.xcassets */; };
6591107A2B6476F7003D7713 /* SearchVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 659110792B6476F7003D7713 /* SearchVC.swift */; };
6591107C2B64771E003D7713 /* FavoritesListVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6591107B2B64771E003D7713 /* FavoritesListVC.swift */; };
659DBD482B667F3600B0D936 /* FollowersListVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 659DBD472B667F3600B0D936 /* FollowersListVC.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -26,6 +27,7 @@
659110732B646FE8003D7713 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
659110792B6476F7003D7713 /* SearchVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchVC.swift; sourceTree = "<group>"; };
6591107B2B64771E003D7713 /* FavoritesListVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoritesListVC.swift; sourceTree = "<group>"; };
659DBD472B667F3600B0D936 /* FollowersListVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FollowersListVC.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -64,6 +66,7 @@
6555E3CD2B65AAC60000FBD3 /* GFButton.swift */,
6555E3CF2B65ADB40000FBD3 /* GFTextField.swift */,
6591107B2B64771E003D7713 /* FavoritesListVC.swift */,
659DBD472B667F3600B0D936 /* FollowersListVC.swift */,
6591106E2B646FE8003D7713 /* Assets.xcassets */,
659110732B646FE8003D7713 /* Info.plist */,
);
Expand Down Expand Up @@ -140,6 +143,7 @@
buildActionMask = 2147483647;
files = (
6555E3D02B65ADB40000FBD3 /* GFTextField.swift in Sources */,
659DBD482B667F3600B0D936 /* FollowersListVC.swift in Sources */,
6591107C2B64771E003D7713 /* FavoritesListVC.swift in Sources */,
6555E3CE2B65AAC60000FBD3 /* GFButton.swift in Sources */,
6591107A2B6476F7003D7713 /* SearchVC.swift in Sources */,
Expand Down
20 changes: 20 additions & 0 deletions GitHub Followers/FollowersListVC.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// FollowersListVC.swift
// GitHub Followers
//
// Created by Furkan Cingöz on 28.01.2024.
//

import UIKit

class FollowersListVC: UIViewController {
var username: String!
override func viewDidLoad() {
super.viewDidLoad()
navigationController?.isNavigationBarHidden = false
view.backgroundColor = .systemBackground
navigationController?.navigationBar.prefersLargeTitles = true
}


}
2 changes: 2 additions & 0 deletions GitHub Followers/GFTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class GFTextField: UITextField {
backgroundColor = .tertiarySystemBackground
autocorrectionType = .no //auto correction off
placeholder = "Enter user name"
returnKeyType = .go



}
Expand Down
8 changes: 5 additions & 3 deletions GitHub Followers/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {

guard let windowScene = (scene as? UIWindowScene) else { return }

let searchNC = UINavigationController(rootViewController: SearchVC())
let favoriteNC = UINavigationController(rootViewController: FavoritesListVC())

window = UIWindow(frame: windowScene.coordinateSpace.bounds)
window?.windowScene = windowScene
window?.rootViewController = createTabbar()
window?.makeKeyAndVisible()

configureNavigaitonBar()
}

func createSearchNC() -> UINavigationController {
Expand All @@ -47,6 +45,10 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
return tabbar
}

func configureNavigaitonBar(){
UINavigationBar.appearance().tintColor = .systemGreen
}

func sceneDidDisconnect(_ scene: UIScene) {
// Called as the scene is being released by the system.
// This occurs shortly after the scene enters the background, or when its session is discarded.
Expand Down
47 changes: 33 additions & 14 deletions GitHub Followers/SearchVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ class SearchVC: UIViewController {
let logoImageView = UIImageView()
let userNameTextField = GFTextField()
let callToActionButton = GFButton(backgroundColor: .systemGreen, title: "Get Followers")
var isUserNameEntered: Bool { return !userNameTextField.text!.isEmpty }

override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .systemBackground
configureLogoImageView()
configureTextField()
confiugreButton()
createDismissKeyboardTapGesture()
}
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .systemBackground
configureLogoImageView()
configureTextField()
confiugreButton()
createDismissKeyboardTapGesture()
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
Expand All @@ -34,7 +35,18 @@ class SearchVC: UIViewController {
view.addGestureRecognizer(tap)
}

private func configureLogoImageView(){
@objc func pushFollowersListVC(){
guard isUserNameEntered else {
print("no user name")
return
}
let followersListVC = FollowersListVC()
followersListVC.username = userNameTextField.text
followersListVC.title = userNameTextField.text
navigationController?.pushViewController(followersListVC, animated: true)
}

private func configureLogoImageView(){
view.addSubview(logoImageView)
logoImageView.translatesAutoresizingMaskIntoConstraints = false
logoImageView.image = UIImage(named: "gh-logo")!
Expand All @@ -47,8 +59,9 @@ private func configureLogoImageView(){
])
}

private func configureTextField(){
private func configureTextField(){
view.addSubview(userNameTextField)
userNameTextField.delegate = self
NSLayoutConstraint.activate([
userNameTextField.topAnchor.constraint(equalTo: logoImageView.bottomAnchor,constant: 48),
userNameTextField.leadingAnchor.constraint(equalTo: view.leadingAnchor,constant: 50),
Expand All @@ -57,11 +70,9 @@ private func configureTextField(){
])
}



private func confiugreButton(){
private func confiugreButton(){
view.addSubview(callToActionButton)

callToActionButton.addTarget(self, action: #selector(pushFollowersListVC), for: .touchUpInside)
NSLayoutConstraint.activate([
callToActionButton.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor,constant: -100),
callToActionButton.leadingAnchor.constraint(equalTo: view.leadingAnchor,constant: 50),
Expand All @@ -70,3 +81,11 @@ private func configureTextField(){
])
}
}


extension SearchVC : UITextFieldDelegate {
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
pushFollowersListVC()
return true
}
}

0 comments on commit 2359183

Please sign in to comment.