Skip to content

Commit

Permalink
Library Refactoring (#9)
Browse files Browse the repository at this point in the history
* Tidying things again

* Library Refactoring

A lot has been going on
  • Loading branch information
g-cqd committed Mar 4, 2024
1 parent bc74d5c commit 9107d2d
Show file tree
Hide file tree
Showing 75 changed files with 1,918 additions and 1,164 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// BilbaryApp.swift
// Bilbary.swift
// iits
//
// Created by Guillaume Coquard on 13/02/24.
Expand All @@ -8,10 +8,10 @@
import SwiftUI

@main
struct BilbaryApp: App {
struct Bilbary: App {
var body: some Scene {
WindowGroup {
MainView()
BilbaryView()
}
}
}
36 changes: 36 additions & 0 deletions Bilbary for iPad/BilbaryView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// BilbaryView.swift
// iits
//
// Created by Guillaume Coquard on 13/02/24.
//

import SwiftUI
import OSLog

struct BilbaryView: View {

@State
private var view: RViewModel = .shared

var body: some View {
HStack(spacing: 0) {
LibraryView()
Divider()
.padding(0)
.opacity(view.isLibraryOpen ? 1 : 0)
ContentView()
}
.padding(0)
.ignoresSafeArea()
.orientationUpdatesScreen()
.sheet(isPresented: $view.displayOnboarding) {
OnboardingView()
}

}
}

#Preview {
BilbaryView()
}
40 changes: 0 additions & 40 deletions Bilbary for iPad/MainView.swift

This file was deleted.

79 changes: 0 additions & 79 deletions Bilbary for iPad/Views/BookInformationView.swift

This file was deleted.

17 changes: 0 additions & 17 deletions Bilbary for iPad/Views/BookPlaceholder.swift

This file was deleted.

1 change: 1 addition & 0 deletions Bilbary for iPad/Views/Components/RButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,5 +139,6 @@ struct RButton<L>: RActionable, View {
.onRelease {
self.isActive = false
}
.disabled(!isShown)
}
}
9 changes: 5 additions & 4 deletions Bilbary for iPad/Views/Components/RPopover.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ struct RPopover<L, P>: RActionable, View {
switch view.isTogglable(self.type) {
case 0:
self.isPresented.toggle()
view.setPopover(to: self.type)
view.updatePopover(to: self.type)
case 1:
self.isPresented.toggle()
default:
view.setPopover(to: .none)
view.updatePopover(to: .none)
}
}

