Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ra1028 committed Jun 4, 2019
1 parent 61d55b2 commit bf2eeb0
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 19 deletions.
26 changes: 13 additions & 13 deletions SwiftUI-Combine-Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
/* Begin PBXBuildFile section */
6B194EFF22A6BA07001B3151 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B194EFE22A6BA07001B3151 /* AppDelegate.swift */; };
6B194F0122A6BA07001B3151 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B194F0022A6BA07001B3151 /* SceneDelegate.swift */; };
6B194F0322A6BA07001B3151 /* UserSearchView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B194F0222A6BA07001B3151 /* UserSearchView.swift */; };
6B194F0322A6BA07001B3151 /* SearchUserView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B194F0222A6BA07001B3151 /* SearchUserView.swift */; };
6B194F0522A6BA08001B3151 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6B194F0422A6BA08001B3151 /* Assets.xcassets */; };
6B194F0822A6BA08001B3151 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6B194F0722A6BA08001B3151 /* Preview Assets.xcassets */; };
6B194F0B22A6BA08001B3151 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6B194F0922A6BA08001B3151 /* LaunchScreen.storyboard */; };
6B194F1322A7108C001B3151 /* UserRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B194F1222A7108C001B3151 /* UserRow.swift */; };
6B194F1322A7108C001B3151 /* SearchUserRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B194F1222A7108C001B3151 /* SearchUserRow.swift */; };
6B194F1522A710AB001B3151 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B194F1422A710AB001B3151 /* User.swift */; };
6B194F1722A710E6001B3151 /* SearchUserResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B194F1622A710E6001B3151 /* SearchUserResponse.swift */; };
6B194F1922A710FF001B3151 /* SearchUserViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B194F1822A710FF001B3151 /* SearchUserViewModel.swift */; };
6B194F1B22A7112D001B3151 /* UserSearchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B194F1A22A7112D001B3151 /* UserSearchBar.swift */; };
6B194F1B22A7112D001B3151 /* SearchUserBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B194F1A22A7112D001B3151 /* SearchUserBar.swift */; };
6B194F1D22A71154001B3151 /* FoundationExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B194F1C22A71154001B3151 /* FoundationExtensions.swift */; };
6B194F1F22A71B0F001B3151 /* AnySubscription.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B194F1E22A71B0F001B3151 /* AnySubscription.swift */; };
/* End PBXBuildFile section */
Expand All @@ -26,16 +26,16 @@
6B194EFB22A6BA07001B3151 /* SwiftUI-Combine-Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "SwiftUI-Combine-Example.app"; sourceTree = BUILT_PRODUCTS_DIR; };
6B194EFE22A6BA07001B3151 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
6B194F0022A6BA07001B3151 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
6B194F0222A6BA07001B3151 /* UserSearchView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserSearchView.swift; sourceTree = "<group>"; };
6B194F0222A6BA07001B3151 /* SearchUserView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchUserView.swift; sourceTree = "<group>"; };
6B194F0422A6BA08001B3151 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
6B194F0722A6BA08001B3151 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
6B194F0A22A6BA08001B3151 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
6B194F0C22A6BA08001B3151 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
6B194F1222A7108C001B3151 /* UserRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserRow.swift; sourceTree = "<group>"; };
6B194F1222A7108C001B3151 /* SearchUserRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchUserRow.swift; sourceTree = "<group>"; };
6B194F1422A710AB001B3151 /* User.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = User.swift; sourceTree = "<group>"; };
6B194F1622A710E6001B3151 /* SearchUserResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchUserResponse.swift; sourceTree = "<group>"; };
6B194F1822A710FF001B3151 /* SearchUserViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchUserViewModel.swift; sourceTree = "<group>"; };
6B194F1A22A7112D001B3151 /* UserSearchBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserSearchBar.swift; sourceTree = "<group>"; };
6B194F1A22A7112D001B3151 /* SearchUserBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchUserBar.swift; sourceTree = "<group>"; };
6B194F1C22A71154001B3151 /* FoundationExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FoundationExtensions.swift; sourceTree = "<group>"; };
6B194F1E22A71B0F001B3151 /* AnySubscription.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnySubscription.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -70,12 +70,12 @@
6B194EFD22A6BA07001B3151 /* SwiftUI-Combine-Example */ = {
isa = PBXGroup;
children = (
6B194F0222A6BA07001B3151 /* UserSearchView.swift */,
6B194F0222A6BA07001B3151 /* SearchUserView.swift */,
6B194F1822A710FF001B3151 /* SearchUserViewModel.swift */,
6B194F1A22A7112D001B3151 /* UserSearchBar.swift */,
6B194F1222A7108C001B3151 /* UserRow.swift */,
6B194F1422A710AB001B3151 /* User.swift */,
6B194F1A22A7112D001B3151 /* SearchUserBar.swift */,
6B194F1222A7108C001B3151 /* SearchUserRow.swift */,
6B194F1622A710E6001B3151 /* SearchUserResponse.swift */,
6B194F1422A710AB001B3151 /* User.swift */,
6B194F1E22A71B0F001B3151 /* AnySubscription.swift */,
6B194F1C22A71154001B3151 /* FoundationExtensions.swift */,
6B194F0022A6BA07001B3151 /* SceneDelegate.swift */,
Expand Down Expand Up @@ -167,16 +167,16 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
6B194F1B22A7112D001B3151 /* UserSearchBar.swift in Sources */,
6B194F1B22A7112D001B3151 /* SearchUserBar.swift in Sources */,
6B194EFF22A6BA07001B3151 /* AppDelegate.swift in Sources */,
6B194F0122A6BA07001B3151 /* SceneDelegate.swift in Sources */,
6B194F1F22A71B0F001B3151 /* AnySubscription.swift in Sources */,
6B194F0322A6BA07001B3151 /* UserSearchView.swift in Sources */,
6B194F0322A6BA07001B3151 /* SearchUserView.swift in Sources */,
6B194F1922A710FF001B3151 /* SearchUserViewModel.swift in Sources */,
6B194F1722A710E6001B3151 /* SearchUserResponse.swift in Sources */,
6B194F1D22A71154001B3151 /* FoundationExtensions.swift in Sources */,
6B194F1522A710AB001B3151 /* User.swift in Sources */,
6B194F1322A7108C001B3151 /* UserRow.swift in Sources */,
6B194F1322A7108C001B3151 /* SearchUserRow.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
2 changes: 1 addition & 1 deletion SwiftUI-Combine-Example/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ final class SceneDelegate: UIResponder, UIWindowSceneDelegate {
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
let window = UIWindow(frame: UIScreen.main.bounds)
window.rootViewController = UIHostingController(
rootView: UserSearchView().environmentObject(SearchUserViewModel())
rootView: SearchUserView().environmentObject(SearchUserViewModel())
)
self.window = window
window.makeKeyAndVisible()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import SwiftUI

struct UserSearchBar: View {
struct SearchUserBar: View {
@Binding var text: String
@State var action: () -> Void

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import SwiftUI

struct UserRow: View {
struct SearchUserRow: View {
@EnvironmentObject var viewModel: SearchUserViewModel
@State var user: User

Expand All @@ -13,8 +13,10 @@ struct UserRow: View {
.clipShape(Circle())
.overlay(Circle().stroke(Color.gray, lineWidth: 1))
}

Text(user.login)
.font(Font.system(size: 18).bold())

Spacer()
}
.padding(EdgeInsets(top: 8, leading: 16, bottom: 8, trailing: 16))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import SwiftUI

struct UserSearchView: View {
struct SearchUserView: View {
@EnvironmentObject var viewModel: SearchUserViewModel
@State var text = "ra1028"

var body: some View {
NavigationView {
VStack {
UserSearchBar(text: $text) {
SearchUserBar(text: $text) {
self.viewModel.search(name: self.text)
}

List(viewModel.users) { user in
UserRow(user: user)
SearchUserRow(user: user)
.tapAction { print(user) }
}
}
Expand Down

0 comments on commit bf2eeb0

Please sign in to comment.