@@ -175,9 +175,9 @@ open class TabsController: TransitionController {
175
175
view. backgroundColor = . white
176
176
view. contentScaleFactor = Screen . scale
177
177
178
- prepareSelectedIndexViewController ( )
179
178
prepareTabBar ( )
180
179
prepareTabItems ( )
180
+ prepareSelectedIndexViewController ( )
181
181
}
182
182
183
183
open override func transition( to viewController: UIViewController , completion: ( ( Bool ) -> Void ) ? ) {
@@ -193,53 +193,40 @@ fileprivate extension TabsController {
193
193
- Parameter completion: An optional completion block.
194
194
*/
195
195
func transition( to viewController: UIViewController , isTriggeredByUserInteraction: Bool , completion: ( ( Bool ) -> Void ) ? ) {
196
- guard let fvc = rootViewController else {
197
- return
198
- }
199
-
200
- guard let fvcIndex = viewControllers. index ( of: fvc) else {
196
+ guard let fvcIndex = viewControllers. index ( of: rootViewController) else {
201
197
return
202
198
}
203
199
204
- let tvc = viewController
205
-
206
- guard let tvcIndex = viewControllers. index ( of: tvc) else {
200
+ guard let tvcIndex = viewControllers. index ( of: viewController) else {
207
201
return
208
202
}
209
203
210
204
var isAuto = false
211
205
212
- switch tvc . motionModalTransitionType {
206
+ switch viewController . motionModalTransitionType {
213
207
case . auto:
214
208
isAuto = true
215
209
viewController. motionModalTransitionType = fvcIndex < tvcIndex ? . slide( direction: . left) : . slide( direction: . right)
216
210
default : break
217
211
}
218
212
219
- prepare ( viewController: tvc, in: container)
220
-
221
213
if isTriggeredByUserInteraction {
222
214
delegate? . tabsController ? ( tabsController: self , willSelect: viewController)
223
215
}
224
216
225
- view. isUserInteractionEnabled = false
226
-
227
- Motion . shared. transition ( from: fvc, to: viewController, in: container) { [ weak self, tvc = tvc, isAuto = isAuto, completion = completion] ( isFinished) in
217
+ super. transition ( to: viewController) { [ weak self, isAuto = isAuto, viewController = viewController, completion = completion] ( isFinished) in
228
218
guard let s = self else {
229
219
return
230
220
}
231
221
232
222
if isAuto {
233
- tvc . motionModalTransitionType = . auto
223
+ viewController . motionModalTransitionType = . auto
234
224
}
235
225
236
- s. rootViewController = tvc
237
- s. view. isUserInteractionEnabled = true
238
-
239
226
completion ? ( isFinished)
240
227
241
228
if isTriggeredByUserInteraction {
242
- s. delegate? . tabsController ? ( tabsController: s, didSelect: tvc )
229
+ s. delegate? . tabsController ? ( tabsController: s, didSelect: viewController )
243
230
}
244
231
}
245
232
}
0 commit comments