Skip to content

Commit

Permalink
add: accessoryInline barebones
Browse files Browse the repository at this point in the history
  • Loading branch information
s8ngyu authored and sboh1214 committed Jul 30, 2023
1 parent 96198c6 commit 8a28b66
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 0 deletions.
53 changes: 53 additions & 0 deletions ios/OTLWidgets/LocationInlineAccessory.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//
// LocationInlineAccessory.swift
// OTLWidgetsExtension
//
// Created by Soongyu Kwon on 28/07/2023.
// Copyright © 2023 The Chromium Authors. All rights reserved.
//

import WidgetKit
import SwiftUI
import Intents

@available(iOSApplicationExtension 16.0, *)
struct LocationInlineAccessoryEntryView : View {
@Environment(\.widgetFamily) var widgetFamily
var entry: Provider.Entry

var body: some View {
switch widgetFamily {
case .accessoryInline:
HStack {
Image(systemName: "tablecells")
Text("(E11 303) 프로그래밍기초")
}

default:
Text("Not Implemented")
}
}
}


@available(iOSApplicationExtension 16.0, *)
struct LocationInlineAccessory: Widget {
let kind: String = "LocationInlineAccessory"

var body: some WidgetConfiguration {
IntentConfiguration(kind: kind, intent: ConfigurationIntent.self, provider: Provider()) { entry in
LocationInlineAccessoryEntryView(entry: entry)
}
.configurationDisplayName("다음 수업과 장소")
.description("다음 수업과 장소를 확인합니다.")
.supportedFamilies([.accessoryInline])
}
}

@available(iOSApplicationExtension 16.0, *)
struct LocationInlineAccessoryPreviews: PreviewProvider {
static var previews: some View {
LocationInlineAccessoryEntryView(entry: WidgetEntry(date: Date(), timetableData: nil, configuration: ConfigurationIntent()))
.previewContext(WidgetPreviewContext(family: .accessoryInline))
}
}
2 changes: 2 additions & 0 deletions ios/OTLWidgets/OTLWidgetBundle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ struct OTLWidgetBundle : WidgetBundle {
// Lock Complications accessories for iOS 16+
if #available(iOSApplicationExtension 16.0, *) {
NextClassAccessory()
TimeInlineAccessory()
LocationInlineAccessory()
}
}
}
53 changes: 53 additions & 0 deletions ios/OTLWidgets/TimeInlineAccessory.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//
// TimeInlineAccessory.swift
// OTLWidgetsExtension
//
// Created by Soongyu Kwon on 28/07/2023.
// Copyright © 2023 The Chromium Authors. All rights reserved.
//

import WidgetKit
import SwiftUI
import Intents

@available(iOSApplicationExtension 16.0, *)
struct TimeInlineAccessoryEntryView : View {
@Environment(\.widgetFamily) var widgetFamily
var entry: Provider.Entry

var body: some View {
switch widgetFamily {
case .accessoryInline:
HStack {
Image(systemName: "tablecells")
Text("10:30 프로그래밍기초")
}

default:
Text("Not Implemented")
}
}
}


@available(iOSApplicationExtension 16.0, *)
struct TimeInlineAccessory: Widget {
let kind: String = "TimeInlineAccessory"

var body: some WidgetConfiguration {
IntentConfiguration(kind: kind, intent: ConfigurationIntent.self, provider: Provider()) { entry in
TimeInlineAccessoryEntryView(entry: entry)
}
.configurationDisplayName("다음 수업과 시간")
.description("다음 수업과 시간을 확인합니다.")
.supportedFamilies([.accessoryInline])
}
}

@available(iOSApplicationExtension 16.0, *)
struct TimeInlineAccessoryPreviews: PreviewProvider {
static var previews: some View {
TimeInlineAccessoryEntryView(entry: WidgetEntry(date: Date(), timetableData: nil, configuration: ConfigurationIntent()))
.previewContext(WidgetPreviewContext(family: .accessoryInline))
}
}
8 changes: 8 additions & 0 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
8BB3DE0B29D1F25B001AD191 /* Configuration.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = 8BB3DE0729D1F25B001AD191 /* Configuration.intentdefinition */; };
8BB3DE0C29D1F25B001AD191 /* Configuration.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = 8BB3DE0729D1F25B001AD191 /* Configuration.intentdefinition */; };
8BB3DE0F29D1F25B001AD191 /* OTLWidgetsExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 8BB3DDFD29D1F25A001AD191 /* OTLWidgetsExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
8BB4F62D2A73D4E700C8FE1D /* TimeInlineAccessory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BB4F62C2A73D4E700C8FE1D /* TimeInlineAccessory.swift */; };
8BB4F62F2A73DD2700C8FE1D /* LocationInlineAccessory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BB4F62E2A73DD2700C8FE1D /* LocationInlineAccessory.swift */; };
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
Expand Down Expand Up @@ -112,6 +114,8 @@
8BB3DE0829D1F25B001AD191 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
8BB3DE0A29D1F25B001AD191 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
8BB3DE4729D1F286001AD191 /* OTLWidgetsExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = OTLWidgetsExtension.entitlements; sourceTree = "<group>"; };
8BB4F62C2A73D4E700C8FE1D /* TimeInlineAccessory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimeInlineAccessory.swift; sourceTree = "<group>"; };
8BB4F62E2A73DD2700C8FE1D /* LocationInlineAccessory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationInlineAccessory.swift; sourceTree = "<group>"; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -190,6 +194,8 @@
8B76C8E32A0E834A007E1947 /* TodayClassesWidget.swift */,
8B1EA3B72A0FFF3B00387753 /* WeekClassesWidget.swift */,
8B643C822A6BC16500BF6DAA /* NextClassAccessory.swift */,
8BB4F62C2A73D4E700C8FE1D /* TimeInlineAccessory.swift */,
8BB4F62E2A73DD2700C8FE1D /* LocationInlineAccessory.swift */,
8B76C8E52A0E837F007E1947 /* WidgetBase.swift */,
8BB3DE0729D1F25B001AD191 /* Configuration.intentdefinition */,
8BB3DE0829D1F25B001AD191 /* Assets.xcassets */,
Expand Down Expand Up @@ -556,10 +562,12 @@
8B1EA3B82A0FFF3B00387753 /* WeekClassesWidget.swift in Sources */,
8BB3DE0429D1F25B001AD191 /* OTLWidgetBundle.swift in Sources */,
8B76C8E62A0E837F007E1947 /* WidgetBase.swift in Sources */,
8BB4F62F2A73DD2700C8FE1D /* LocationInlineAccessory.swift in Sources */,
8BB3458E2A012CF0008A0E30 /* IntentHandler.swift in Sources */,
8B76C8E42A0E834A007E1947 /* TodayClassesWidget.swift in Sources */,
8BB3DE0629D1F25B001AD191 /* NextClassWidget.swift in Sources */,
8B643C832A6BC16500BF6DAA /* NextClassAccessory.swift in Sources */,
8BB4F62D2A73D4E700C8FE1D /* TimeInlineAccessory.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down

0 comments on commit 8a28b66

Please sign in to comment.