Skip to content

Commit

Permalink
Design: 친구목록 ui 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
hhyukjin committed Feb 1, 2024
1 parent ff31539 commit 6286b41
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 12 deletions.
8 changes: 8 additions & 0 deletions iOS/Ringo/Ringo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
945603152B6AC22A002F4B33 /* ContactsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 945603142B6AC22A002F4B33 /* ContactsViewController.swift */; };
945603172B6AC2D3002F4B33 /* RecentsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 945603162B6AC2D3002F4B33 /* RecentsViewController.swift */; };
945603192B6AC365002F4B33 /* AccountViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 945603182B6AC365002F4B33 /* AccountViewController.swift */; };
9456031B2B6BD40B002F4B33 /* ContactsNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9456031A2B6BD40B002F4B33 /* ContactsNavigationController.swift */; };
9456031D2B6BF44A002F4B33 /* FriendRequestViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9456031C2B6BF44A002F4B33 /* FriendRequestViewController.swift */; };
945CF97B2B67E1CD00396E4E /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 945CF97A2B67E1CD00396E4E /* AppDelegate.swift */; };
945CF97D2B67E1CD00396E4E /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 945CF97C2B67E1CD00396E4E /* SceneDelegate.swift */; };
945CF97F2B67E1CD00396E4E /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 945CF97E2B67E1CD00396E4E /* ViewController.swift */; };
Expand All @@ -25,6 +27,8 @@
945603142B6AC22A002F4B33 /* ContactsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContactsViewController.swift; sourceTree = "<group>"; };
945603162B6AC2D3002F4B33 /* RecentsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecentsViewController.swift; sourceTree = "<group>"; };
945603182B6AC365002F4B33 /* AccountViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountViewController.swift; sourceTree = "<group>"; };
9456031A2B6BD40B002F4B33 /* ContactsNavigationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContactsNavigationController.swift; sourceTree = "<group>"; };
9456031C2B6BF44A002F4B33 /* FriendRequestViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FriendRequestViewController.swift; sourceTree = "<group>"; };
945CF9772B67E1CD00396E4E /* Ringo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Ringo.app; sourceTree = BUILT_PRODUCTS_DIR; };
945CF97A2B67E1CD00396E4E /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
945CF97C2B67E1CD00396E4E /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -70,7 +74,9 @@
945CF97C2B67E1CD00396E4E /* SceneDelegate.swift */,
945CF97E2B67E1CD00396E4E /* ViewController.swift */,
945603122B6AC07D002F4B33 /* TabBarViewController.swift */,
9456031A2B6BD40B002F4B33 /* ContactsNavigationController.swift */,
945603142B6AC22A002F4B33 /* ContactsViewController.swift */,
9456031C2B6BF44A002F4B33 /* FriendRequestViewController.swift */,
945603162B6AC2D3002F4B33 /* RecentsViewController.swift */,
945603182B6AC365002F4B33 /* AccountViewController.swift */,
945CF9832B67E1CE00396E4E /* Assets.xcassets */,
Expand Down Expand Up @@ -157,13 +163,15 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
9456031B2B6BD40B002F4B33 /* ContactsNavigationController.swift in Sources */,
945603132B6AC07D002F4B33 /* TabBarViewController.swift in Sources */,
945CF97F2B67E1CD00396E4E /* ViewController.swift in Sources */,
945603192B6AC365002F4B33 /* AccountViewController.swift in Sources */,
945CF97B2B67E1CD00396E4E /* AppDelegate.swift in Sources */,
945603172B6AC2D3002F4B33 /* RecentsViewController.swift in Sources */,
945CF97D2B67E1CD00396E4E /* SceneDelegate.swift in Sources */,
945603152B6AC22A002F4B33 /* ContactsViewController.swift in Sources */,
9456031D2B6BF44A002F4B33 /* FriendRequestViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Binary file not shown.
48 changes: 48 additions & 0 deletions iOS/Ringo/Ringo/ContactsNavigationController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//
// ContactsNavigationController.swift
// Ringo
//
// Created by 강진혁 on 2/1/24.
//

import UIKit

class ContactsNavigationController: UINavigationController {

override func viewDidLoad() {
super.viewDidLoad()

setViewControllers([ContactsViewController()], animated: true)
// Do any additional setup after loading the view.
}
/*
// MARK: - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/

}
// canvas 이용하기
import SwiftUI

struct ContactsNavigationControllerRepresentable: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> ContactsNavigationController {
return ContactsNavigationController()
}

func updateUIViewController(_ uiViewController: ContactsNavigationController, context: Context) {
}

typealias UIViewControllerType = ContactsNavigationController

}
@available(iOS 13.0.0, *)
struct ContactsNavigationViewPreview: PreviewProvider {
static var previews: some View {
ContactsNavigationControllerRepresentable().edgesIgnoringSafeArea(.all)
}
}
65 changes: 62 additions & 3 deletions iOS/Ringo/Ringo/ContactsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,53 @@
//

import UIKit
import SnapKit

class ContactsViewController: UIViewController {
class ContactsViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {

let randomNames = ["민준", "서준", "예준", "도윤", "시우", "주원", "하준", "지호", "지후", "준서", "준우", "현우", "도현", "지훈", "건우", "우진", "선우", "서진", "민재", "현준", "연우", "유준", "정우", "승우", "승현", "시윤", "준혁", "은우", "지환", "승민", "지우", "유찬", "윤우", "민성", "준영", "시후", "진우", "지수", "서연", "서윤", "지우", "서현", "민서", "하은", "하윤", "윤서", "지유", "지민", "채원", "지윤", "은서", "수아", "다은", "예은", "지아", "수빈", "소율", "예린", "예원", "지원", "소윤", "지안", "하린", "시은", "유진", "채은"]

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return randomNames.count
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
cell.textLabel?.text = randomNames[indexPath.row]

return cell
}


let searchController = UISearchController()
var tableView: UITableView!

override func viewDidLoad() {
super.viewDidLoad()

view.backgroundColor = .red
// Do any additional setup after loading the view.
view.backgroundColor = .white

// navigationItem.largeTitleDisplayMode = .inline

//navigation
self.navigationItem.title = "Contacts"
self.navigationController?.navigationBar.prefersLargeTitles = true
self.navigationItem.searchController = searchController
self.navigationItem.hidesSearchBarWhenScrolling = false
self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: UIImage(systemName: "person.badge.plus"), style: .plain, target: self, action: #selector(requestFriend))

//table
tableView = UITableView(frame: CGRect(x: 0, y: 0, width: self.view.bounds.width, height: self.view.bounds.height))
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "Cell")
tableView.delegate = self
tableView.dataSource = self
self.view.addSubview(tableView)

}

//navigaion rightBtn action
@objc private func requestFriend(_ sender: UIBarButtonItem) {
self.navigationController?.pushViewController(FriendRequestViewController(), animated: true)
}


Expand All @@ -28,3 +67,23 @@ class ContactsViewController: UIViewController {
*/

}
// canvas 이용하기
import SwiftUI

