Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ロック画面Widgetをサクッと実装してみた話
Search
aoi
February 21, 2023
Programming
3
430
ロック画面Widgetをサクッと実装してみた話
https://potatotips.connpass.com/event/272353/
aoi
February 21, 2023
Tweet
Share
More Decks by aoi
See All by aoi
モバイルアプリの行動ログの運用つらさ解消法 / mobile-log-troubleshooting
aomathwift
3
2.6k
OS 固有の新機能をサービスに取り入れ活用していくための Tips
aomathwift
0
63
DocC Documentation Archiveをアプリ開発で活用してみよう / DocC Documentation Archive for iOS Application
aomathwift
0
620
即時通知を導入する際に考えるべきこと
aomathwift
0
4.9k
機能ごとに動作するミニアプリでプレビューサイクルを爆速にした話 After Talk
aomathwift
0
510
機能ごとに動作するミニアプリでプレビューサイクルを爆速にした話
aomathwift
1
10k
Other Decks in Programming
See All in Programming
あまり知られていない MCP 仕様たち / MCP specifications that aren’t widely known
ktr_0731
0
220
リッチエディターを安全に開発・運用するために
unachang113
1
350
Claude Code で Astro blog を Pages から Workers へ移行してみた
codehex
0
170
No Install CMS戦略 〜 5年先を見据えたフロントエンド開発を考える / no_install_cms
rdlabo
0
430
Google I/O Extended Incheon 2025 ~ What's new in Android development tools
pluu
1
220
Comparing decimals in Swift Testing
417_72ki
0
160
CIを整備してメンテナンスを生成AIに任せる
hazumirr
0
510
副作用と戦う PHP リファクタリング ─ ドメインイベントでビジネスロジックを解きほぐす
kajitack
3
520
0から始めるモジュラーモノリス-クリーンなモノリスを目指して
sushi0120
0
250
Understanding Kotlin Multiplatform
l2hyunwoo
0
250
階層化自動テストで開発に機動力を
ickx
1
470
商品比較サービス「マイベスト」における パーソナライズレコメンドの第一歩
ucchiii43
0
270
Featured
See All Featured
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.8k
Testing 201, or: Great Expectations
jmmastey
45
7.6k
Rebuilding a faster, lazier Slack
samanthasiow
83
9.1k
A better future with KSS
kneath
238
17k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
8
420
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
8
870
The Art of Programming - Codeland 2020
erikaheidi
54
13k
The World Runs on Bad Software
bkeepers
PRO
70
11k
Adopting Sorbet at Scale
ufuk
77
9.5k
Designing Experiences People Love
moore
142
24k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
47
9.6k
A Tale of Four Properties
chriscoyier
160
23k
Transcript
ϩοΫը໘ Widget ΛαΫοͱ࣮ͯ͠Έͨ Aoi Okawa (@aomathwift) 2023/02/21 potatotips #81
ϩοΫը໘ Widgetʁ
ϩοΫը໘ Widget ͱ • iOS 16 ͔Β͑ΔϩοΫը໘ ΧελϚΠζػೳͷҰ෦ • AppleWatch
ͷίϯϓϦέʔ γϣϯͷΑ͏ͳ Widget
৽͍͠ WidgetFamily accessory Circular accessory Rectangular accessory Inline
࣮ํ๏ @main struct CookpadMartWidget: Widget { var body: some WidgetConfiguration
{ StaticConfiguration( kind: "DefaultWidget", provider: Provider() ) { entry in EntryView(entry: entry) } .supportedFamilies([.systemSmall, .accessoryCircular]) // ... } }
࣮ํ๏ 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") } } }
Cookpad Mart ͷ Widget ػೳ طʹಋೖࡁΈ🎉
ϩοΫը໘ Widget αΫοͱಋೖͰ͖ͦ͏💡
• accessoryRectangular ͱ accessoryCircular ͷ 2αΠζΛαϙʔτ • iOS Ͱͷར༻ͷΈΛఆ ࣮ͯ͠Έͨ
ಋೖͯ͠Έͨॴײ
• දࣔͰ͖Δใྔ͕ϗʔϜը ໘ Widget ʹൺͯগͳ͍ • ΞϓϦΛىಈ͢Δಈઢͱͯ͠ ͷ׆༻ʹৼΓΔͷ༗Γ දࣔίϯςϯπͷ͠͞
Inline ෆ࠾༻ • Rectangular Ҏ্ʹڝ૪͕ߴ͍ʢ1ͷΈʣ • ͷྡʹઃஔ͞ΕΔͷͰใ͕ຒΕ͍͢ ϚʔτΞϓϦͰड͚औΓ༧ఆΛදࣔ ͠Α͏ͱ͕ͨ͠ɺ࣌ࠁͷ্ʹ͕ೋͭ ฒͿͱ͍͏ݟ͕ͨෆࣗવա͗ͯ🥲
ར༻͞ΕͯΔʁ accessoryRectangular Λઃஔ͍ͯ͠ΔϢʔβʔͷׂ߹ 0.018% accessoryCircular Λઃஔ͍ͯ͠ΔϢʔβʔͷׂ߹ 0.10% (ࢀߟ) systemMedium Λઃஔͯ͠ΔϢʔβʔͷׂ߹
0.045% (ࢀߟ) systemSmall Λઃஔ͍ͯ͠ΔϢʔβʔͷׂ߹ 0.098%
ͬͯΒ͏ͷ͕͍͠ • ػೳͷଘࡏࣗମ͕ೝ͞Εʹ͍͘ • ͷڝ૪͕ߴ͗͢Δ • શ෦ͷαΠζ߹Θͤͯ࠷େͰ̑ • ݱঢ়ͷ͕ଟ͍ํ͕ͬͯΒ͑ͯΔ
Widget ར༻ͷϩάͷऔΓํ • WidgetCenter.getCurrentConfigurations • ઃஔ͞ΕͯΔ WidgetFamily ͕ྻͰฦΔ • ΞϓϦ͕ΞΫςΟϒʹͳΔʹ࠷৽Λૹ৴
ࠓޙͷ՝ • ػೳͷଘࡏͷೝΛ্͛Δ • ίϯςϯπͷϒϥογϡΞοϓ • LiveActivity ಋೖͯ͠ϩοΫը໘Ͱͷଘࡏײ ⬆