0

I have medium the fidget with four buttons, each of the buttons open Deeplink with different tails, then I handle Deeplink inside SceneDelegate, but each time when I handle Deeplink inside SceneDelegate each Deeplink the identical why?

My code:

struct WidgetTestEntryView : View {
    var entry: Provider.Entry
    
    var deeplinkURLFirst: URL {
        URL(string: "widget-DeepLinkWidget://widgetFamily/0")!
    }
    var deeplinkURLSecond: URL {
        URL(string: "widget-DeepLinkWidget://widgetFamily/1")!
    }
    
    var deeplinkURLThird: URL {
        URL(string: "widget-DeepLinkWidget://widgetFamily/2")!
    }
    
    var deeplinkURLFourty: URL {
        URL(string: "widget-DeepLinkWidget://widgetFamily/3")!
    }
    
    var widgetLabel = "Favourites"

    var body: some View {
        
       
        
        VStack {
            HStack(spacing: 100){
                Text(widgetLabel).foregroundColor(.white).font(.system(size: 16, weight: .bold, design: .default)).offset(y: 2)
                Image("Label").resizable().frame(width: 80, height: 15, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
                
            }.frame(maxWidth: .infinity, maxHeight: 50, alignment: .center).background(Color.black).offset(y: -9)
            
            HStack {
                Spacer()
                Button(action: {}) {
                    
                    Image(imageFromAppGroup(key: "image0")).resizable().frame(width: 70, height: 70)
                        .cornerRadius(10)
                        .background(Color(red: 0.218, green: 0.215, blue: 0.25))
                    
                }.widgetURL(deeplinkURLFirst).cornerRadius(10)

                Button(action: {}) {
                    Image(imageFromAppGroup(key: "image1")).resizable().frame(width: 70, height: 70)
                        .cornerRadius(10)
                        .background(Color(red: 0.218, green: 0.215, blue: 0.25))
                }.widgetURL(deeplinkURLSecond).cornerRadius(10)

                Button(action: {}) {
                    Image(imageFromAppGroup(key: "image2")).resizable().frame(width: 70, height: 70)
                        .cornerRadius(10)
                        .background(Color(red: 0.218, green: 0.215, blue: 0.25))
                }.widgetURL(deeplinkURLThird).cornerRadius(10)

                Button(action: {}) {
                    Image(imageFromAppGroup(key: "image3")).resizable().frame(width: 70, height: 70)
                        .cornerRadius(10)
                        .background(Color(red: 0.218, green: 0.215, blue: 0.25))
                }.widgetURL(deeplinkURLFourty).cornerRadius(10)

                Spacer().frame(width: 10, height: 10, alignment: .center)
                
            }.background(Color(red: 0.118, green: 0.118, blue: 0.15)).offset(y: -9)
            
            
        }.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center).background(Color(red: 0.118, green: 0.118, blue: 0.15)).onAppear {
            print("I AM HERE !!!")
            
        }
    }
}

Console log:

widget-DeepLinkWidget://widgetFamily/3
widget-DeepLinkWidget://widgetFamily/3
widget-DeepLinkWidget://widgetFamily/3
widget-DeepLinkWidget://widgetFamily/3

Must to be:

widget-DeepLinkWidget://widgetFamily/0
widget-DeepLinkWidget://widgetFamily/1
widget-DeepLinkWidget://widgetFamily/2
widget-DeepLinkWidget://widgetFamily/3

The end of the index depends on a particular button.

Ice
  • 680
  • 1
  • 10
  • 23
  • 2
    use this Link(destination: deeplinkURLFirst, label: {your button view))/ insted of . widgetURL... – Raja Kishan Mar 02 '21 at 16:55
  • 1
    Yes, `widgetURL` covers the whole widget area and it should only be used once. If you want to have multiple tappable areas, you need to use `Link`. – pawello2222 Mar 02 '21 at 23:08

0 Answers0