Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥

ロック画面Widgetをサクッと実装してみた話

aoi
February 21, 2023

 ロック画面Widgetをサクッと実装してみた話

aoi

February 21, 2023
Tweet

More Decks by aoi

Other Decks in Programming

Transcript

  1. ࣮૷ํ๏ @main struct CookpadMartWidget: Widget { var body: some WidgetConfiguration

    { StaticConfiguration( kind: "DefaultWidget", provider: Provider() ) { entry in EntryView(entry: entry) } .supportedFamilies([.systemSmall, .accessoryCircular]) // ... } }
  2. ࣮૷ํ๏ struct EntryView : View { @Environment(\.widgetFamily) var family var

    entry: Provider.Entry var body: some View { switch family { case .systemSmall: SmallView(entry: entry) case .accessoryCircular: CircularView(entry: entry) // ... @unknown default: Text("default") } } }