Skip to content

Commit 8dc0c00

Browse files
authored
Merge pull request #5 from RxSwiftCommunity/develop/1.0
Override methods
2 parents 492d117 + 67623a5 commit 8dc0c00

33 files changed

+208
-210
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,7 @@ Carthage/Build
4141
# Swift Package Manager
4242
.build
4343
Package.resolved
44-
.swiftpm
44+
.swiftpm
45+
46+
# rxtree
47+
.rxtree-version

.travis.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

Example/Podfile.lock

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
PODS:
22
- Differentiator (4.0.1)
33
- Fakery (4.1.1)
4-
- Reusable (4.1.0):
5-
- Reusable/Storyboard (= 4.1.0)
6-
- Reusable/View (= 4.1.0)
7-
- Reusable/Storyboard (4.1.0)
8-
- Reusable/View (4.1.0)
4+
- Reusable (4.1.1):
5+
- Reusable/Storyboard (= 4.1.1)
6+
- Reusable/View (= 4.1.1)
7+
- Reusable/Storyboard (4.1.1)
8+
- Reusable/View (4.1.1)
99
- RxBinding (0.3.1):
1010
- RxCocoa (~> 5)
1111
- RxSwift (~> 5)
12-
- RxCocoa (5.0.1):
12+
- RxCocoa (5.1.1):
1313
- RxRelay (~> 5)
1414
- RxSwift (~> 5)
1515
- RxController (0.10):
@@ -25,12 +25,12 @@ PODS:
2525
- RxCocoa (~> 5)
2626
- RxDataSources (~> 4)
2727
- RxSwift (~> 5)
28-
- RxFlow (2.7.0):
29-
- RxCocoa (>= 5.0.0)
30-
- RxSwift (>= 5.0.0)
31-
- RxRelay (5.0.1):
28+
- RxFlow (2.8.0):
29+
- RxCocoa (>= 5.1.1)
30+
- RxSwift (>= 5.1.1)
31+
- RxRelay (5.1.1):
3232
- RxSwift (~> 5)
33-
- RxSwift (5.0.1)
33+
- RxSwift (5.1.1)
3434
- SnapKit (5.0.1)
3535

3636
DEPENDENCIES:
@@ -61,17 +61,17 @@ EXTERNAL SOURCES:
6161
SPEC CHECKSUMS:
6262
Differentiator: 886080237d9f87f322641dedbc5be257061b0602
6363
Fakery: d3380c4aa1efe7631c0831d7e26aa9db4491f014
64-
Reusable: 82be188f29d96dc5eff0db7b2393bcc08d2cdd5b
64+
Reusable: 53a9acf5c536f229b31b5865782414b508252ddb
6565
RxBinding: 58be2cf1311165489a66eacb4a3e33932d598a53
66-
RxCocoa: e741b9749968e8a143e2b787f1dfbff2b63d0a5c
66+
RxCocoa: 32065309a38d29b5b0db858819b5bf9ef038b601
6767
RxController: c596ce5b2bc9ab933649690838d60118f0e4b110
6868
RxDataSources: efee07fa4de48477eca0a4611e6d11e2da9c1114
6969
RxDataSourcesSingleSection: 4394e57ae097f33e3845cf3a57bdf7826eca2d38
70-
RxFlow: 605ef6364d7e937bea8f9507a1e99a431cdc2493
71-
RxRelay: 89d54507f4fd4d969e6ec1d4bd7f3673640b4640
72-
RxSwift: e2dc62b366a3adf6a0be44ba9f405efd4c94e0c4
70+
RxFlow: 41c9d56e7611c6470d00febdfee08b63b0b018f8
71+
RxRelay: d77f7d771495f43c556cbc43eebd1bb54d01e8e9
72+
RxSwift: 81470a2074fa8780320ea5fe4102807cb7118178
7373
SnapKit: 97b92857e3df3a0c71833cce143274bf6ef8e5eb
7474

7575
PODFILE CHECKSUM: 0e048f42166325ac7ea57547d12ebbc2fc47fb5f
7676

77-
COCOAPODS: 1.8.4
77+
COCOAPODS: 1.9.1

