Skip to content

Any ideas for implementing a scrollable view that consists of multiple forms of row view? #590

Answered by takehilo
takehilo asked this question in Q&A
Discussion options

You must be logged in to vote

I got a solution. Does it make sense?

Model

struct Model: Equatable {
    let users: [User]
}

enum User: Equatable {
    case normalUser(NormalUser)
    case premiumUser(PremiumUser)
}

struct NormalUser: Equatable {
    let id: Int
    let name: String
    let someNiceProperty: String
}

struct PremiumUser: Equatable {
    let id: Int
    let name: String
    let someGreatProperty: String
}

TCA Core

struct AppState: Equatable {
    var users: [UserState]
}

enum AppAction: Equatable {
    case user(id: Int, action: UserAction)
}

struct AppEnvironment {}

let appReducer: Reducer<AppState, AppAction, AppEnvironment> =
    userReducer.forEach(
        state: \.users,
        action: /AppA…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@takehilo
Comment options

Answer selected by takehilo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant