Skip to content

Commit

Permalink
Merge pull request #172 from Team-B1ND/develop
Browse files Browse the repository at this point in the history
3.3.0
  • Loading branch information
hhhello0507 authored Oct 2, 2024
2 parents 5fa8d7e + 8d43bcb commit e9c4955
Show file tree
Hide file tree
Showing 176 changed files with 1,943 additions and 982 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ clean:
rm -rf *.xcworkspace

reset:
tuist clean
mise exec -- tuist clean
rm -rf **/*.xcodeproj
rm -rf *.xcworkspace

clean-spm:
rm -rf ~/Library/Caches/org.swift.swiftpm
rm -rf ~/Library/org.swift.swiftpm
14 changes: 11 additions & 3 deletions Projects/App/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ let project = Project(
developmentRegion: "ko"
),
settings: .settings(
base: .init(),
base: .init()
.otherLinkerFlags(["$(inherited) -ObjC"]),
configurations: [
.debug(name: .debug),
.release(name: .release)
Expand All @@ -25,7 +26,7 @@ let project = Project(
infoPlist: .extendingDefault(
with: [
"CFBundleDisplayName": "도담도담",
"CFBundleShortVersionString": "3.2.2",
"CFBundleShortVersionString": "3.3.0",
"CFBundleVersion": "1",
"UISupportedInterfaceOrientations": ["UIInterfaceOrientationPortrait"],
"UIMainStoryboardFile": "",
Expand All @@ -51,7 +52,7 @@ let project = Project(
infoPlist: .extendingDefault(with: [
"CFBundleDisplayName": "$(PRODUCT_NAME)",
"NSExtension": [
"NSExtensionPointIdentifier": "com.apple.widgetkit-extension",
"NSExtensionPointIdentifier": "com.apple.widgetkit-extension"
]
]),
sources: ["iOS-Widget/Source/**"],
Expand All @@ -64,6 +65,13 @@ let project = Project(
.project(target: "Shared", path: .relativeToRoot("Projects/Shared")),
.external(name: "DDS")
]
),
.target(
name: "Aggregate",
destinations: [.iPhone],
product: .bundle,
bundleId: "com.b1nd.dodam.aggregate",
scripts: [.periphery]
)
]
)
43 changes: 43 additions & 0 deletions Projects/App/iOS-Widget/Source/Component/MealMenuText.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// MealMenuText.swift
// DodamDodam
//
// Created by dgsw8th36 on 9/23/24.
//

import SwiftUI
import DDS

struct MealMenuText: View {

let text: String
let isMealEmpty: Bool

init(text: String, isMealEmpty: Bool = false) {
self.text = text
self.isMealEmpty = isMealEmpty
}

var body: some View {
VStack {
if isMealEmpty {
Text(text)
.font(.footnote)
.multilineTextAlignment(.center)
.foreground(DodamColor.Label.normal)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center)
} else {
Text(text)
.lineLimit(1)
.truncationMode(.tail)
.font(.caption)
.foreground(DodamColor.Label.normal)
.frame(maxWidth: .infinity, alignment: .leading)
}
}
}
}

#Preview {
MealMenuText(text: "test", isMealEmpty: true)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ import Swinject
import DataSource
import Network
import Repository
import Local

struct DataSourceAssembly: Assembly {

func assemble(container: Container) {
container.register(MealDataSource.self) {
.init(remote: $0.resolve(MealRemote.self)!)
}.inObjectScope(.container)

container.register(LocalMealDataSource.self) {
.init(mealCache: $0.resolve(MealCache.self)!)
}.inObjectScope(.container)
}
}
20 changes: 20 additions & 0 deletions Projects/App/iOS-Widget/Source/DI/Assembly/LocalAssembly.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// LocalAssembly.swift
// DodamDodam
//
// Created by hhhello0507 on 9/17/24.
//

import Foundation
import Swinject
import Local
import Domain

struct LocalAssembly: Assembly {

func assemble(container: Container) {
container.register(MealCache.self) { _ in
.init()
}.inObjectScope(.container)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ struct RepositoryAssembly: Assembly {

func assemble(container: Container) {
container.register((any MealRepository).self) {
MealRepositoryImpl(dataSource: $0.resolve(MealDataSource.self)!)
MealRepositoryImpl(
dataSource: $0.resolve(MealDataSource.self)!,
localDataSource: $0.resolve(LocalMealDataSource.self)!
)
}.inObjectScope(.container)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public extension DependencyProvider {
[
DataSourceAssembly(),
RemoteAssembly(),
RepositoryAssembly()
RepositoryAssembly(),
LocalAssembly()
],
container: self.container
)
Expand Down
6 changes: 3 additions & 3 deletions Projects/App/iOS-Widget/Source/Entry/MealEntry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Domain

struct MealEntry: TimelineEntry {
let date: Date
let meal: MealResponse?
let meal: MealModel?
}

extension MealEntry {
Expand All @@ -27,8 +27,8 @@ extension MealEntry {
}
}

extension MealResponse {
static let empty = MealResponse(
extension MealModel {
static let empty = MealModel(
exists: true,
date: .now,
breakfast: nil,
Expand Down
22 changes: 14 additions & 8 deletions Projects/App/iOS-Widget/Source/Provider/MealProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct MealProvider: TimelineProvider {
@Inject var mealRepository: any MealRepository
func placeholder(in context: Context) -> MealEntry {

let meal = Meal(
let meal = MealDetail(
details: [
.init(name: "퀴노아녹두죽", allergies: []),
.init(name: "채소샐러드", allergies: []),
Expand All @@ -28,7 +28,7 @@ struct MealProvider: TimelineProvider {
)
let entry = MealEntry(
date: .now,
meal: MealResponse(
meal: MealModel(
exists: true,
date: .now,
breakfast: meal,
Expand All @@ -42,13 +42,13 @@ struct MealProvider: TimelineProvider {
func getSnapshot(in context: Context, completion: @escaping (MealEntry) -> Void) {
Task {
var currentDate = Date.now
if getDate(.hour, date: currentDate) >= 20 {
if currentDate[.hour] >= 20 {
currentDate = Calendar.current.date(byAdding: .day, value: 1, to: currentDate)!
}
do {
let year = getDate(.year, date: currentDate)
let month = getDate(.month, date: currentDate)
let day = getDate(.day, date: currentDate)
let year = currentDate[.year]
let month = currentDate[.month]
let day = currentDate[.day]
let request = FetchMealRequest(year: year, month: month, day: day)
let meal = try await mealRepository.fetchMeal(request)
let entry = MealEntry(
Expand All @@ -68,12 +68,18 @@ struct MealProvider: TimelineProvider {
Task {
var currentDate = Date()
// 오후 8시가 지나면 다음날로
if getDate(.hour, date: currentDate) >= 20 {
if currentDate[.hour] >= 20 {
currentDate = Calendar.current.date(byAdding: .day, value: 1, to: currentDate)!
}

do {
let meal = try await mealRepository.fetchMeal(.init(year: getDate(.year, date: currentDate), month: getDate(.month, date: currentDate), day: getDate(.day, date: currentDate)))
let meal = try await mealRepository.fetchMeal(
.init(
year: currentDate[.year],
month: currentDate[.month],
day: currentDate[.day]
)
)
let entry = MealEntry(
date: currentDate,
meal: meal
Expand Down
66 changes: 29 additions & 37 deletions Projects/App/iOS-Widget/Source/Widget/DodamMealWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct DodamMealWidget: Widget {

struct MealWidgetContent: View {

@State private var selection = 0
@Environment(\.widgetFamily) private var widgetFamily

private let entry: MealProvider.Entry

Expand All @@ -48,42 +48,24 @@ struct MealWidgetContent: View {
var body: some View {
Group {
if #available(iOSApplicationExtension 17.0, *) {
label(meal: entry.meal)
content(meal: entry.meal)
.containerBackground(for: .widget) {
Dodam.color(DodamColor.Background.neutral)
}
} else {
label(meal: entry.meal)
content(meal: entry.meal)
}
}
.padding(8)
}

@ViewBuilder
private func label(meal: MealResponse?) -> some View {
let idx = switch (getDate(.hour, date: .now), getDate(.minute, date: .now)) {
// 아침: ~ 8:20
case (0...8, _), (8, ..<20): 0
// 점심: 8:21 ~ 13:30
case (8, 21...60), (8...13, _), (13, 0..<30): 1
// 저녁: 13:31 ~ 19:10
case (13, 0...30), (13...19, _), (19, 0..<10): 2
default: 0
}
let (tag, meal): (String, Meal?) = switch idx {
case 0: ("아침", meal?.breakfast)
case 1: ("점심", meal?.lunch)
case 2: ("저녁", meal?.dinner)
default: ("", nil)
}
content(tag: tag, meal: meal)
}

@ViewBuilder
private func content(tag: String, meal: Meal?) -> some View {
private func content(meal: MealModel?) -> some View {
let mealType = MealType.from(.now) ?? .breakfast
let meal = meal?.getMeal(type: mealType)
VStack(spacing: 4) {
HStack {
Text(tag)
Text(mealType.label)
.foreground(DodamColor.Static.white)
.padding(.horizontal, 10)
.padding(.vertical, 4)
Expand All @@ -99,20 +81,30 @@ struct MealWidgetContent: View {
}
VStack(alignment: .leading, spacing: 0) {
if let meal {
ForEach(meal.details, id: \.self) {
Text($0.name)
.lineLimit(1)
.truncationMode(.tail)
.font(.caption)
.foreground(DodamColor.Label.normal)
.frame(maxWidth: .infinity, alignment: .leading)
if meal.details.isEmpty {
MealMenuText(text: "오늘은\n급식이 없어요", isMealEmpty: false)
} else {
HStack {
if widgetFamily == .systemSmall {
VStack(alignment: .leading, spacing: 0) {
ForEach(0..<min(meal.details.count, 6), id: \.self) { idx in
MealMenuText(text: meal.details.count > 6 && idx == 6 ? "..." : meal.details[idx].name)
}
}
} else {
let splitArray = splitArray(array: meal.details, position: 6)
ForEach(splitArray, id: \.self) { meals in
VStack(alignment: .leading, spacing: 0) {
ForEach(meals, id: \.self) { meal in
MealMenuText(text: meal.name)
}
}
}
}
}
}
} else {
Text("급식을\n불러올 수 없어요")
.font(.footnote)
.multilineTextAlignment(.center)
.foreground(DodamColor.Label.normal)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center)
MealMenuText(text: "급식을\n불러올 수 없어요", isMealEmpty: false)
}
}
.padding(8)
Expand Down
7 changes: 6 additions & 1 deletion Projects/App/iOS/Source/AppMain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
//

import SwiftUI
import SignKit
import DIContainer
import Feature
import Shared
import DDS
import FlowKit
import Realm

@main
struct AppMain: App {
Expand All @@ -36,6 +36,11 @@ struct AppMain: App {
FlowPresenter(flow: flow)
}
.ignoresSafeArea()
.onAppear {
#if DEBUG
print("Realm DB location: \(RLMRealmConfiguration.default().fileURL!)")
#endif
}
}
}
}
6 changes: 5 additions & 1 deletion Projects/App/iOS/Source/DI/Assembly/DataSourceAssembly.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Swinject
import DataSource
import Network
import Repository
import Local

struct DataSourceAssembly: Assembly {

Expand All @@ -29,6 +29,10 @@ struct DataSourceAssembly: Assembly {
.init(remote: $0.resolve(MealRemote.self)!)
}.inObjectScope(.container)

container.register(LocalMealDataSource.self) {
.init(mealCache: $0.resolve(MealCache.self)!)
}.inObjectScope(.container)

container.register(MemberDataSource.self) {
.init(remote: $0.resolve(MemberRemote.self)!)
}.inObjectScope(.container)
Expand Down
Loading

0 comments on commit e9c4955

Please sign in to comment.