mukaschultze / nativescript-windowed-modal

Consistent modals for Android and iOS
https://www.npmjs.com/package/nativescript-windowed-modal
Apache License 2.0
47 stars 18 forks source link

Can't resolve all parameters for ModalDialogParams #20

Closed kfw9257 closed 4 years ago

kfw9257 commented 4 years ago

Make sure to check the demo app(s) for sample usage

Make sure to check the existing issues in this repository

If the demo apps cannot help and there is no issue for your problem, tell us about it

Please, ensure your title is less than 63 characters long and starts with a capital letter.

Which platform(s) does your issue occur on?

iOS iPhone 6s emulator

Please, provide the following version numbers that your issue occurs with:

Please, tell us how to recreate the issue in as much detail as possible.

Error occurs when I try running the app.

Is there any code involved?

Container component:

constructor(
      private store$: Store<fromDashboard.State>,
      private routerExtensions: RouterExtensions,
      private modalService: ModalDialogService,
      private vcRef: ViewContainerRef
    ) { ... }

  public onShowReceipt(receiptUrl: string) {
    console.log(receiptUrl);
    this.modalService.showModal(ReceiptModalComponent, {
      context: {
        receiptUrl
      },
      viewContainerRef: this.vcRef
    });
  }

Modal Component Template:

<ModalStack>
    <StackLayout>
        <Image [src]="receipt"></Image>
    </StackLayout>
    <button text="Close Modal" (tap)="onCloseModal()"></button>
</ModalStack>

Modal Component

import { ExtendedShowModalOptions } from 'nativescript-windowed-modal';

@Component({
  selector: 'ems-receipt-modal',
  templateUrl: './receipt-modal.component.html',
  styleUrls: ['./receipt-modal.component.scss']
})
export class ReceiptModalComponent implements OnInit {

  receipt = '';

  constructor(private params: ModalDialogParams) {

  }

  ngOnInit() {
  }

}

Feature Module (relevant code):

...
  providers: [
    ModalDialogParams
  ],
kfw9257 commented 4 years ago

Here's the error message I'm seeing:

