Added the "createFolder", "uploadFile" and "showProfile" closures to the BrowseToolbar toolbar.
This commit is contained in:
parent
05023985a1
commit
3835dab788
@ -31,6 +31,10 @@ let package = Package(
|
||||
),
|
||||
.target(
|
||||
name: "Browse",
|
||||
dependencies: [
|
||||
"Cores",
|
||||
"Libraries"
|
||||
],
|
||||
resources: [.process("Resources")]
|
||||
),
|
||||
.target(
|
||||
|
@ -1,19 +1,29 @@
|
||||
//
|
||||
// BrowseToolbar.swift
|
||||
// BeReal
|
||||
// Browse
|
||||
//
|
||||
// Created by Javier Cicchelli on 03/12/2022.
|
||||
// Copyright © 2022 Röck+Cöde. All rights reserved.
|
||||
//
|
||||
|
||||
import DataModels
|
||||
import SwiftUI
|
||||
|
||||
struct BrowseToolbar: ToolbarContent {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
let createFolder: ActionClosure
|
||||
let uploadFile: ActionClosure
|
||||
let showProfile: ActionClosure
|
||||
|
||||
// MARK: Body
|
||||
|
||||
var body: some ToolbarContent {
|
||||
ToolbarItem(placement: .primaryAction) {
|
||||
Menu {
|
||||
Button {
|
||||
// TODO: Implement the creation of a new folder.
|
||||
createFolder()
|
||||
} label: {
|
||||
Label {
|
||||
Text(
|
||||
@ -27,7 +37,7 @@ struct BrowseToolbar: ToolbarContent {
|
||||
}
|
||||
|
||||
Button {
|
||||
// TODO: Implement the upload of a file from the device to the API.
|
||||
uploadFile()
|
||||
} label: {
|
||||
Label {
|
||||
Text(
|
||||
@ -55,7 +65,7 @@ struct BrowseToolbar: ToolbarContent {
|
||||
|
||||
ToolbarItem(placement: .navigationBarTrailing) {
|
||||
Button {
|
||||
// TODO: Implement the show of the user profile.
|
||||
showProfile()
|
||||
} label: {
|
||||
Label {
|
||||
Text(
|
||||
@ -70,6 +80,7 @@ struct BrowseToolbar: ToolbarContent {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Image+Constants
|
||||
|
@ -6,13 +6,28 @@
|
||||
// Copyright © 2022 Röck+Cöde. All rights reserved.
|
||||
//
|
||||
|
||||
import DataModels
|
||||
import SwiftUI
|
||||
|
||||
public struct BrowseView: View {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
private let createFolder: ActionClosure
|
||||
private let uploadFile: ActionClosure
|
||||
private let showProfile: ActionClosure
|
||||
|
||||
// MARK: Initialisers
|
||||
|
||||
public init() {}
|
||||
public init(
|
||||
createFolder: @escaping ActionClosure,
|
||||
uploadFile: @escaping ActionClosure,
|
||||
showProfile: @escaping ActionClosure
|
||||
) {
|
||||
self.createFolder = createFolder
|
||||
self.uploadFile = uploadFile
|
||||
self.showProfile = showProfile
|
||||
}
|
||||
|
||||
// MARK: Body
|
||||
|
||||
@ -106,7 +121,11 @@ public struct BrowseView: View {
|
||||
.background(Color.red)
|
||||
.navigationTitle("Folder name")
|
||||
.toolbar {
|
||||
BrowseToolbar()
|
||||
BrowseToolbar(
|
||||
createFolder: createFolder,
|
||||
uploadFile: uploadFile,
|
||||
showProfile: showProfile
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -123,7 +142,13 @@ private extension Image {
|
||||
struct BrowseView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
NavigationView {
|
||||
BrowseView()
|
||||
BrowseView {
|
||||
// ...
|
||||
} uploadFile: {
|
||||
// ...
|
||||
} showProfile: {
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user