eas-widget-example icon indicating copy to clipboard operation
eas-widget-example copied to clipboard

[Question]: Lock Screen Widget

Open mariomurrent-softwaresolutions opened this issue 1 year ago • 4 comments

Maybe it's a dump question, but is it possible to use this widget as lockscreen widget as well?

@mariomurrent-softwaresolutions Yes I think this should also be possible. There are no extra configurations needed to add a widget to the lock screen so I don't see any problems. You should only add some new views which are designed to be used on the lock screen, and call them accordingly.

In the Apple Developer docs they provided an example: https://developer.apple.com/documentation/widgetkit/creating-lock-screen-widgets-and-watch-complications#Create-views-for-accessory-widgets

struct EmojiRangerWidgetEntryView: View {
    var entry: Provider.Entry
    
    @Environment(\.widgetFamily) var family

    @ViewBuilder
    var body: some View {
        switch family {
        case .accessoryInline:
            // Code to construct the view for the inline widget or watch complication.
        case .accessoryRectangular:
            // Code to construct the view for the rectangular Lock Screen widget or watch complication.
        case .accessoryCircular:
            // Code to construct the view for the circular Lock Screen widget or watch complication.
        case .systemSmall:
            // Code to construct the view for the small widget.
        default:
            // Code to construct the view for other widgets; for example, the system medium or large widgets.
        }
    }
}

aLemonFox avatar Apr 14 '23 07:04 aLemonFox

Very nice - i will try it out and let you know :)

@mariomurrent-softwaresolutions did this work?

rkstar avatar Oct 02 '23 18:10 rkstar

@mariomurrent-softwaresolutions did this work?

Since I’m using the EAS build in managed workflow, where should this code be added?