Skip to content

Commit

Permalink
fix: 설치된 앱 보기 해제 시 API로 가져온 딥링크 표시되지 않는 증상 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
heonha committed Nov 5, 2023
1 parent 087f753 commit 683deac
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 38 deletions.
18 changes: 13 additions & 5 deletions koget.xcodeproj/project.pbxproj
Expand Up @@ -709,12 +709,8 @@
39D441B12A5C3D0700C9D11D /* DeepLinkAssetListView.swift */,
39D441B32A5C3D3F00C9D11D /* DeepLinkAssetCell.swift */,
3ABFEFBC292E70A900455730 /* DeepLinkViewModel.swift */,
39DAACD32A5F8C18005A9A9D /* DeepLinkModel.swift */,
39DAACD52A5F8C48005A9A9D /* DeepLinkSessionType.swift */,
39A282C22AF69C0C000AFA99 /* DeepLinkAPIModel.swift */,
39A282C02AF69BFE000AFA99 /* DeepLinkAPIResponse.swift */,
390853B729A3949F006E8311 /* QuestionSenderViewModel.swift */,
39DEF0972AF7406F008013B3 /* FetchDeepLinkAssetType.swift */,
39DEF09A2AF74676008013B3 /* Model */,
);
path = DeepLinkAssets;
sourceTree = "<group>";
Expand Down Expand Up @@ -862,6 +858,18 @@
path = HomeHeader;
sourceTree = "<group>";
};
39DEF09A2AF74676008013B3 /* Model */ = {
isa = PBXGroup;
children = (
39DAACD32A5F8C18005A9A9D /* DeepLinkModel.swift */,
39DAACD52A5F8C48005A9A9D /* DeepLinkSessionType.swift */,
39A282C22AF69C0C000AFA99 /* DeepLinkAPIModel.swift */,
39A282C02AF69BFE000AFA99 /* DeepLinkAPIResponse.swift */,
39DEF0972AF7406F008013B3 /* FetchDeepLinkAssetType.swift */,
);
path = Model;
sourceTree = "<group>";
};
39E0FAE329D132070081E169 /* UI */ = {
isa = PBXGroup;
children = (
Expand Down
16 changes: 8 additions & 8 deletions koget/UI/DeepLinkAssets/DeepLinkAssetCell.swift
Expand Up @@ -21,7 +21,9 @@ struct DeepLinkAssetCell: View {
@State private var webImage: UIImage?
@State private var linkType: DeepLinkSessionType = .app

init(viewModel: any DeepLinkAssetProtocol, widget: DeepLinkModel, type: FetchDeepLinkAssetType = .inApp) {
init(viewModel: any DeepLinkAssetProtocol,
widget: DeepLinkModel,
type: FetchDeepLinkAssetType = .inApp) {
self.type = type
self.widgetData = widget
self.viewModel = viewModel
Expand All @@ -31,13 +33,6 @@ struct DeepLinkAssetCell: View {

var body: some View {
ZStack(alignment: .leading) {
if widgetData.fetchType == .web || linkType == .web {
Color.init(uiColor: .secondarySystemBackground).opacity(0.2)
} else if !widgetData.canOpen {
Color.clear
} else {
Color.init(uiColor: .tertiarySystemBackground).opacity(0.2)
}

Button {
viewModel.getWidgetData(selectedWidget: widgetData, webImage: webImage)
Expand All @@ -52,10 +47,15 @@ struct DeepLinkAssetCell: View {
}
.padding(.horizontal, 4)
.disabled(!widgetData.canOpen)

}
.clipShape(RoundedRectangle(cornerRadius: 8))
}

}

extension DeepLinkAssetCell {

private func imageView(image: UIImage?) -> some View {
ZStack {
Color.white
Expand Down
61 changes: 36 additions & 25 deletions koget/UI/DeepLinkAssets/DeepLinkAssetListView.swift
Expand Up @@ -8,39 +8,42 @@
import SwiftUI

struct DeepLinkAssetListView: View {

@StateObject var widgetAssets = DeepLinkViewModel()
@ObservedObject var viewModel: CreateWidgetViewModel

@State private var searchText: String = ""
@State var searching: Bool = false
@State var presentAssetRequestView: Bool = false
@State var showMoreAppList = false

@Environment(\.dismiss) var dismiss


var body: some View {
ZStack {
AppColor.Background.first
.ignoresSafeArea()

VStack {
titleView
titleView()

topView
topView()

// 리스트
appListView
appListView()
}
}
.onAppear {
// 설치된 앱만 보기
widgetAssets.isOnlyInstalledApp = false
}

}
}

extension DeepLinkAssetListView {

var topView: some View {
private func topView() -> some View {
VStack(alignment: .leading) {
TextFieldView(systemName: .magnifyingglass, placeholder: "앱 검색", text: $searchText)
.padding(.horizontal)
Expand All @@ -57,14 +60,13 @@ struct DeepLinkAssetListView: View {

}

var titleView: some View {
private func titleView() -> some View {
Text("앱 리스트")
.font(.custom(.robotoBold, size: 18))
.padding(.vertical, 12)

}

var appListView: some View {
private func appListView() -> some View {
List(searchText.isEmpty ? widgetAssets.data : widgetAssets.searchResults, id: \.id) { widget in
DeepLinkAssetCell(viewModel: viewModel, widget: widget)
.opacity(widgetAssets.canOpenApp(widget.canOpen))
Expand All @@ -77,20 +79,16 @@ struct DeepLinkAssetListView: View {

private func taskBar() -> some View {
HStack {
Button {
presentAssetRequestView.toggle()
} label: {
Text("앱 추가요청")
.font(.custom(.robotoMedium, size: 14))
.foregroundColor(AppColor.Label.second)
.padding(.leading, 16)
}
.sheet(isPresented: $presentAssetRequestView) {
DeepLinkRequestView()
}

addAppRequestButton()

Spacer()

onlyVisableInstalledToggle()
}
}

private func onlyVisableInstalledToggle() -> some View {
Group {
Text("설치된 앱만 보기")
.font(.custom(.robotoMedium, size: 14))
.foregroundColor(AppColor.Label.second)
Expand All @@ -100,7 +98,20 @@ struct DeepLinkAssetListView: View {
.toggleStyle(CheckmarkToggleStyle())
.frame(width: 32, height: 32)
.padding(.trailing, 20)

}
}

private func addAppRequestButton() -> some View {
Button {
presentAssetRequestView.toggle()
} label: {
Text("앱 추가요청")
.font(.custom(.robotoMedium, size: 14))
.foregroundColor(AppColor.Label.second)
.padding(.leading, 16)
}
.sheet(isPresented: $presentAssetRequestView) {
DeepLinkRequestView()
}
}
}
1 change: 1 addition & 0 deletions koget/UI/DeepLinkAssets/DeepLinkViewModel.swift
Expand Up @@ -38,6 +38,7 @@ final class DeepLinkViewModel: BaseViewModel {
})
} else {
data = baseWidgetService.getWidget()
fetchDeeplinkFromFB()
}
}

Expand Down
File renamed without changes.

0 comments on commit 683deac

Please sign in to comment.