Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Major bug when onPress is called in a screen other than the root #23

Closed
vanlooverenkoen opened this issue Sep 14, 2022 · 1 comment
Closed

Comments

@vanlooverenkoen
Copy link

Add an onPress to the ListTemplate A Section

              CPListItem(
                text: "Item 1",
                onPress: (complete, self) {
                  print('Button Click');
                  complete();
                },
              ),

And you will see this behaviour.

Screen.Recording.2022-09-14.at.14.36.04.mov

I did some research. Turns out there is a major bug in the findItem method

  static func findItem(elementId: String, actionWhenFound: (_ item: FCPListItem) -> Void) {
    let objcRootTemplateType = String(describing: SwiftFlutterCarplayPlugin.objcRootTemplate).match(#"(.*flutter_carplay\.(.*)\))"#)[0][2]
    var templates: [FCPListTemplate] = []
    if (objcRootTemplateType.elementsEqual(String(describing: FCPListTemplate.self))) {
      templates.append(SwiftFlutterCarplayPlugin.objcRootTemplate as! FCPListTemplate)
      NSLog("FCP: FCPListTemplate")
    } else if (objcRootTemplateType.elementsEqual(String(describing: FCPTabBarTemplate.self))) {
      templates = (SwiftFlutterCarplayPlugin.objcRootTemplate as! FCPTabBarTemplate).getTemplates()
      NSLog("FCP: FCPTabBarTemplate")
    } else {
      NSLog("FCP: item not found 1: \(elementId)")
      return
    }
    for t in templates {
      for s in t.getSections() {
        for i in s.getItems() {
          NSLog("FCP: items: \(t.elementId) \(s.elementId) \(i.elementId)")
          if (i.elementId == elementId) {
            NSLog("FCP: item found: \(elementId)")
            actionWhenFound(i)
            return
          }
        }
      }
    }
    NSLog("FCP: item not found 2: \(elementId)")
  }

I added some logs. And these are the logs I got:

FCP: On Press Send event
FCP: SET ITEMS FOR: Optional("A Section"): items: 4
FCP: SET ITEMS FOR: Optional("B Section"): items: 2
FCP: SET ITEMS FOR: Optional("C Section"): items: 2
FCP: onListItemSelectedComplete: fb7982ac-12f4-4ddb-a315-69fcf9ffc789
FCP: FCPTabBarTemplate
FCP: GET ITEMS FOR: Optional("First Section"): items: 2
FCP: items: 300ef966-6cbb-4435-aebe-25e7dea0060f 51f17de1-ecc6-47f9-aed8-9a138ef19865 89283c2a-5e98-47eb-8f99-0c875098cfd6
FCP: items: 300ef966-6cbb-4435-aebe-25e7dea0060f 51f17de1-ecc6-47f9-aed8-9a138ef19865 6776af5d-4cb0-4572-a3cb-a4627ca29112
FCP: GET ITEMS FOR: Optional("Second Section"): items: 3
FCP: items: 300ef966-6cbb-4435-aebe-25e7dea0060f a6215f6c-5eb2-4b1a-8b0f-dc2739a8b188 0cb547b1-366e-47b8-bc5c-db6220bdeae4
FCP: items: 300ef966-6cbb-4435-aebe-25e7dea0060f a6215f6c-5eb2-4b1a-8b0f-dc2739a8b188 9759bd49-5366-45bf-b8a6-d72bf1dc44a1
FCP: items: 300ef966-6cbb-4435-aebe-25e7dea0060f a6215f6c-5eb2-4b1a-8b0f-dc2739a8b188 c577273f-520e-4816-ad18-bf6e7eb072f1
FCP: GET ITEMS FOR: Optional("Features"): items: 6
FCP: items: 6fb3dfc3-0112-418c-b5f7-90b7495d335f c7ee5afd-2770-4005-9a7e-7e22c30d33a4 084a1787-56e5-42d5-a2d8-02eafc0ce250
FCP: items: 6fb3dfc3-0112-418c-b5f7-90b7495d335f c7ee5afd-2770-4005-9a7e-7e22c30d33a4 153b464a-e856-46de-9f9d-f1dbd816381a
FCP: items: 6fb3dfc3-0112-418c-b5f7-90b7495d335f c7ee5afd-2770-4005-9a7e-7e22c30d33a4 eaf71ddf-d3af-4104-ac73-40314d257076
FCP: items: 6fb3dfc3-0112-418c-b5f7-90b7495d335f c7ee5afd-2770-4005-9a7e-7e22c30d33a4 fb7982ac-12f4-4ddb-a315-69fcf9ffc789
FCP: item found: fb7982ac-12f4-4ddb-a315-69fcf9ffc789
FCP: STOP HANDLER: fb7982ac-12f4-4ddb-a315-69fcf9ffc789

I also added a log to the onPress event that was send and in the onListItemSelectedComplete,
Also added logs to the init of the FCPListSection -> SET ITEMS FOR: ...
And to the getItems of FCPListSection -> GET ITEMS FOR: ...

Turns out that the FCPTabBarTemplate is retrieved instead of the FCPListTemplate.

Workaround

Just don't select anything for some time. (couple of seconds +/-10 - 20) And you will be able to select another item. (The spinner will stay there as long as you don't call the complet method

@vanlooverenkoen
Copy link
Author

Duplicate of #17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant