diff --git a/Projects/App/WidgetExtension/Sources/Model/OCREntry.swift b/Projects/App/WidgetExtension/Sources/Model/OCREntry.swift deleted file mode 100644 index c9db688..0000000 --- a/Projects/App/WidgetExtension/Sources/Model/OCREntry.swift +++ /dev/null @@ -1,21 +0,0 @@ -import WidgetKit - -struct OCREntry: TimelineEntry { - let date: Date -} - -struct OCRProvider: TimelineProvider { - func placeholder(in context: Context) -> OCREntry { - OCREntry(date: Date()) - } - - func getSnapshot(in context: Context, completion: @escaping (OCREntry) -> ()) { - let entry = OCREntry(date: Date()) - completion(entry) - } - - func getTimeline(in context: Context, completion: @escaping (Timeline) -> ()) { - let timeline = Timeline(entries: [OCREntry(date: .now)], policy: .never) - completion(timeline) - } -} diff --git a/Projects/App/WidgetExtension/Sources/View/GradientView.swift b/Projects/App/WidgetExtension/Sources/View/GradientView.swift new file mode 100644 index 0000000..7450f95 --- /dev/null +++ b/Projects/App/WidgetExtension/Sources/View/GradientView.swift @@ -0,0 +1,16 @@ +import SwiftUI + +public struct GradientView: View { + public var body: some View { + LinearGradient( + stops: [ + .init(color: Color(uiColor: UIColor(hexString: "8496F9")), location: 0.0), + .init(color: Color(uiColor: UIColor(hexString: "C6DFFD")), location: 0.36), + .init(color: Color(uiColor: UIColor(hexString: "E9D8EB")), location: 0.70), + .init(color: Color(uiColor: UIColor(hexString: "C6DFFD")), location: 1.0) + ], + startPoint: .leading, + endPoint: .trailing + ) + } +} diff --git a/Projects/App/WidgetExtension/Sources/View/MiniNotSelectedAgencyView.swift b/Projects/App/WidgetExtension/Sources/View/MiniNotSelectedAgencyView.swift new file mode 100644 index 0000000..1cc60b2 --- /dev/null +++ b/Projects/App/WidgetExtension/Sources/View/MiniNotSelectedAgencyView.swift @@ -0,0 +1,25 @@ +import SwiftUI + +import DesignSystem + +struct MiniNotSelectedAgencyView: View { + var body: some View { + VStack { + Image(uiImage: Images.mongLedgerWidgetMini!) + VStack { + ( + Text("회비 관리할 ").foregroundStyle(.white) + + Text("장부").foregroundStyle(Color(uiColor: Colors.Blue._4)) + + Text("를").foregroundStyle(.white) + ) + .font(.system(size: 16, weight: .bold)) + Text("만들어주세요!") + .foregroundStyle(.white) + .font(.system(size: 16, weight: .bold)) + } + } + .containerBackground(for: .widget) { + GradientView() + } + } +} diff --git a/Projects/App/WidgetExtension/Sources/View/NotSelectedAgencyView.swift b/Projects/App/WidgetExtension/Sources/View/NotSelectedAgencyView.swift new file mode 100644 index 0000000..792176a --- /dev/null +++ b/Projects/App/WidgetExtension/Sources/View/NotSelectedAgencyView.swift @@ -0,0 +1,22 @@ +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/Widgets/MainWidget.swift b/Projects/App/WidgetExtension/Sources/Widgets/MainWidget.swift index 3c6b9b6..9c4282d 100644 --- a/Projects/App/WidgetExtension/Sources/Widgets/MainWidget.swift +++ b/Projects/App/WidgetExtension/Sources/Widgets/MainWidget.swift @@ -7,7 +7,11 @@ struct MainWidget: Widget { var body: some WidgetConfiguration { StaticConfiguration(kind: kind, provider: AgencyProvider()) { entry in - MainWidgetEntryView(entry: entry) + if entry.name.isEmpty { + NotSelectedAgencyView() + } else { + MainWidgetEntryView(entry: entry) + } } .supportedFamilies([.systemMedium]) .configurationDisplayName("회비 내역 등록") diff --git a/Projects/App/WidgetExtension/Sources/Widgets/OCRWidget.swift b/Projects/App/WidgetExtension/Sources/Widgets/OCRWidget.swift index 1f14d72..26160cb 100644 --- a/Projects/App/WidgetExtension/Sources/Widgets/OCRWidget.swift +++ b/Projects/App/WidgetExtension/Sources/Widgets/OCRWidget.swift @@ -7,8 +7,12 @@ struct OCRWidget: Widget { private let kind: String = "OCRWidget" var body: some WidgetConfiguration { - StaticConfiguration(kind: kind, provider: OCRProvider()) { entry in - OCRWidgetEntryView() + StaticConfiguration(kind: kind, provider: AgencyProvider()) { entry in + if entry.name.isEmpty { + MiniNotSelectedAgencyView() + } else { + OCRWidgetEntryView() + } } .supportedFamilies([.systemSmall]) .configurationDisplayName("회비 내역 스캔") @@ -38,3 +42,9 @@ struct OCRWidgetEntryView: View { } } } + +#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 a59bb96..24bbf10 100644 --- a/Projects/App/WidgetExtension/Sources/Widgets/SecondWidget.swift +++ b/Projects/App/WidgetExtension/Sources/Widgets/SecondWidget.swift @@ -8,7 +8,11 @@ struct SecondWidget: Widget { var body: some WidgetConfiguration { StaticConfiguration(kind: kind, provider: AgencyProvider()) { entry in - SecondWidgetEntryView(entry: entry) + if entry.name.isEmpty { + NotSelectedAgencyView() + } else { + SecondWidgetEntryView(entry: entry) + } } .supportedFamilies([.systemMedium]) .configurationDisplayName("내 장부") @@ -78,6 +82,6 @@ struct SecondWidgetEntryView: View { #Preview(as: .systemMedium) { SecondWidget() } timeline: { - AgencyEntry(date: .now, name: "머니몽", amount: 100000) + AgencyEntry(date: .now, name: "", amount: 100000) AgencyEntry(date: .now, name: "머니몽2", amount: 120000) } diff --git a/Projects/Core/Core/Sources/Network/APIs/AgencyAPI/Repository/AgencyRepository.swift b/Projects/Core/Core/Sources/Network/APIs/AgencyAPI/Repository/AgencyRepository.swift index 5ce27a8..a42a489 100644 --- a/Projects/Core/Core/Sources/Network/APIs/AgencyAPI/Repository/AgencyRepository.swift +++ b/Projects/Core/Core/Sources/Network/APIs/AgencyAPI/Repository/AgencyRepository.swift @@ -1,4 +1,5 @@ import Foundation +import WidgetKit public protocol AgencyRepositoryInterface { func fetchList(page: Int, size: Int) async throws -> [Agency] @@ -74,5 +75,7 @@ public final class AgencyRepository: AgencyRepositoryInterface { public func deleteAgency(id: Int) async throws { let targetType = AgencyAPI.delete(id: id) try await networkManager.request(target: targetType) + UserDefaults(suiteName: "group.moneymong")?.removeObject(forKey: "agencyInfo") + WidgetCenter.shared.reloadAllTimelines() } } diff --git a/Projects/Shared/DesignSystem/Resources/Image/Icon.xcassets/MoneyMong/mong.ledger.widget.imageset/Contents.json b/Projects/Shared/DesignSystem/Resources/Image/Icon.xcassets/MoneyMong/mong.ledger.widget.imageset/Contents.json new file mode 100644 index 0000000..ff6e635 --- /dev/null +++ b/Projects/Shared/DesignSystem/Resources/Image/Icon.xcassets/MoneyMong/mong.ledger.widget.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "icon-study.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "icon-study@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "icon-study@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/Shared/DesignSystem/Resources/Image/Icon.xcassets/MoneyMong/mong.ledger.widget.imageset/icon-study.png b/Projects/Shared/DesignSystem/Resources/Image/Icon.xcassets/MoneyMong/mong.ledger.widget.imageset/icon-study.png new file mode 100644 index 0000000..3de1280 Binary files /dev/null and b/Projects/Shared/DesignSystem/Resources/Image/Icon.xcassets/MoneyMong/mong.ledger.widget.imageset/icon-study.png differ diff --git a/Projects/Shared/DesignSystem/Resources/Image/Icon.xcassets/MoneyMong/mong.ledger.widget.imageset/icon-study@2x.png b/Projects/Shared/DesignSystem/Resources/Image/Icon.xcassets/MoneyMong/mong.ledger.widget.imageset/icon-study@2x.png new file mode 100644 index 0000000..1a15a70 Binary files /dev/null and b/Projects/Shared/DesignSystem/Resources/Image/Icon.xcassets/MoneyMong/mong.ledger.widget.imageset/icon-study@2x.png differ diff --git a/Projects/Shared/DesignSystem/Resources/Image/Icon.xcassets/MoneyMong/mong.ledger.widget.imageset/icon-study@3x.png b/Projects/Shared/DesignSystem/Resources/Image/Icon.xcassets/MoneyMong/mong.ledger.widget.imageset/icon-study@3x.png new file mode 100644 index 0000000..f1fdca4 Binary files /dev/null and b/Projects/Shared/DesignSystem/Resources/Image/Icon.xcassets/MoneyMong/mong.ledger.widget.imageset/icon-study@3x.png differ diff --git a/Projects/Shared/DesignSystem/Resources/Image/Icon.xcassets/MoneyMong/mong.ledger.widget.mini.imageset/Contents.json b/Projects/Shared/DesignSystem/Resources/Image/Icon.xcassets/MoneyMong/mong.ledger.widget.mini.imageset/Contents.json new file mode 100644 index 0000000..ff6e635 --- /dev/null +++ b/Projects/Shared/DesignSystem/Resources/Image/Icon.xcassets/MoneyMong/mong.ledger.widget.mini.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "icon-study.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "icon-study@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "icon-study@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/Shared/DesignSystem/Resources/Image/Icon.xcassets/MoneyMong/mong.ledger.widget.mini.imageset/icon-study.png b/Projects/Shared/DesignSystem/Resources/Image/Icon.xcassets/MoneyMong/mong.ledger.widget.mini.imageset/icon-study.png new file mode 100644 index 0000000..5d4c7ae Binary files /dev/null and b/Projects/Shared/DesignSystem/Resources/Image/Icon.xcassets/MoneyMong/mong.ledger.widget.mini.imageset/icon-study.png differ diff --git a/Projects/Shared/DesignSystem/Resources/Image/Icon.xcassets/MoneyMong/mong.ledger.widget.mini.imageset/icon-study@2x.png b/Projects/Shared/DesignSystem/Resources/Image/Icon.xcassets/MoneyMong/mong.ledger.widget.mini.imageset/icon-study@2x.png new file mode 100644 index 0000000..cfefcbe Binary files /dev/null and b/Projects/Shared/DesignSystem/Resources/Image/Icon.xcassets/MoneyMong/mong.ledger.widget.mini.imageset/icon-study@2x.png differ diff --git a/Projects/Shared/DesignSystem/Resources/Image/Icon.xcassets/MoneyMong/mong.ledger.widget.mini.imageset/icon-study@3x.png b/Projects/Shared/DesignSystem/Resources/Image/Icon.xcassets/MoneyMong/mong.ledger.widget.mini.imageset/icon-study@3x.png new file mode 100644 index 0000000..b25c72d Binary files /dev/null and b/Projects/Shared/DesignSystem/Resources/Image/Icon.xcassets/MoneyMong/mong.ledger.widget.mini.imageset/icon-study@3x.png differ diff --git a/Projects/Shared/DesignSystem/Sources/Utils/Images.swift b/Projects/Shared/DesignSystem/Sources/Utils/Images.swift index 0909bef..3065d6d 100644 --- a/Projects/Shared/DesignSystem/Sources/Utils/Images.swift +++ b/Projects/Shared/DesignSystem/Sources/Utils/Images.swift @@ -91,5 +91,7 @@ public enum Images { // Widget public static let scanCircle = UIImage(named: "scan.circle.gray", in: Bundle.module, with: nil) public static let mongCoin = UIImage(named: "mong.coin", in: Bundle.module, with: nil) + public static let mongLedgerWidget = UIImage(named: "mong.ledger.widget", in: Bundle.module, with: nil) + public static let mongLedgerWidgetMini = UIImage(named: "mong.ledger.widget.mini", in: Bundle.module, with: nil) }