[Framework] Feed item view in the Feed framework (#10)
This PR contains the work done to implement the `FeedItemViewController` view controller, that shows in details a selected review from the `FeedListViewController` view controller. Reviewed-on: rock-n-code/app-reviews#10 Co-authored-by: Javier Cicchelli <javier@rock-n-code.com> Co-committed-by: Javier Cicchelli <javier@rock-n-code.com>
This commit was merged in pull request #10.
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
//
|
||||
// FakeLabel.swift
|
||||
// ReviewsUIKit
|
||||
//
|
||||
// Created by Javier Cicchelli on 20/03/2024.
|
||||
// Copyright © 2024 Röck+Cöde. All rights reserved.
|
||||
//
|
||||
|
||||
import ReviewsFoundationKit
|
||||
import SwiftUI
|
||||
|
||||
public struct FakeLabel: View {
|
||||
|
||||
// MARK: Constants
|
||||
private let systemIcon: String
|
||||
private let title: String
|
||||
|
||||
// MARK: Initialisers
|
||||
public init(
|
||||
systemIcon: String,
|
||||
title: String
|
||||
) {
|
||||
self.systemIcon = systemIcon
|
||||
self.title = title
|
||||
}
|
||||
|
||||
// MARK: Body
|
||||
public var body: some View {
|
||||
HStack(
|
||||
alignment: .bottom,
|
||||
spacing: 8
|
||||
) {
|
||||
iconOrQuestionMark
|
||||
|
||||
Text(titleOrDash)
|
||||
.font(.body)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Helpers
|
||||
private extension FakeLabel {
|
||||
|
||||
// MARK: Computed
|
||||
var iconOrQuestionMark: Image {
|
||||
.init(systemName: systemIcon.isEmpty
|
||||
? .Icon.questionMark
|
||||
: systemIcon
|
||||
)
|
||||
}
|
||||
|
||||
var titleOrDash: String {
|
||||
title.isEmpty
|
||||
? .Title.none
|
||||
: title
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - String+Constants
|
||||
private extension String {
|
||||
enum Title {
|
||||
static let none = "-"
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Previews
|
||||
#Preview("Fake Label with system icon and title") {
|
||||
FakeLabel(
|
||||
systemIcon: .Icon.person,
|
||||
title: "Some title goes here..."
|
||||
)
|
||||
}
|
||||
|
||||
#Preview("Fake Label with empty system icon and title") {
|
||||
FakeLabel(
|
||||
systemIcon: .empty,
|
||||
title: "Some title goes here..."
|
||||
)
|
||||
}
|
||||
|
||||
#Preview("Fake Label with system icon and empty title") {
|
||||
FakeLabel(
|
||||
systemIcon: .Icon.person,
|
||||
title: .empty
|
||||
)
|
||||
}
|
||||
|
||||
#Preview("Fake Label with both empty system icon and title") {
|
||||
FakeLabel(
|
||||
systemIcon: .empty,
|
||||
title: .empty
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user