Skip to content

Commit

Permalink
Fix/#227 (#235)
Browse files Browse the repository at this point in the history
* [Setting] Widget Extension 타겟 추가

* [Setting] Widget match identifier 주석 해제

* [Feat] ArrivalInfoWidget 추가

* [Remove] 레거시 위젯 제거 ArrivalInfoWidget로 대체

* [Chore] 위젯뷰 경로 수정

* [Add] RefreshView Preview 추가

* [Fix] 주변정류장 위젯 이름 / 설명 추가

* [Feat] ArrivalInfoIntent 동적 파라미터 추가

* [Fix] DynamicOptionsProvider defaultResult 추가

* [Chore] NearByStopView 경로 수정

* [Fix] widgetBackground 인자 기본값 추가

* [Setting] Widget Extension Resources 경로 수정

* [Setting] 빌드버전 한국기준으로 고정

* [Setting] CI/CD OS, Xcode, Swift 버전 수정

* [Setting] 빌드 테스트 Scheme App으로 수정
  • Loading branch information
gnksbm authored Apr 15, 2024
1 parent 6ca54b9 commit c814b4d
Show file tree
Hide file tree
Showing 19 changed files with 226 additions and 77 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/pull_request_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
build_test:
runs-on: macos-13
runs-on: macos-14
steps:
- uses: actions/checkout@v2

Expand All @@ -21,11 +21,12 @@ jobs:
- name: Setup Xcode version
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: "14.3"
xcode-version: "15.3"

- uses: swift-actions/setup-swift@65540b95f51493d65f5e59e97dcef9629ddf11bf
- name: Setup Swift Version
uses: swift-actions/setup-swift@v2
with:
swift-version: "5.8.0"
swift-version: "5.10"

- name: Get swift version
run: swift --version
Expand All @@ -43,4 +44,4 @@ jobs:
run: tuist fetch

- name: Tuist Build Test
run: tuist build
run: tuist build App
9 changes: 5 additions & 4 deletions .github/workflows/upload_testflight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
upload_testflight:
runs-on: macos-13
runs-on: macos-14
steps:
- uses: actions/checkout@v2

Expand All @@ -30,11 +30,12 @@ jobs:
- name: Setup Xcode version
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: "14.3"
xcode-version: "15.3"

- uses: swift-actions/setup-swift@65540b95f51493d65f5e59e97dcef9629ddf11bf
- name: Setup Swift Version
uses: swift-actions/setup-swift@v2
with:
swift-version: "5.8.0"
swift-version: "5.10"

