@@ -129,38 +129,6 @@ class PureViewController(
129129 })
130130 }
131131
132- init {
133- globalMainScope.launch {
134- waitInit()
135- val rootView = uiViewControllerInMain.view
136- boundsFlow.combine(viewAppearFlow) { bounds, viewAppear ->
137- bounds to rootView.superview
138- }.collect { (bounds, parentView) ->
139- withMainContext {
140- setBoundsInMain(bounds, rootView, parentView)
141- }
142- }
143- }
144- }
145-
146- init {
147- nativeViewController.onInitSignal.listen {
148- if (it == vcId) {
149- offListener()
150- isAdded = true
151- initDeferred.complete(Unit )
152- }
153- }
154- nativeViewController.onDestroySignal.listen {
155- if (it == vcId) {
156- destroySignal.emit()
157- isAdded = false
158- lifecycleScope.cancel(CancellationException (" viewController destroyed" ))
159- lifecycleScope = CoroutineScope (mainAsyncExceptionHandler + SupervisorJob ())
160- }
161- }
162- }
163-
164132 override var lifecycleScope = CoroutineScope (mainAsyncExceptionHandler + SupervisorJob ())
165133 private set
166134
@@ -196,6 +164,38 @@ class PureViewController(
196164 private val scope = nativeViewController.scope
197165
198166
167+ init {
168+ globalMainScope.launch {
169+ waitInit()
170+ val rootView = uiViewControllerInMain.view
171+ boundsFlow.combine(viewAppearFlow) { bounds, viewAppear ->
172+ bounds to rootView.superview
173+ }.collect { (bounds, parentView) ->
174+ withMainContext {
175+ setBoundsInMain(bounds, rootView, parentView)
176+ }
177+ }
178+ }
179+ }
180+
181+ init {
182+ nativeViewController.onInitSignal.listen {
183+ if (it == vcId) {
184+ offListener()
185+ isAdded = true
186+ initDeferred.complete(Unit )
187+ }
188+ }
189+ nativeViewController.onDestroySignal.listen {
190+ if (it == vcId) {
191+ destroySignal.emit()
192+ isAdded = false
193+ lifecycleScope.cancel(CancellationException (" viewController destroyed" ))
194+ lifecycleScope = CoroutineScope (mainAsyncExceptionHandler + SupervisorJob ())
195+ }
196+ }
197+ }
198+
199199 private val uiViewControllerDelegate = object : ComposeUIViewControllerDelegate {
200200 // 视图被加载后立即调用
201201 override fun viewDidLoad () {
0 commit comments