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