- name: Install Tuist
run: curl -Ls https://install.tuist.io|bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public extension String {
let date = Date()
let formatter = DateFormatter()
formatter.dateFormat = "yyyy.MM.dd.HH.mm"
formatter.locale = Locale(identifier: "ko_KR")
return formatter.string(from: date)
}
}
Expand Down
40 changes: 20 additions & 20 deletions Projects/App/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,26 @@ let project = Project.makeProject(
entitlementsPath: .relativeToManifest("App.entitlements"),
hasResource: true,
appExtensionTarget: [
// Project.appExtensionTarget(
// name: "Widget",
// plist: .extendingDefault(
// with: .widgetInfoPlist
// ),
// resources: [
// "Resources/Model.xcdatamodeld",
// "Resources/total_stationList.json",
// "Widget/Resources/**",
// ],
// entitlements: .file(
// path: .relativeToRoot(
// "Projects/App/Widget.entitlements"
// )
// ),
// dependencies: [
// .mainFeature,
// .data,
// ]
// )
Project.appExtensionTarget(
name: "Widget",
plist: .extendingDefault(
with: .widgetInfoPlist
),
resources: [
"Resources/Model.xcdatamodeld",
"Resources/total_stationList.json",
"Widget/Resources/**",
],
entitlements: .file(
path: .relativeToRoot(
"Projects/App/Widget.entitlements"
)
),
dependencies: [
.mainFeature,
.data,
]
)
],
packages: [
.remote(
Expand Down
2 changes: 2 additions & 0 deletions Projects/App/Widget/ArrivalInfo/ArrivalInfoProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct ArrivalInfoProvider: AppIntentTimelineProvider {
responses: useCase.responses
)
}

func snapshot(
for configuration: ArrivalInfoIntent,
in context: Context
Expand All @@ -33,6 +34,7 @@ struct ArrivalInfoProvider: AppIntentTimelineProvider {
responses: useCase.responses
)
}

func timeline(
for configuration: ArrivalInfoIntent,
in context: Context
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
//
// ArrivalInfoMediumWidget.swift
// ArrivalInfoWidget.swift
// Widget
//
// Created by gnksbm on 4/12/24.
// Created by gnksbm on 4/13/24.
// Copyright © 2024 Pepsi-Club. All rights reserved.
//

import WidgetKit
import SwiftUI

@available(iOS 17.0, *)
struct ArrivalInfoMediumWidget: Widget {
let kind: String = "ArrivalInfoMedium"
struct ArrivalInfoWidget: Widget {
let kind: String = "ArrivalInfo"

var body: some WidgetConfiguration {
AppIntentConfiguration(
kind: kind,
intent: ArrivalInfoIntent.self,
provider: ArrivalInfoProvider()
) { entry in
ArrivalInfoMediumView(
ArrivalInfoView(
entry: entry
)
}
.supportedFamilies([.systemMedium])
.supportedFamilies([
.systemSmall,
.systemMedium
])
.configurationDisplayName("즐겨찾기")
.description("실시간 도착정보를 확인할 수 있어요")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import AppIntents
@available(iOS 17.0, *)
struct ArrivalInfoIntent: WidgetConfigurationIntent {
static var title: LocalizedStringResource = "Configuration"
static var description = IntentDescription("This is an example widget.")

// An example configurable parameter.
@Parameter(title: "Favorite Emoji", default: "😃")
var favoriteEmoji: String
@Parameter(title: "정류장", optionsProvider: BusStopOptionProvider())
var busStop: String
@Parameter(title: "버스", optionsProvider: BusOptionProvider())
var bus: String
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// BusOptionProvider.swift
// AppUITests
//
// Created by gnksbm on 4/13/24.
// Copyright © 2024 Pepsi-Club. All rights reserved.
//

import AppIntents

import CoreDataService
import Domain

struct BusOptionProvider: DynamicOptionsProvider {
// let coreDataService = DefaultCoreDataService()
func defaultResult() async -> String? {
""
}

func results() async throws -> [String] {
// let responses = try coreDataService.fetch(
// type: FavoritesBusStopResponse.self
// )
// return responses.flatMap { $0.busIds }
[]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// BusStopOptionProvider.swift
// AppUITests
//
// Created by gnksbm on 4/13/24.
// Copyright © 2024 Pepsi-Club. All rights reserved.
//

import AppIntents

import CoreDataService
import Domain

struct BusStopOptionProvider: DynamicOptionsProvider {
// let coreDataService = DefaultCoreDataService()
func defaultResult() async -> String? {
""
}

func results() async throws -> [String] {
// let responses = try coreDataService.fetch(
// type: FavoritesBusStopResponse.self
// )
// return responses.map { $0.busStopId }
[]
}
}
28 changes: 0 additions & 28 deletions Projects/App/Widget/ArrivalInfo/Small/ArrivalInfoSmallWidget.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ struct ArrivalInfoMediumView: View {
arrivalInfoView
}
}
.widgetBackground(Color.white)
.widgetURL(url)
}

Expand Down Expand Up @@ -83,13 +82,24 @@ struct ArrivalInfoMediumView: View {
@available(iOS 17.0, *)
struct ArrivalInfoMediumView_Preview: PreviewProvider {
static var previews: some View {
ArrivalInfoMediumView(
entry: ArrivalInfoEntry(
date: .now,
configuration: .init()
)
)
.widgetBackground()
.previewContext(
WidgetPreviewContext(family: .systemMedium)
)
ArrivalInfoMediumView(
entry: ArrivalInfoEntry(
date: .now,
configuration: .init(),
responses: .mock
)
)
.widgetBackground()
.previewContext(
WidgetPreviewContext(family: .systemMedium)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ struct ArrivalInfoSmallView: View {
arrivalInfoView
}
}
.widgetBackground(Color.white)
.widgetURL(url)
}

Expand Down Expand Up @@ -84,13 +83,24 @@ struct ArrivalInfoSmallView: View {
@available(iOS 17.0, *)
struct ArrivalInfoSmallView_Preview: PreviewProvider {
static var previews: some View {
ArrivalInfoSmallView(
entry: ArrivalInfoEntry(
date: .now,
configuration: .init()
)
)
.widgetBackground()
.previewContext(
WidgetPreviewContext(family: .systemSmall)
)
ArrivalInfoSmallView(
entry: ArrivalInfoEntry(
date: .now,
configuration: .init(),
responses: .mock
)
)
.widgetBackground()
.previewContext(
WidgetPreviewContext(family: .systemSmall)
)
Expand Down
60 changes: 60 additions & 0 deletions Projects/App/Widget/ArrivalInfo/View/ArrivalInfoView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
//
// ArrivalInfoView.swift
// Widget
//
// Created by gnksbm on 4/13/24.
// Copyright © 2024 Pepsi-Club. All rights reserved.
//

import SwiftUI
import WidgetKit

@available (iOS 17.0, *)
struct ArrivalInfoView: View {
var entry: ArrivalInfoProvider.Entry
@Environment(\.widgetFamily) var widgetFamily

var body: some View {
view.widgetBackground(Color.white)
}

@ViewBuilder
var view: some View {
switch widgetFamily {
case .systemSmall:
ArrivalInfoSmallView(entry: entry)
case .systemMedium:
ArrivalInfoMediumView(entry: entry)
default:
EmptyView()
}
}
}

#if DEBUG
@available(iOS 17.0, *)
struct ArrivalInfoView_Preview: PreviewProvider {
static var previews: some View {
ArrivalInfoView(
entry: ArrivalInfoEntry(
date: .now,
configuration: .init(),
responses: .mock
)
)
.previewContext(
WidgetPreviewContext(family: .systemSmall)
)
ArrivalInfoView(
entry: ArrivalInfoEntry(
date: .now,
configuration: .init(),
responses: .mock
)
)
.previewContext(
WidgetPreviewContext(family: .systemMedium)
)
}
}
#endif
Loading

0 comments on commit c814b4d

Please sign in to comment.