struct ContactsViewControllerRepresentable: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> ContactsViewController {
return ContactsViewController()
}

func updateUIViewController(_ uiViewController: ContactsViewController, context: Context) {
}

typealias UIViewControllerType = ContactsViewController

}
@available(iOS 13.0.0, *)
struct ContactsViewPreview: PreviewProvider {
static var previews: some View {
ContactsViewControllerRepresentable().edgesIgnoringSafeArea(.all)
}
}
33 changes: 33 additions & 0 deletions iOS/Ringo/Ringo/FriendRequestViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// FriendRequestViewController.swift
// Ringo
//
// Created by 강진혁 on 2/2/24.
//

import UIKit

class FriendRequestViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()

view.backgroundColor = .brown

self.navigationItem.title = "Request Friend"
self.navigationItem.largeTitleDisplayMode = .never
// Do any additional setup after loading the view.
}


/*
// MARK: - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/

}
37 changes: 28 additions & 9 deletions iOS/Ringo/Ringo/TabBarViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,38 @@ class TabBarViewController: UITabBarController{
override func viewDidLoad() {
super.viewDidLoad()

let contactsVC = UINavigationController(rootViewController: ContactsViewController())
tabBar.backgroundColor = .init(white: 1, alpha: 0.8)

// let contactsVC = UINavigationController(rootViewController: ContactsViewController())
let contactsVC = ContactsNavigationController()
let recentsVC = RecentsViewController()
let accountVC = AccountViewController()

contactsVC.title = "Contacts"
recentsVC.title = "Recents"
accountVC.title = "Account"

contactsVC.tabBarItem.image = UIImage(systemName: "person.3")
recentsVC.tabBarItem.image = UIImage(systemName: "clock")
accountVC.tabBarItem.image = UIImage(systemName: "person.text.rectangle")
contactsVC.tabBarItem = UITabBarItem(title: "Contacts", image: UIImage(systemName: "person.3"), tag: 1)
recentsVC.tabBarItem = UITabBarItem(title: "Recents", image: UIImage(systemName: "clock"), tag: 2)
accountVC.tabBarItem = UITabBarItem(title: "Account", image: UIImage(systemName: "person.text.rectangle"), tag: 3)

setViewControllers([contactsVC,recentsVC,accountVC], animated: true)
setViewControllers([contactsVC,recentsVC,accountVC], animated: false)
}
}

// canvas 이용하기
import SwiftUI

struct TabBarViewControllerRepresentable: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> TabBarViewController {
return TabBarViewController()
}

func updateUIViewController(_ uiViewController: TabBarViewController, context: Context) {
}

typealias UIViewControllerType = TabBarViewController

}
@available(iOS 13.0.0, *)
struct TabBarViewPreview: PreviewProvider {
static var previews: some View {
TabBarViewControllerRepresentable().edgesIgnoringSafeArea(.all)
}
}

0 comments on commit 6286b41

Please sign in to comment.