Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
20201009 iOS 14 ウィジェットをつくってみた
Kei Ito
October 09, 2020
Programming
1
1.3k
20201009 iOS 14 ウィジェットをつくってみた
Kei Ito
October 09, 2020
Tweet
Share
More Decks by Kei Ito
See All by Kei Ito
20211015 Mac CatalystでmacOS用アプリを作る
itok
2
2.7k
20210219 Flutterに入門してみた
itok
1
2.7k
20191206 Property Wrappers 入門
itok
0
860
20190920 iOS 13 対応ではまった話
itok
1
1.7k
20190726 Background App Refresh Taskがやってきた
itok
0
1.4k
20190722 Firebase Remote Configでアドネットワークを管理する
itok
0
1.1k
20190419 iOSアプリで証明書の情報を参照する
itok
0
1k
20190412 Android TV向けアプリを作ってみる
itok
0
790
20190215 iOS/Androidでドキュメントスキャナーを作ってみた
itok
0
1.3k
Other Decks in Programming
See All in Programming
About Type Syntax Proposal
quramy
1
1.2k
dbtとBigQueryで始めるData Vault入門
kazk1018
0
180
microCMS × Shopifyで、ECサイトがリニューアル後急成長した話
microcms
0
470
Node.js 最新動向 TFCon 2022
yosuke_furukawa
PRO
6
2.9k
From Java 11 to 17 and beyond
josepaumard
0
300
偏見と妄想で語るスクリプト言語としての Swift / Swift as a Scripting Language
lovee
2
270
How useEvent would change our applications
koba04
1
1.7k
近況PHP / PHP in now a days
uzulla
4
1.8k
UI State Modeling 어떤게 좋을까?
laco2951
1
230
Swift Concurrencyによる安全で快適な非同期処理
tattn
2
320
未経験QAの私が、よきQA(Question Asker) になっていく物語
atamaplus
0
200
Is Rust a great language for building Kubernetes ecosystem
deepu105
0
150
Featured
See All Featured
StorybookのUI Testing Handbookを読んだ
zakiyama
4
2k
Principles of Awesome APIs and How to Build Them.
keavy
113
15k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
119
28k
Making the Leap to Tech Lead
cromwellryan
113
6.9k
Robots, Beer and Maslow
schacon
152
7.1k
Fontdeck: Realign not Redesign
paulrobertlloyd
73
4.1k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
181
15k
Optimizing for Happiness
mojombo
365
63k
Designing for Performance
lara
596
63k
A designer walks into a library…
pauljervisheath
196
16k
How GitHub (no longer) Works
holman
296
140k
YesSQL, Process and Tooling at Scale
rocio
157
12k
Transcript
J04ΟδΣοτΛ ͭͬͯ͘Έͨ .PCJMF"DU0/-*/& JUPL!ͦΒ͔ͥ
JUPL!ͦΒ͔ͥ w ͍ͱ͏͚͍ʢJUPLʣ w ɹɹɹɹɹɹͷதͷਓ w ϞόΠϧΞϓϦΤϯδχΞ݉$&0 w ෭ۀͰϑϦʔϥϯεత w
IUUQTJUPLKQ IUUQTTPSBLB[FDPKQ !JUPLKQ
ॴࡏɿژࢢதژ۠ ࣾһਓࣗ
࣮ डୗ ࣗࣾ
J04"OESPJENBD048JOEPXTαʔό ҰਓͰͬͯ·͢ʢσβΠϯҎ֎ʣ
iOS൛ v10.0.0
None
J04 ΟδΣοτΛ ͭͬͯ͘Έͨ
·ͣҙࣄ߲
4XJGU6*ඞਢ
6*,JU͑·ͤΜ
6*7JFX3FQSFTFOUBCMFΛ ͏ͱ͜͏ͳΔ
ࢀߟ w 88%$ w 8JEHFU,JUʹ͍ͭͯ w 8JEHFU$PEF"MPOHʙ
ΟδΣοτͷछྨ
TNBMM NFEJVN MBSHF ֎ݟ ૢ࡞ શମλοϓͷΈ શମ ҙͷྖҬλοϓ
ૢ࡞ w શମλοϓ w ҙͷྖҬλοϓ { }.widgetURL(url) Link(destination: url) {
}
جຊߏ 8JEHFU 8JEHFU$POpHVSBUJPO 5JNFMJOF1SPWJEFS 7JFX 5JNFMJOF&OUSZ
جຊߏ struct MyWidget: Widget { public var body: some WidgetConfiguration
{ StaticConfiguration(kind: kind, provider: MyProvider()) { entry in MyWidgetEntryView(entry: entry) } } } struct MyProvider: TimelineProvider { func getTimeline(in context: Context, completion: @escaping (Timeline<MyEntry>) -> Void) { ... completion(Timeline(entries: entries, policy: .atEnd)) } } struct MyWidgetEntryView : View { var entry: MyEntry var body: some View { ... } }
ઃఆʢTUBUJDʣ͋Γ 8JEHFU 8JEHFU$POpHVSBUJPO *OUFOU 7JFX 5JNFMJOF&OUSZ 5JNFMJOF1SPWJEFS
ઃఆʢEZOBNJDʣ͋Γ 8JEHFU 8JEHFU$POpHVSBUJPO *OUFOU 7JFX 5JNFMJOF&OUSZ 5JNFMJOF1SPWJEFS *OUFOU&YUFOTJPO
ઃఆ͋Γ struct MyWidget: Widget { public var body: some WidgetConfiguration
{ IntentConfiguration(kind: kind, intent: MySelectionIntent.self, provider: MyIntentProvider()) { entry in MyWidgetEntryView(entry: entry) } } } struct MyIntentProvider: IntentTimelineProvider { func getTimeline(for configuration: MySelectionIntent, in context: Context, completion: @escaping (Timeline<MyEntry>) -> Void) { ... completion(Timeline(entries: entries, policy: .after(date))) } }
IntentHandler.swift class IntentHandler: INExtension, MySelectionIntentHandling { func provideParameterOptionsCollection( for intent:
MySelectionIntent, with completion: @escaping (INObjectCollection<MyType>?, Error?) -> Void) { completion(INObjectCollection(items: items), nil) } *OUFOU&YUFOTJPO .Z4FMFDUJPOJOUFOUEFpOJUJPO
ߋ৽ public struct TimelineReloadPolicy : Equatable { // entries͕શ෦ऴΘͬͨΒߋ৽ public
static let atEnd: TimelineReloadPolicy // ߋ৽͠ͳ͍ public static let never: TimelineReloadPolicy // ࢦఆ࣌ؒʹߋ৽ public static func after(_ date: Date) -> TimelineReloadPolicy } // ΞϓϦଆ͔Βߋ৽Λଅ͢͜ͱ WidgetCenter.shared.reloadAllTimelines() ࣮ࡍͷߋ৽λΠϛϯά ࠷ऴతʹ04͕͍͍ײ͡ʹௐ͢ΔͷͰҙ
ෳΟδΣοτ 8JEHFU#VOEMF 8JEHFUᶄ 8JEHFUᶃ *OUFOU&YUFOTJPO @main struct Bundle: WidgetBundle {
@WidgetBundleBuilder var body: some Widget { Widget1() Widget2() } }
͍͞͝ʹ w ΟδΣοτରԠ͍ͯ͜͠͏ʂ w ͰΞϓϦຊମͷ༠ಋେࣄʁʢϏδωεతʹʣ w ΄ͲΑ͍ใͷόϥϯε۩߹ΛݟۃΊͯ