Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions iosVariant/Variant.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@
knownRegions = (
en,
Base,
es,
fr,
"pt-BR",
);
mainGroup = 7555FF72242A565900829871;
packageReferences = (
Expand Down
90 changes: 81 additions & 9 deletions iosVariant/iosVariant/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,96 @@ struct HomeView: View {
}
},
onDeleteComics: {
Log().info(tag: TAG, message: "Deleting \(variantViewModel.selectionList.count) comic book(s)")
Log().info(
tag: TAG,
message:
"Deleting \(variantViewModel.selectionList.count) comic book(s)"
)
Task {
try await variantViewModel.deleteSelections()
}
}
)
.tag(AppDestination.comics)
.tabItem { Label("Comics", systemImage: "book.fill") }
.tabItem {
Label(
String(
localized: "destination.comics.label",
defaultValue: "Comics"
),
systemImage: "book.fill"
)
}

ServerView()
.tag(AppDestination.browseServer)
.tabItem {
Label("Browse", systemImage: "person.crop.circle.fill")
ServerView(
comicBookList: self.variantViewModel.comicBookList,
currentPath: self.variantViewModel.browsingState.currentPath,
title: self.variantViewModel.browsingState.title,
parentPath: self.variantViewModel.browsingState.parentPath,
directoryContents: self.variantViewModel.browsingState.contents,
downloadingState: self.variantViewModel.browsingState
.downloadingState,
loading: self.variantViewModel.loading,
onLoadDirectory: { path, reload in
Log().debug(
tag: TAG,
message: "Loading path: \(path) reload=\(reload)"
)
self.variantViewModel.loadDirectory(
path: path,
reload: reload
)
},
onDownloadFile: { path, filename in
Task {
Log().debug(
tag: TAG,
message: "Downloading file: \(filename)"
)

self.variantViewModel.downloadFile(
path: path,
filename: filename
)
}
}
)
.tag(AppDestination.browseServer)
.tabItem {
Label(
String(
localized: "destination.browse-server.label",
defaultValue: "Browse"
),
systemImage: "person.crop.circle.fill"
)
}

SettingsView()
.tag(AppDestination.settings)
.tabItem { Label("Settings", systemImage: "gearshape.fill") }
SettingsView(
address: variantViewModel.address,
username: variantViewModel.username,
password: variantViewModel.password,
onSaveChanges: { address, username, password in
Log().debug(
tag: TAG,
message:
"Saving server settings: \(address), \(username), \(password)"
)
variantViewModel.address = address
variantViewModel.username = username
variantViewModel.password = password
}
)
.tag(AppDestination.settings)
.tabItem {
Label(
String(
localized: "destination.settings.label",
defaultValue: "Settings"
),
systemImage: "gearshape.fill"
)
}
}
.edgesIgnoringSafeArea(.bottom)
.onChange(of: currentDestination) { tab in
Expand Down
7 changes: 6 additions & 1 deletion iosVariant/iosVariant/Views/Comics/ComicBookListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ struct ComicBookListView: View {
}
.padding(.horizontal)
}
.navigationTitle("Comic List")
.navigationTitle(
String(
localized: "comic-book-list.title",
defaultValue: "Comic List"
)
)
}
}
}
Expand Down
89 changes: 54 additions & 35 deletions iosVariant/iosVariant/Views/Servers/BrowseServerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ import shared
private let TAG = "BrowseServerView"

