Skip to content

Commit

Permalink
fix: improve search structure, add better status for repos, search, a…
Browse files Browse the repository at this point in the history
…nd allow users to copy repo url
  • Loading branch information
ErrorErrorError committed Dec 15, 2023
1 parent 4cdfd5e commit 80e55ca
Show file tree
Hide file tree
Showing 36 changed files with 657 additions and 361 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "shippingbox.badge.clock.fill.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
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,15 @@
{
"images" : [
{
"filename" : "shippingbox.badge.plus.fill.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
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,15 @@
{
"images" : [
{
"filename" : "shippingbox.badge.questionmark.fill.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
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,15 @@
{
"images" : [
{
"filename" : "shippingbox.trianglebadge.exclamationmark.fill.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
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,15 @@
{
"images" : [
{
"filename" : "search.badge.clock.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions App/Shared/Assets.xcassets/search.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "search.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
11 changes: 11 additions & 0 deletions App/Shared/Assets.xcassets/search.imageset/search.svg
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,15 @@
{
"images" : [
{
"filename" : "search.trianglebadge.exclamationmark.2.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,21 @@ struct BuildClient: _Client {
}
}
//
// ClipboardClient.swift
//
//
// Created by ErrorErrorError on 12/15/23.
//
//

import Foundation

struct ClipboardClient: _Client {
var dependencies: any Dependencies {
ComposableArchitecture()
}
}
//
// DatabaseClient.swift
//
//
Expand Down Expand Up @@ -1219,6 +1234,7 @@ import Foundation
struct Repos: _Feature {
var dependencies: any Dependencies {
Architecture()
ClipboardClient()
ModuleClient()
RepoClient()
SharedModels()
Expand Down
15 changes: 15 additions & 0 deletions Package/Sources/Clients/ClipboardClient.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// ClipboardClient.swift
//
//
// Created by ErrorErrorError on 12/15/23.
//
//

import Foundation

struct ClipboardClient: _Client {
var dependencies: any Dependencies {
ComposableArchitecture()
}
}
1 change: 1 addition & 0 deletions Package/Sources/Features/Repos.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Foundation
struct Repos: _Feature {
var dependencies: any Dependencies {
Architecture()
ClipboardClient()
ModuleClient()
RepoClient()
SharedModels()
Expand Down
32 changes: 32 additions & 0 deletions Sources/Clients/ClipboardClient/Client.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// Client.swift
//
//
// Created ErrorErrorError on 12/15/23.
// Copyright © 2023. All rights reserved.
//

import Dependencies
import Foundation
import XCTestDynamicOverlay

// MARK: - ClipboardClient

public struct ClipboardClient: Sendable {
public var copyValue: @Sendable (String) -> Void
}

// MARK: TestDependencyKey

extension ClipboardClient: TestDependencyKey {
public static let testValue = Self(
copyValue: unimplemented(".copyValue")
)
}

extension DependencyValues {
public var clipboardClient: ClipboardClient {
get { self[ClipboardClient.self] }
set { self[ClipboardClient.self] = newValue }
}
}
30 changes: 30 additions & 0 deletions Sources/Clients/ClipboardClient/Live.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// Live.swift
//
//
// Created ErrorErrorError on 12/15/23.
// Copyright © 2023. All rights reserved.
//

import Dependencies
import Foundation

#if canImport(UIKit)
import UIKit
#elseif canImport(AppKit)
import AppKit
#endif

// MARK: - ClipboardClient + DependencyKey

extension ClipboardClient: DependencyKey {
public static let liveValue = Self(
copyValue: { value in
#if canImport(UIKit)
UIPasteboard.general.string = value
#elseif canImport(AppKit)
NSPasteboard.general.setString(value, forType: .string)
#endif
}
)
}
12 changes: 8 additions & 4 deletions Sources/Features/Discover/DiscoverFeature+Reducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ extension DiscoverFeature {
state.moduleLists = .init()

case let .view(.didTapPlaylist(playlist)):
guard let id = state.section.module?.module.id else { break }
guard let id = state.section.module?.module.id else {
break
}
state.path.append(.playlistDetails(.init(content: .init(repoModuleId: id, playlist: playlist))))

case .view(.didTapSearchButton):
if !state.path.contains(where: { $0.is(\.search) }) {
state.path.append(.search(.init(repoModuleId: state.section.module?.module.id)))
if let repoModuleId = state.section.module?.module.id {
state.path.append(.search(.init(repoModuleId: repoModuleId)))
}

case let .view(.didTapViewMoreListing(listingId)):
Expand Down Expand Up @@ -77,7 +79,9 @@ extension DiscoverFeature {
state.path.append(.playlistDetails(.init(content: .init(repoModuleId: repoModuleId, playlist: playlist))))

case let .internal(.path(.element(elementId, .viewMoreListing(.didTapPlaylist(playlist))))):
guard let id = state.path[id: elementId]?.viewMoreListing?.repoModuleId else { break }
guard let id = state.path[id: elementId]?.viewMoreListing?.repoModuleId else {
break
}
state.path.append(.playlistDetails(.init(content: .init(repoModuleId: id, playlist: playlist))))

case let .internal(.path(.element(_, .playlistDetails(.delegate(.playbackVideoItem(items, id, playlist, group, variant, paging, itemId)))))):
Expand Down
19 changes: 12 additions & 7 deletions Sources/Features/Discover/DiscoverFeature+View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,19 @@ extension DiscoverFeature.View: View {
}

ToolbarItem(placement: .automatic) {
Button {
viewStore.send(.didTapSearchButton)
} label: {
Image(systemName: "magnifyingglass")
WithViewStore(store) { state in
!state.section.is(\.home)
} content: { showMagnifyingGlass in
Button {
viewStore.send(.didTapSearchButton)
} label: {
Image(systemName: "magnifyingglass")
}
#if os(iOS)
.buttonStyle(.materialToolbarItem)
#endif
.opacity(showMagnifyingGlass.state ? 1.0 : 0)
}
#if os(iOS)
.buttonStyle(.materialToolbarItem)
#endif
}
}
}
Expand Down
11 changes: 1 addition & 10 deletions Sources/Features/Discover/DiscoverFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ public struct DiscoverFeature: Feature {
case viewMoreListing(ViewMoreListing.Action)
}

@ReducerBuilder<State, Action>
public var body: some ReducerOf<Self> {
@ReducerBuilder<State, Action> public var body: some ReducerOf<Self> {
Scope(state: \.search, action: \.search) {
SearchFeature()
}
Expand Down Expand Up @@ -187,11 +186,3 @@ public struct DiscoverFeature: Feature {

public init() {}
}

extension DiscoverFeature.State {
public mutating func clearQuery() -> Effect<DiscoverFeature.Action> {
// search?.clearQuery()
// .map { .internal(.search(.presented($0))) } ?? .none
.none
}
}
Loading

0 comments on commit 80e55ca

Please sign in to comment.