diff --git a/Projects/App/Project.swift b/Projects/App/Project.swift index ef75512..2c79172 100644 --- a/Projects/App/Project.swift +++ b/Projects/App/Project.swift @@ -8,7 +8,7 @@ let project = Project( ), settings: .settings( base: .init() - .marketingVersion("1.2.2") + .marketingVersion("1.3.0") .swiftVersion("5.7") .currentProjectVersion("1") .appleGenericVersioningSystem(), @@ -23,6 +23,7 @@ let project = Project( platform: .iOS, product: .appExtension, bundleId: "com.yapp.moneymong.WidgetExtension", + deploymentTarget: .iOS(targetVersion: "15.0", devices: .iphone), infoPlist: .extendingDefault(with: [ "CFBundleDisplayName": "$(PRODUCT_NAME)", "NSExtension": [ diff --git a/Projects/App/WidgetExtension/Sources/Utils/View+.swift b/Projects/App/WidgetExtension/Sources/Utils/View+.swift new file mode 100644 index 0000000..3fe343c --- /dev/null +++ b/Projects/App/WidgetExtension/Sources/Utils/View+.swift @@ -0,0 +1,14 @@ +import SwiftUI + +extension View { + func widgetBackground(_ backgroundView: some View) -> some View { + if #available(iOSApplicationExtension 17.0, *) { + return containerBackground(for: .widget) { + backgroundView + } + } else { + return background(backgroundView) + } + } +} + diff --git a/Projects/App/WidgetExtension/Sources/View/EmptyAgencyView.swift b/Projects/App/WidgetExtension/Sources/View/EmptyAgencyView.swift new file mode 100644 index 0000000..de14152 --- /dev/null +++ b/Projects/App/WidgetExtension/Sources/View/EmptyAgencyView.swift @@ -0,0 +1,21 @@ +import SwiftUI +import WidgetKit + +import DesignSystem + +// 4 * 2 위젯일때 소속이 없을경우 +struct EmptyAgencyView: View { + var body: some View { + VStack { + Image(uiImage: Images.mongLedgerWidget!) + ( + Text("회비 관리할 ").foregroundColor(.white) + + Text("장부").foregroundColor(Color(uiColor: Colors.Blue._4)) + + Text("를 만들어주세요!").foregroundColor(.white) + ) + .font(.system(size: 16, weight: .bold)) + + } + .widgetBackground(GradientBackgroundView()) + } +} diff --git a/Projects/App/WidgetExtension/Sources/View/GradientView.swift b/Projects/App/WidgetExtension/Sources/View/GradientBackgroundView.swift similarity index 91% rename from Projects/App/WidgetExtension/Sources/View/GradientView.swift rename to Projects/App/WidgetExtension/Sources/View/GradientBackgroundView.swift index 7450f95..68fc10a 100644 --- a/Projects/App/WidgetExtension/Sources/View/GradientView.swift +++ b/Projects/App/WidgetExtension/Sources/View/GradientBackgroundView.swift @@ -1,6 +1,6 @@ import SwiftUI -public struct GradientView: View { +public struct GradientBackgroundView: View { public var body: some View { LinearGradient( stops: [ diff --git a/Projects/App/WidgetExtension/Sources/View/NotSelectedAgencyView.swift b/Projects/App/WidgetExtension/Sources/View/NotSelectedAgencyView.swift deleted file mode 100644 index 792176a..0000000 --- a/Projects/App/WidgetExtension/Sources/View/NotSelectedAgencyView.swift +++ /dev/null @@ -1,22 +0,0 @@ -import SwiftUI -import WidgetKit - -import DesignSystem - -struct NotSelectedAgencyView: View { - var body: some View { - VStack { - Image(uiImage: Images.mongLedgerWidget!) - ( - Text("회비 관리할 ").foregroundStyle(.white) + - Text("장부").foregroundStyle(Color(uiColor: Colors.Blue._4)) + - Text("를 만들어주세요!").foregroundStyle(.white) - ) - .font(.system(size: 16, weight: .bold)) - - } - .containerBackground(for: .widget) { - GradientView() - } - } -} diff --git a/Projects/App/WidgetExtension/Sources/View/MiniNotSelectedAgencyView.swift b/Projects/App/WidgetExtension/Sources/View/SmallEmptyAgencyView.swift similarity index 54% rename from Projects/App/WidgetExtension/Sources/View/MiniNotSelectedAgencyView.swift rename to Projects/App/WidgetExtension/Sources/View/SmallEmptyAgencyView.swift index 1cc60b2..5553141 100644 --- a/Projects/App/WidgetExtension/Sources/View/MiniNotSelectedAgencyView.swift +++ b/Projects/App/WidgetExtension/Sources/View/SmallEmptyAgencyView.swift @@ -2,15 +2,16 @@ import SwiftUI import DesignSystem -struct MiniNotSelectedAgencyView: View { +// 2 * 2 위젯인데 소속이 없을경우 +struct SmallEmptyAgencyView: View { var body: some View { VStack { Image(uiImage: Images.mongLedgerWidgetMini!) VStack { ( - Text("회비 관리할 ").foregroundStyle(.white) + - Text("장부").foregroundStyle(Color(uiColor: Colors.Blue._4)) + - Text("를").foregroundStyle(.white) + Text("회비 관리할 ").foregroundColor(.white) + + Text("장부").foregroundColor(Color(uiColor: Colors.Blue._4)) + + Text("를").foregroundColor(.white) ) .font(.system(size: 16, weight: .bold)) Text("만들어주세요!") @@ -18,8 +19,6 @@ struct MiniNotSelectedAgencyView: View { .font(.system(size: 16, weight: .bold)) } } - .containerBackground(for: .widget) { - GradientView() - } + .widgetBackground(GradientBackgroundView()) } } diff --git a/Projects/App/WidgetExtension/Sources/Widgets/MainWidget.swift b/Projects/App/WidgetExtension/Sources/Widgets/MainWidget.swift index 9c4282d..2044ecd 100644 --- a/Projects/App/WidgetExtension/Sources/Widgets/MainWidget.swift +++ b/Projects/App/WidgetExtension/Sources/Widgets/MainWidget.swift @@ -8,7 +8,7 @@ struct MainWidget: Widget { var body: some WidgetConfiguration { StaticConfiguration(kind: kind, provider: AgencyProvider()) { entry in if entry.name.isEmpty { - NotSelectedAgencyView() + EmptyAgencyView() } else { MainWidgetEntryView(entry: entry) } @@ -22,7 +22,6 @@ struct MainWidget: Widget { struct MainWidgetEntryView: View { var entry: AgencyProvider.Entry - var body: some View { VStack { Link(destination: URL(string: "widget://CreateLedger")!) { @@ -71,14 +70,6 @@ struct MainWidgetEntryView: View { .frame(height: 24) Spacer() } - .containerBackground(for: .widget) { - Color(uiColor: Colors.Gray._1) - } + .widgetBackground(Color(uiColor: Colors.Gray._1)) } } - -#Preview(as: .systemMedium, widget: { - MainWidget() -}, timeline: { - AgencyEntry(date: .now, name: "머니몽", amount: 1000) -}) diff --git a/Projects/App/WidgetExtension/Sources/Widgets/OCRWidget.swift b/Projects/App/WidgetExtension/Sources/Widgets/OCRWidget.swift index 26160cb..dc4e13a 100644 --- a/Projects/App/WidgetExtension/Sources/Widgets/OCRWidget.swift +++ b/Projects/App/WidgetExtension/Sources/Widgets/OCRWidget.swift @@ -9,7 +9,7 @@ struct OCRWidget: Widget { var body: some WidgetConfiguration { StaticConfiguration(kind: kind, provider: AgencyProvider()) { entry in if entry.name.isEmpty { - MiniNotSelectedAgencyView() + SmallEmptyAgencyView() } else { OCRWidgetEntryView() } @@ -37,14 +37,6 @@ struct OCRWidgetEntryView: View { } .padding(.vertical, 20) .widgetURL(URL(string: "widget://OCR")) - .containerBackground(for: .widget) { - Color(uiColor: Colors.Gray._1) - } + .widgetBackground(Color(uiColor: Colors.Gray._1)) } } - -#Preview(as: .systemSmall, widget: { - OCRWidget() -}, timeline: { - AgencyEntry(date: .now, name: "머니몽", amount: 1000) -}) diff --git a/Projects/App/WidgetExtension/Sources/Widgets/SecondWidget.swift b/Projects/App/WidgetExtension/Sources/Widgets/SecondWidget.swift index 24bbf10..104242a 100644 --- a/Projects/App/WidgetExtension/Sources/Widgets/SecondWidget.swift +++ b/Projects/App/WidgetExtension/Sources/Widgets/SecondWidget.swift @@ -9,7 +9,7 @@ struct SecondWidget: Widget { var body: some WidgetConfiguration { StaticConfiguration(kind: kind, provider: AgencyProvider()) { entry in if entry.name.isEmpty { - NotSelectedAgencyView() + EmptyAgencyView() } else { SecondWidgetEntryView(entry: entry) } @@ -73,15 +73,6 @@ struct SecondWidgetEntryView: View { } .padding(.horizontal, 10) .padding(.vertical, 20) - .containerBackground(for: .widget) { - Color(uiColor: Colors.Gray._1) - } + .widgetBackground(Color(uiColor: Colors.Gray._1)) } } - -#Preview(as: .systemMedium) { - SecondWidget() -} timeline: { - AgencyEntry(date: .now, name: "", amount: 100000) - AgencyEntry(date: .now, name: "머니몽2", amount: 120000) -}