struct BrowseServerView: View {
@EnvironmentViewModel var variantViewModel: VariantViewModel

let comicBookList: [ComicBook]
let path: String
let title: String
let parentPath: String
Expand All @@ -44,8 +43,8 @@ struct BrowseServerView: View {
}

var body: some View {
ZStack {
NavigationStack {
NavigationStack {
ZStack {
List(directoryContents, id: \.id, selection: $selected) {
entry in
if entry.isDirectory {
Expand All @@ -62,56 +61,75 @@ struct BrowseServerView: View {
} else {
FileItemView(
entry: entry,
comicBookFiles: variantViewModel.comicBookList.map {
comicBookFiles: comicBookList.map {
$0.filename
},
downloadingState: downloadingState,
onDownloadFile: onDownloadFile
)
}
}
.refreshable {
if !loading {
Log().info(
tag: TAG,
message:
"Reloading path: \(variantViewModel.browsingState.currentPath)"
)
onLoadDirectory(
variantViewModel.browsingState.currentPath,
true
)
}
.grayscale(loading ? 1 : 0)

if loading {
ProgressView()
}
.navigationTitle(displayableTitle)
.toolbar {
if parentPath != "" {
ToolbarItem(placement: .topBarLeading) {
Button("Back") {
Log().info(
tag: TAG,
message: "Loading parent: \(parentPath)"
)
onLoadDirectory(parentPath, false)
}
}

.refreshable {
if !loading {
Log().info(
tag: TAG,
message:
"Reloading path: \(path)"
)
onLoadDirectory(
path,
true
)
}
}
.navigationTitle(displayableTitle)
.toolbar {
if parentPath != "" {
ToolbarItem(placement: .topBarLeading) {
Button {
Log().info(
tag: TAG,
message: "Loading parent: \(parentPath)"
)
onLoadDirectory(parentPath, false)
} label: {
Image(systemName: "arrow.backward")
}
}
}
}

if loading {
ProgressView()
}
}
}
}

#Preview("normal") {
#Preview("directories") {
BrowseServerView(
comicBookList: COMIC_BOOK_LIST,
path: "/reader/v1",
title: "",
parentPath: "",
directoryContents: DIRECTORY_LIST.filter { $0.isDirectory },
downloadingState: [],
loading: false,
onLoadDirectory: { _, _ in },
onDownloadFile: { _, _ in }
)
}

#Preview("files") {
BrowseServerView(
comicBookList: COMIC_BOOK_LIST,
path: "/reader/v1",
title: "",
parentPath: "",
directoryContents: DIRECTORY_LIST,
directoryContents: DIRECTORY_LIST.filter { $0.isDirectory == false },
downloadingState: [],
loading: false,
onLoadDirectory: { _, _ in },
Expand All @@ -121,10 +139,11 @@ struct BrowseServerView: View {

#Preview("loading") {
BrowseServerView(
comicBookList: COMIC_BOOK_LIST,
path: "/reader/v1",
title: "",
parentPath: "",
directoryContents: DIRECTORY_LIST,
directoryContents: DIRECTORY_LIST.filter { $0.isDirectory },
downloadingState: [],
loading: true,
onLoadDirectory: { _, _ in },
Expand Down
30 changes: 14 additions & 16 deletions iosVariant/iosVariant/Views/Servers/FileItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,21 @@ struct FileItemView: View {
var body: some View {
HStack {
if isDownloaded {
Button(
"",
systemImage: "checkmark.circle.fill",
action: {}
)
Button {

} label: {
Image(systemName: "checkmark.circle.fill")
}
} else {
Button(
"",
systemImage: "plus.circle.fill",
action: {
Log().info(
tag: TAG,
message: "Downloading file: \(entry.path)"
)
onDownloadFile(entry.path, entry.filename)
}
)
Button {
Log().info(
tag: TAG,
message: "Downloading file: \(entry.path)"
)
onDownloadFile(entry.path, entry.filename)
} label: {
Image(systemName: "plus.circle.fill")
}
}

VStack(alignment: .leading) {
Expand Down
62 changes: 30 additions & 32 deletions iosVariant/iosVariant/Views/Servers/ServerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,44 +23,42 @@ import shared
private let TAG = "ServerView"

struct ServerView: View {
@EnvironmentViewModel var variantViewModel: VariantViewModel
let comicBookList: [ComicBook]
let currentPath: String
let title: String
let parentPath: String
let directoryContents: [DirectoryEntry]
let downloadingState: [DownloadingState]
let loading: Bool

let onLoadDirectory: (String, Bool) -> Void
let onDownloadFile: (String, String) -> Void

var body: some View {
BrowseServerView(
path: self.variantViewModel.browsingState.currentPath,
title: self.variantViewModel.browsingState.title,
parentPath: self.variantViewModel.browsingState.parentPath,
directoryContents: self.variantViewModel.browsingState.contents,
downloadingState: self.variantViewModel.browsingState
.downloadingState,
loading: self.variantViewModel.loading,
onLoadDirectory: { path, reload in
Log().debug(
tag: TAG,
message: "Loading path: \(path) reload=\(reload)"
)
self.variantViewModel.loadDirectory(
path: path,
reload: reload
)
},
onDownloadFile: { path, filename in
Task {
Log().debug(
tag: TAG,
message: "Downloading file: \(filename)"
)

self.variantViewModel.downloadFile(
path: path,
filename: filename
)
}
}
comicBookList: comicBookList,
path: currentPath,
title: title,
parentPath: parentPath,
directoryContents: directoryContents,
downloadingState: downloadingState,
loading: loading,
onLoadDirectory: onLoadDirectory,
onDownloadFile: onDownloadFile
)
}
}

#Preview {
ServerView()
ServerView(
comicBookList: COMIC_BOOK_LIST,
currentPath: "The current path",
title: "The Title",
parentPath: "The parent path",
directoryContents: DIRECTORY_LIST,
downloadingState: [],
loading: false,
onLoadDirectory: { _, _ in },
onDownloadFile: { _, _ in }
)
}
Loading