-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
212 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 3 additions & 4 deletions
7
CheoMooRac/CheoMooRac/Resources/Storyboards/Base.lproj/Main.storyboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// | ||
// Person.swift | ||
// CheoMooRac | ||
// | ||
// Created by 김윤서 on 2021/09/23. | ||
// | ||
|
||
struct Person { | ||
var firstName: String | ||
var familyName: String | ||
var phoneNumber: String | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// Dynamic.swift | ||
// CheoMooRac | ||
// | ||
// Created by 김윤서 on 2021/09/24. | ||
// | ||
|
||
import Foundation | ||
|
||
class Dynamic<T> { | ||
typealias Listener = (T) -> Void | ||
var listener: Listener? | ||
|
||
func bind(_ listener: Listener?) { | ||
self.listener = listener | ||
} | ||
|
||
func bindAndFire(_ listener: Listener?) { | ||
self.listener = listener | ||
listener?(value) | ||
} | ||
|
||
var value: T { | ||
didSet { | ||
listener?(value) | ||
} | ||
} | ||
|
||
init(_ v: T) { | ||
value = v | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
CheoMooRac/CheoMooRac/Sources/ViewModels/MainViewModel.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// | ||
// MainViewModel.swift | ||
// CheoMooRac | ||
// | ||
// Created by 김윤서 on 2021/09/23. | ||
// | ||
|
||
import Foundation | ||
|
||
protocol MainViewModelInput { | ||
|
||
} | ||
|
||
protocol MainViewModelOutput { | ||
var list: Dynamic<[String]> {get} | ||
var sectionHeaderList: Dynamic<[String]> {get} | ||
} | ||
|
||
protocol MainViewModelProtocol : MainViewModelInput,MainViewModelOutput {} | ||
|
||
class MainViewModel: MainViewModelProtocol { | ||
|
||
// MARK: - OUTPUT | ||
let list: Dynamic<[String]> = Dynamic([]) | ||
let sectionHeaderList: Dynamic<[String]> = Dynamic([]) | ||
|
||
// private var filteredList: [String] = [] | ||
// private var filterdHeaderList: [String] = [] | ||
// private var list = ["김윤서", "김루희", "윤예지", "김혜수", "코코", "민재", "잼권이", "리헤이", "노제", "몬익화", "립제이", "잘린이", "엠마", "모아나", "케이데이", "가비", "시미즈zz", "강호동", "이수근", "유재석", "리정" ] | ||
// | ||
// private var filteredList: [String] = [] | ||
// private var filterdHeaderList: [String] = [] | ||
// | ||
// private var sectionHeaderList: [String] { | ||
// var sectionHeaderList: [String] = [] | ||
// list.forEach { name in | ||
// sectionHeaderList.append(StringManager.shared.chosungCheck(word: name)) | ||
// } | ||
// | ||
// return Array(Set(sectionHeaderList)).sorted() | ||
// } | ||
|
||
// var sectionHeaderList$: [String] { | ||
// var sectionHeaderList: [String] = [] | ||
// self.list?.forEach { name in | ||
// sectionHeaderList.append(StringManager.shared.chosungCheck(word: name)) | ||
// } | ||
// | ||
// return Array(Set(sectionHeaderList)).sorted() | ||
// } | ||
|
||
init() { | ||
self.list.value = ["김윤서", "김루희", "윤예지", "김혜수", "코코", "민재", "잼권이", "리헤이", "노제", "몬익화", "립제이", "잘린이", "엠마", "모아나", "케이데이", "가비", "시미즈zz", "강호동", "이수근", "유재석", "리정" ] | ||
|
||
var sectionHeaderList$: [String] = [] | ||
self.list.value.forEach { name in | ||
sectionHeaderList$.append(StringManager.shared.chosungCheck(word: name)) | ||
} | ||
|
||
self.sectionHeaderList.value = Array(Set(sectionHeaderList$)).sorted() | ||
} | ||
} |
Oops, something went wrong.