Example/RxController/Controller/Child/FirstNameViewController.swift

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
// RxController_Example
44
//
55
// Created by Meng Li on 2019/06/03.
6-
// Copyright © 2019 CocoaPods. All rights reserved.
6+
// Copyright © 2019 MuShare. All rights reserved.
77
//
88

9+
import RxSwift
10+
911
private struct Const {
1012

1113
struct title {
@@ -59,22 +61,27 @@ class FirstNameViewController: BaseViewController<FirstNameViewModel> {
5961

6062
override func viewDidLoad() {
6163
super.viewDidLoad()
62-
view.backgroundColor = .white
63-
64-
view.addSubview(titleLabel)
65-
view.addSubview(firstNameLabel)
66-
view.addSubview(lastNameLabel)
67-
view.addSubview(updateButton)
68-
createConstraints()
6964

70-
disposeBag ~ [
65+
view.backgroundColor = .white
66+
}
67+
68+
override func subviews() -> [UIView] {
69+
return [
70+
titleLabel,
71+
firstNameLabel,
72+
lastNameLabel,
73+
updateButton
74+
]
75+
}
76+
77+
override func bind() -> [Disposable] {
78+
return [
7179
viewModel.firstName ~> firstNameLabel.rx.text,
7280
viewModel.lastName ~> lastNameLabel.rx.text
7381
]
7482
}
75-
7683

77-
private func createConstraints() {
84+
override func createConstraints() {
7885

7986
titleLabel.snp.makeConstraints {
8087
$0.left.equalToSuperview().offset(Const.title.marginLeft)

Example/RxController/Controller/Child/FirstNameViewModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// RxController_Example
44
//
55
// Created by Meng Li on 2019/06/03.
6-
// Copyright © 2019 CocoaPods. All rights reserved.
6+
// Copyright © 2019 MuShare. All rights reserved.
77
//
88

99
import Fakery

Example/RxController/Controller/Child/InfoViewController.swift

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
// RxController
44
//
55
// Created by Meng Li on 04/01/2019.
6-
// Copyright (c) 2019 XFLAG. All rights reserved.
6+
// Copyright (c) 2019 MuShare. All rights reserved.
77
//
88

9+
import RxSwift
10+
911
private struct Const {
1012

1113
struct nameTitle {
@@ -66,24 +68,28 @@ class InfoViewController: BaseViewController<InfoViewModel> {
6668
super.viewDidLoad()
6769
view.backgroundColor = .white
6870

69-
view.addSubview(nameTitleLabel)
70-
view.addSubview(numberTitleLabel)
71-
view.addSubview(updateButton)
72-
view.addSubview(nameView)
73-
view.addSubview(numberView)
74-
7571
addChild(nameViewController, to: nameView)
7672
addChild(numberViewController, to: numberView)
77-
78-
createConstraints()
79-
80-
disposeBag ~ [
73+
}
74+
75+
override func subviews() -> [UIView] {
76+
return [
77+
nameTitleLabel,
78+
numberTitleLabel,
79+
updateButton,
80+
nameView,
81+
numberView
82+
]
83+
}
84+
85+
override func bind() -> [Disposable] {
86+
return [
8187
viewModel.name ~> nameTitleLabel.rx.text,
8288
viewModel.number ~> numberTitleLabel.rx.text
8389
]
8490
}
8591

86-
private func createConstraints() {
92+
override func createConstraints() {
8793

8894
nameTitleLabel.snp.makeConstraints {
8995
$0.left.equalToSuperview().offset(Const.nameTitle.marginLeft)

Example/RxController/Controller/Child/InfoViewModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// RxController_Example
44
//
55
// Created by Meng Li on 2019/04/09.
6-
// Copyright © 2019 XFLAG. All rights reserved.
6+
// Copyright © 2019 MuShare. All rights reserved.
77
//
88

99
import RxSwift

Example/RxController/Controller/Child/LastNameViewController.swift

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
// RxController_Example
44
//
55
// Created by Meng Li on 2019/06/03.
6-
// Copyright © 2019 CocoaPods. All rights reserved.
6+
// Copyright © 2019 MuShare. All rights reserved.
77
//
88

9+
import RxSwift
10+
911
private struct Const {
1012

1113
struct title {
@@ -59,21 +61,27 @@ class LastNameViewController: BaseViewController<LastNameViewModel> {
5961

6062
override func viewDidLoad() {
6163
super.viewDidLoad()
62-
view.backgroundColor = .white
63-
64-
view.addSubview(titleLabel)
65-
view.addSubview(firstNameLabel)
66-
view.addSubview(lastNameLabel)
67-
view.addSubview(updateButton)
68-
createConstraints()
6964

70-
disposeBag ~ [
65+
view.backgroundColor = .white
66+
}
67+
68+
override func subviews() -> [UIView] {
69+
return [
70+
titleLabel,
71+
firstNameLabel,
72+
lastNameLabel,
73+
updateButton
74+
]
75+
}
76+
77+
override func bind() -> [Disposable] {
78+
return [
7179
viewModel.firstName ~> firstNameLabel.rx.text,
7280
viewModel.lastName ~> lastNameLabel.rx.text
7381
]
7482
}
7583

76-
private func createConstraints() {
84+
override func createConstraints() {
7785

7886
titleLabel.snp.makeConstraints {
7987
$0.left.equalToSuperview().offset(Const.title.marginLeft)

Example/RxController/Controller/Child/LastNameViewModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// RxController_Example
44
//
55
// Created by Meng Li on 2019/06/03.
6-
// Copyright © 2019 CocoaPods. All rights reserved.
6+
// Copyright © 2019 MuShare. All rights reserved.
77
//
88

99
import Fakery

Example/RxController/Controller/Child/NameViewController.swift

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
// RxController_Example
44
//
55
// Created by Meng Li on 2019/04/16.
6-
// Copyright © 2019 XFLAG. All rights reserved.
6+
// Copyright © 2019 MuShare. All rights reserved.
77
//
88

9+
import RxSwift
10+
911
private struct Const {
1012
struct title {
1113
static let marginLeft = 10
@@ -78,32 +80,36 @@ class NameViewController: BaseViewController<NameViewModel> {
7880
override func viewDidLoad() {
7981
super.viewDidLoad()
8082
view.backgroundColor = .white
81-
82-
view.addSubview(titleLabel)
83-
view.addSubview(nameLabel)
84-
view.addSubview(numberLabel)
85-
view.addSubview(updateButton)
86-
view.addSubview(firstNameView)
87-
view.addSubview(lastNameView)
8883

8984
addChild(firstNameViewController, to: firstNameView)
9085
addChild(lastNameViewController, to: lastNameView)
91-
92-
createConstraints()
93-
94-
disposeBag ~ [
95-
viewModel.name ~> nameLabel.rx.text,
96-
viewModel.number ~> numberLabel.rx.text
97-
]
9886
}
9987

10088
override func viewWillAppear(_ animated: Bool) {
10189
super.viewWillAppear(animated)
10290

10391
viewModel.updateName()
10492
}
93+
94+
override func subviews() -> [UIView] {
95+
return [
96+
titleLabel,
97+
nameLabel,
98+
numberLabel,
99+
updateButton,
100+
firstNameView,
101+
lastNameView
102+
]
103+
}
105104

106-
private func createConstraints() {
105+
override func bind() -> [Disposable] {
106+
return [
107+
viewModel.name ~> nameLabel.rx.text,
108+
viewModel.number ~> numberLabel.rx.text
109+
]
110+
}
111+
112+
override func createConstraints() {
107113

108114
titleLabel.snp.makeConstraints {
109115
$0.left.equalToSuperview().offset(Const.title.marginLeft)
@@ -135,7 +141,7 @@ class NameViewController: BaseViewController<NameViewModel> {
135141
lastNameView.snp.makeConstraints {
136142
$0.height.equalTo(Const.lastName.height)
137143
$0.left.right.equalToSuperview()
138-
$0.top.equalTo(firstNameViewController.view.snp.bottom).offset(Const.lastName.marginTop)
144+
$0.top.equalTo(firstNameView.snp.bottom).offset(Const.lastName.marginTop)
139145
}
140146

141147
}

0 commit comments

Comments
 (0)