Skip to content

Commit

Permalink
[D-1] 등록된 소속 없는 경우 위젯 처리 (526) (#78)
Browse files Browse the repository at this point in the history
* add: 위젯에 사용될 이미지 세트 추가

* feat: MainWidget 등록된 소속 없을 때 UI 처리

* feat: OCRWidget 등록된 소속 없을 때 UI 처리

* feat: SecondWidget 등록된 소속 없는 경우 UI 처리

* fix: 소속 삭제 시 UserDefaults 비워주기
  • Loading branch information
Siwon-L authored Nov 7, 2024
1 parent 6c06e08 commit ff1348c
Show file tree
Hide file tree
Showing 17 changed files with 137 additions and 26 deletions.
21 changes: 0 additions & 21 deletions Projects/App/WidgetExtension/Sources/Model/OCREntry.swift

This file was deleted.

16 changes: 16 additions & 0 deletions Projects/App/WidgetExtension/Sources/View/GradientView.swift
Original file line number Diff line number Diff line change
@@ -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
)
}
}
Original file line number Diff line number Diff line change
@@ -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()
}
}
}
Original file line number Diff line number Diff line change
@@ -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()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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("회비 내역 등록")
Expand Down
14 changes: 12 additions & 2 deletions Projects/App/WidgetExtension/Sources/Widgets/OCRWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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("회비 내역 스캔")
Expand Down Expand Up @@ -38,3 +42,9 @@ struct OCRWidgetEntryView: View {
}
}
}

#Preview(as: .systemSmall, widget: {
OCRWidget()
}, timeline: {
AgencyEntry(date: .now, name: "머니몽", amount: 1000)
})
Original file line number Diff line number Diff line change
Expand Up @@ -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("내 장부")
Expand Down Expand Up @@ -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)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import WidgetKit

public protocol AgencyRepositoryInterface {
func fetchList(page: Int, size: Int) async throws -> [Agency]
Expand Down Expand Up @@ -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()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "icon-study.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "icon-study.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions Projects/Shared/DesignSystem/Sources/Utils/Images.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit ff1348c

Please sign in to comment.