Expand Down Expand Up @@ -135,12 +135,13 @@ struct RPopover<L, P>: RActionable, View {
) {
self.popover
.onAppear {
view.setPopover(to: self.type)
view.updatePopover(to: self.type)
}
.onDisappear {
view.setPopover(to: .none)
view.updatePopover(to: .none)
}
}
)
.disabled(!view.isInterfaceVisible)
}
}
2 changes: 1 addition & 1 deletion Bilbary for iPad/Views/Components/RReadingTimeMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct RReadingTimeMenu: View {

var body: some View {
RButton(
isShown: $viewModel.interfaceVisibility,
isShown: $viewModel.isInterfaceVisible,
linkedTo: .readingTime
) {
logger.log("sds")
Expand Down
4 changes: 2 additions & 2 deletions Bilbary for iPad/Views/ContentView/BottomBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct BottomBar: View {
var body: some View {
RBarRow {
RPopover(
isShown: $view.interfaceVisibility,
isShown: $view.isInterfaceVisible,
title: NSLocalizedString(
"Informations",
comment: "Information about the current open book"
Expand All @@ -41,7 +41,7 @@ struct BottomBar: View {
}
} trailing: {
RPopover(
isShown: $view.interfaceVisibility,
isShown: $view.isInterfaceVisible,
title: NSLocalizedString("Text Customization", comment: ""),
systemImage: "textformat.size",
type: .customization
Expand Down
44 changes: 25 additions & 19 deletions Bilbary for iPad/Views/ContentView/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,43 @@ struct ContentView: View {
private let logger: Logger = .views

var body: some View {
NavigationStack(path: $view.contentPath) {
ScrollView(.horizontal) {
ScrollView(.horizontal) {
NavigationStack(path: $view.contentPath) {
VStack(spacing: 0) {
TopBar()
.padding(.horizontal, 74)
EPUBView()
BottomBar()
.padding(.horizontal, 74)
}
.padding(100)
.padding(.vertical, 64)
.safeAreaPadding()
.frame(minWidth: view.proxy?.size.width ?? UIWindow.current?.screen.bounds.width)
.frame(maxWidth: view.proxy?.size.width ?? UIWindow.current?.screen.bounds.width)
.frame(minWidth: view.screenWidth)
.frame(maxWidth: view.screenWidth)
.toolbar(.hidden, for: .navigationBar)
.toolbar(.hidden, for: .tabBar)
.toolbar(.hidden, for: .bottomBar)
}
.scrollDisabled(true)
.onTapGesture {
withAnimation {
if !view.libraryVisibility {
logger.info("\(String(describing: view.isAnyPopoverDisplayed))")
logger.info("\(String(describing: view.activePopover))")
if !view.isAnyPopoverDisplayed {
view.interfaceVisibility.toggle()
}
} else {
view.libraryVisibility.toggle()
}
.frame(minWidth: view.screenWidth)
.frame(maxWidth: view.screenWidth)
.fixedSize(horizontal: true, vertical: false)
}
.safeAreaPadding()
.scrollDisabled(true)
.contentShape(Rectangle())
.onTapGesture {
withAnimation {
if !view.isAnyPopoverDisplayed {
view.isInterfaceVisible.toggle()
} else
if view.isLibraryOpen {
view.toggleLibrary()
}
}
.contentShape(Rectangle())
.toolbar(.hidden, for: .navigationBar)
}
}
}

#Preview {
ContentView(book: nil)
}
11 changes: 7 additions & 4 deletions Bilbary for iPad/Views/ContentView/TopBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,22 @@ struct TopBar: View {

RBarRow {
RButton(
isShown: $view.interfaceVisibility,
title: NSLocalizedString("Library", comment: "Library"),
isShown: $view.isInterfaceVisible,
title: NSLocalizedString(
"Library",
comment: "Library"
),
systemImage: "books.vertical",
systemImageActive: "books.vertical.fill",
linkedTo: .library
) {
view.libraryVisibility.toggle()
view.toggleLibrary()
}
} center: {
RReadingTimeMenu()
} trailing: {
RPopover(
isShown: $view.interfaceVisibility,
isShown: $view.isInterfaceVisible,
title: NSLocalizedString("Streak", comment: ""),
systemImage: "timer",
type: .goalStreak
Expand Down
49 changes: 49 additions & 0 deletions Bilbary for iPad/Views/EPUB/EPUBScrollableContent.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//
// EPUBScrollableContent.swift
// Bilbary
//
// Created by Guillaume Coquard on 03/03/24.
//

import SwiftUI

struct EPUBScrollableContent: View {

@State
private var view: RViewModel = .shared

var book: Book

var body: some View {
VStack {
ScrollView {
VStack {
ForEach((book.content?.strings ?? []).prefix(10), id: \.self) { paragraph in
VStack {
Text(paragraph)
}
.frame(maxWidth: .infinity)
.padding(.vertical)
}
}
.font(.title2)
.fontDesign(.serif)
.frame(minHeight: 200)
.frame(maxWidth: .infinity)
.padding(0)
}
.padding(0)
}
.padding(.vertical, 0)
.padding(.horizontal, 64)
// .frame(minWidth: view.screenWidth - 128)
// .frame(width: view.screenWidth - 128)
// .frame(maxWidth: view.screenWidth - 128)
.containerRelativeFrame(
.horizontal,
count: 1,
spacing: 128,
alignment: .center
)
}
}
Loading

0 comments on commit 9107d2d

Please sign in to comment.