***** Fatal JavaScript exception - application has been terminated. *****
Native stack trace:
1   0x10d10d0ee NativeScript::reportFatalErrorBeforeShutdown(JSC::ExecState*, JSC::Exception*, bool)
2   0x10d1482d8 NativeScript::FFICallback<NativeScript::ObjCMethodCallback>::ffiClosureCallback(ffi_cif*, void*, void**, void*)
3   0x10dad9672 ffi_closure_unix64_inner
4   0x10dada09a ffi_closure_unix64
5   0x7fff23ad3875 _CFXRegistrationPost1
6   0x7fff23ad35e1 ___CFXNotificationPost_block_invoke
7   0x7fff23bd1a33 -[_CFXNotificationRegistrar find:object:observer:enumerator:]
8   0x7fff23ad2f36 _CFXNotificationPost
9   0x7fff25676cb5 -[NSNotificationCenter postNotificationName:object:userInfo:]
10  0x7fff47571581 -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:]
11  0x7fff47576f6e -[UIApplication _runWithMainScene:transitionContext:completion:]
12  0x7fff46cbc3ed -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:]
13  0x7fff471a4aa9 _UIScenePerformActionsWithLifecycleActionMask
14  0x7fff46cbceff __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke
15  0x7fff46cbc90e -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:]
16  0x7fff46cbcd2c -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]
17  0x7fff46cbc5c1 -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:]
18  0x7fff46cc0bef __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke_2
19  0x7fff470ca9d7 +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:actions:completion:]
20  0x7fff471c2fa7 _UISceneSettingsDiffActionPerformChangesWithTransitionContext
21  0x7fff46cc090a __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke
22  0x7fff471c2eaa _UISceneSettingsDiffActionPerformActionsWithDelayForTransitionContext
23  0x7fff46cc0778 -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]
24  0x7fff46b1ac67 __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke
25  0x7fff46b197ec -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:]
26  0x7fff46b1a991 -[UIScene scene:didUpdateWithDiff:transitionContext:completion:]
27  0x7fff475755cb -[UIApplication workspace:didCreateScene:withTransitionContext:completion:]
28  0x7fff470ec535 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:]
29  0x7fff364e0361 -[FBSSceneImpl _callOutQueue_agent_didCreateWithTransitionContext:completion:]
30  0x7fff365065f8 __86-[FBSWorkspaceScenesClient sceneID:createWithParameters:transitionContext:completion:]_block_invoke.154
31  0x7fff364eae41 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:]
JavaScript stack trace:
_reportError(file:///node_modules/@angular/compiler/fesm5/compiler.js:21763:0)
at _getDependenciesMetadata(file:///node_modules/@angular/compiler/fesm5/compiler.js:21574:0)
at _getTypeMetadata(file:///node_modules/@angular/compiler/fesm5/compiler.js:21466:0)
at getProviderMetadata(file:///node_modules/@angular/compiler/fesm5/compiler.js:21698:0)
at file:///node_modules/@angular/compiler/fesm5/compiler.js:21636:0
at forEach([native code])
at _getProvidersMetadata(file:///node_modules/@angular/compiler/fesm5/compiler.js:21596:0)
at getNgModuleMetadata(file:///node_modules/@angular/compiler/fesm5/compiler.js:21314:52)
at _loadModules(file:///node_modules/@angular/compiler/fesm5/compiler.js:27376:0)
at _compileModuleAndComponents(file:///node_modules/@angular/compiler/fesm5/compiler.js:27357:0)
at compileModuleAsync(file:///node_modules/@angular/compiler/fesm5/compiler.js:27317:0)
at bootstrapModule(file:///node_modules/@angular/core/fesm5/core.js:26789:0)
at _bootstrapper(file:///node_modules/nativescript-angular/platform-common.js:89:0)
at file:///node_modules/nativescript-angular/platform-common.js:156:0
at notify(file:///node_modules/@nativescript/core/data/observable/observable.js:110:0)
at [native code]
at notifyAppStarted(file:///node_modules/@nativescript/core/application/application.js:172:0)
at didFinishLaunchingWithOptions(file:///node_modules/@nativescript/core/application/application.js:164:0)
at [native code]
at onReceive(file:///node_modules/@nativescript/core/application/application.js:37:0)
at UIApplicationMain([native code])
at _start(file:///node_modules/@nativescript/core/application/application.js:324:0)
at run(file:/<…>
JavaScript error:
file:///node_modules/@angular/compiler/fesm5/compiler.js:21763:0: JS ERROR Error: Can't resolve all parameters for ModalDialogParams: (?, ?).
NativeScript caught signal 11.
Native Stack:
1   0x10d155ff1 sig_handler(int)
2   0x7fff518c9b1d _sigtramp
3   0x800000000
4   0x7fff518fdb85 libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_x86_64>::step()
5   0x7fff51901e58 _Unwind_RaiseException
6   0x7fff4f6df8bd __cxa_throw
7   0x7fff50864c44 _objc_exception_destructor(void*)
8   0x10d10d572 NativeScript::reportFatalErrorBeforeShutdown(JSC::ExecState*, JSC::Exception*, bool)
9   0x10d1482d8 NativeScript::FFICallback<NativeScript::ObjCMethodCallback>::ffiClosureCallback(ffi_cif*, void*, void**, void*)
10  0x10dad9672 ffi_closure_unix64_inner
11  0x10dada09a ffi_closure_unix64
12  0x7fff23ad3875 _CFXRegistrationPost1
13  0x7fff23ad35e1 ___CFXNotificationPost_block_invoke
14  0x7fff23bd1a33 -[_CFXNotificationRegistrar find:object:observer:enumerator:]
15  0x7fff23ad2f36 _CFXNotificationPost
16  0x7fff25676cb5 -[NSNotificationCenter postNotificationName:object:userInfo:]
17  0x7fff47571581 -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:]
18  0x7fff47576f6e -[UIApplication _runWithMainScene:transitionContext:completion:]
19  0x7fff46cbc3ed -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:]
20  0x7fff471a4aa9 _UIScenePerformActionsWithLifecycleActionMask
21  0x7fff46cbceff __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke
22  0x7fff46cbc90e -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:]
23  0x7fff46cbcd2c -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]
24  0x7fff46cbc5c1 -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:]
25  0x7fff46cc0bef __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke_2
26  0x7fff470ca9d7 +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:actions:completion:]
27  0x7fff471c2fa7 _UISceneSettingsDiffActionPerformChangesWithTransitionContext
28  0x7fff46cc090a __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke
29  0x7fff471c2eaa _UISceneSettingsDiffActionPerformActionsWithDelayForTransitionContext
30  0x7fff46cc0778 -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]
31  0x7fff46b1ac67 __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke
JS Stack:
UIApplicationMain([native code])
at _start(file:///node_modules/@nativescript/core/application/application.js:324:0)
at run(file:///node_modules/@nativescript/core/application/application.js:366:0)
at bootstrapNativeScriptApp(file:///node_modules/nativescript-angular/platform-common.js:210:0)
at bootstrapApp(file:///node_modules/nativescript-angular/platform-common.js:111:0)
at bootstrapModule(file:///node_modules/nativescript-angular/platform-common.js:91:0)
at file:///app/bundle.js:10928:144
at ./main.ts(file:///app/bundle.js:10933:34)
at __webpack_require__(file:///src/webpack/bootstrap:753:0)
at checkDeferredModules(file:///src/webpack/bootstrap:43:0)
at webpackJsonpCallback(file:///src/webpack/bootstrap:30:0)
at anonymous(file:///app/bundle.js:2:61)
at evaluate([native code])
at moduleEvaluation
at promiseReactionJob
edusperoni commented 4 years ago

Closing as it's not related to this plugin:

this is wrong:

...
  providers: [
    ModalDialogParams
  ],

correct:

providers: [
        ModalDialogService,
    ]

https://github.com/NativeScript/nativescript-angular/issues/1758

kfw9257 commented 4 years ago

Closing as it's not related to this plugin:

this is wrong:

...
  providers: [
    ModalDialogParams
  ],

correct:

providers: [
        ModalDialogService,
    ]

NativeScript/nativescript-angular#1758

The problem is I'm getting an error if I try to run it now:

CONSOLE ERROR [native code]: ERROR NullInjectorError: StaticInjectorError(AppModule)[ReceiptModalComponent -> ModalDialogParams]:
StaticInjectorError(Platform: core)[ReceiptModalComponent -> ModalDialogParams]:
NullInjectorError: No provider for ModalDialogParams!
CONSOLE ERROR [native code]: ERROR CONTEXT {
"view": {
"def": {
"nodeFlags": 33669121,
"rootNodeFlags": 33554433,
"nodeMatchedQueries": 0,
"flags": 0,
"nodes": [
{
"nodeIndex": 0,
"parent": null,
"renderParent": null,
"bindingIndex": 0,
"outputIndex": 0,
"checkIndex": 0,
"flags": 33554433,
"childFlags": 114688,
"directChildFlags": 114688,
"childMatchedQueries": 0,
"matchedQueries": {},
"matchedQueryIds": 0,
"references": {},
"ngContentIndex": null,
"childCount": 1,
"bindings": [],
"bindingFlags": 0,
"outputs": [],
"element": {
"ns": "",
"name": "ems-receipt-modal",
"attrs": [],
"template": null,
"componentProvider": {
"nodeIndex": 1,
"parent": "[Circular]",
"renderParent<…>
edusperoni commented 4 years ago

I can't help without the full code. As I said in the other issue, this error only happens when you try to load the component without calling showModal as the token is injected by the method, so it's impossible for this error to occur with you construct the component using showModal

kfw9257 commented 4 years ago

Thanks for that info! I was able to determine the issue was with bootstrapping the component in the wrong module. It's working now.