Skip to content

Commit

Permalink
viewPostion for Sheet is created, and sheet is complte
Browse files Browse the repository at this point in the history
  • Loading branch information
Zahlkovsk1 committed Aug 2, 2024
1 parent 1d5af70 commit e725d45
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 230 deletions.
14 changes: 13 additions & 1 deletion Bilbary for iPhone/Viiews/CustomSheetView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,30 @@ struct CustomSheetView: View {
private var activeTab: TabModel.Tab = .book
@State private var mainViewScrollState: TabModel.Tab?
@State private var tabBarScrollState: TabModel.Tab?
@State private var screenHeight = UIScreen.main.bounds.height
@State private var heightSpacing: CGFloat = 30

var body: some View {

VStack {
Spacer().frame(height: 30)
Spacer().frame(height: heightSpacing)
CustomTabBar()
.padding()

ViewScroller()

Spacer()
}
.viewPosition { value in
let minValue = screenHeight * 0.84
let clampedValue = value.clamped(to: minValue...minValue + 30)
let height = clampedValue - minValue
if height.truncatingRemainder(dividingBy: 3) == 0 {
withAnimation {
heightSpacing = height
}
}
}

.onReceive(self.timer) { _ in
timeSpent = appUsageTracker.computeTimeSpentToday(sessions)
Expand Down
62 changes: 0 additions & 62 deletions Bilbary for iPhone/Viiews/TabGridView.swift

This file was deleted.

48 changes: 0 additions & 48 deletions Bilbary for iPhone/iiPhone Models/CustomSheetDragGesture.swift

This file was deleted.

37 changes: 0 additions & 37 deletions Bilbary for iPhone/iiPhone Models/SheetCoordinator.swift

This file was deleted.

1 change: 0 additions & 1 deletion Bilbary for iPhone/iiPhone Models/SheetMask.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ private struct SheetRootViewFinder: UIViewRepresentable {
size: .init(width: window.frame.width, height: window.frame.height - (self.mask ? (height) : height + 0.1)
))


rootView.clipsToBounds = true
rootView.frame = newFrame
rootView.layoutIfNeeded()
Expand Down
33 changes: 33 additions & 0 deletions Bilbary for iPhone/iiPhone Models/SheetPosition.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// SheetPosition.swift
// Bilbary for iPhone
//
// Created by SHOHJAHON on 02/08/24.
//

import SwiftUI

// Custom View Extension which will return View Position

struct PositionKey: PreferenceKey {
static var defaultValue: CGFloat = .zero

static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) {
value = nextValue()
}
}
extension View {
@ViewBuilder
func viewPosition( completion: @escaping (CGFloat) -> Void) -> some View {
self
.overlay {
GeometryReader {
let y = $0.frame(in: .global).minY

Color.clear
.preference(key: PositionKey.self, value: y)
.onPreferenceChange(PositionKey.self, perform: completion)
}
}
}
}
65 changes: 0 additions & 65 deletions Bilbary for iPhone/iiPhone Models/TabButtonItem.swift

This file was deleted.

20 changes: 4 additions & 16 deletions Bilbary.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
463CEDD82B854579001D951C /* Book.swift in Sources */ = {isa = PBXBuildFile; fileRef = 463CEDD72B854579001D951C /* Book.swift */; };
463CEDDA2B8545E0001D951C /* BookInformationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 463CEDD92B8545E0001D951C /* BookInformationView.swift */; };
463CEDE62B8559E3001D951C /* Bilbary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 463CEDE52B8559E3001D951C /* Bilbary.swift */; };
463CEDF22B855D00001D951C /* TabButtonItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 463CEDF12B855D00001D951C /* TabButtonItem.swift */; };
463CEDFA2B8569BE001D951C /* BilbaryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 463CEDF92B8569BE001D951C /* BilbaryView.swift */; };
463EBC182B91CE9400BB9A57 /* Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = 463EBC172B91CE9400BB9A57 /* Utilities.swift */; };
463EBC192B91CE9400BB9A57 /* Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = 463EBC172B91CE9400BB9A57 /* Utilities.swift */; };
Expand Down Expand Up @@ -144,9 +143,7 @@
46A5FE502B923CBD00C46368 /* SwiftSoup in Frameworks */ = {isa = PBXBuildFile; productRef = 46A5FE4F2B923CBD00C46368 /* SwiftSoup */; };
650AFE102C3E8B4700FEA8D0 /* determineHigherValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 650AFE0F2C3E8B4700FEA8D0 /* determineHigherValue.swift */; };
650AFE122C3E8B7B00FEA8D0 /* timerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 650AFE112C3E8B7B00FEA8D0 /* timerView.swift */; };
650C44C72C43239100F414A7 /* SheetCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 650C44C62C43239100F414A7 /* SheetCoordinator.swift */; };
650C44CB2C43DE8400F414A7 /* TabGridView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 650C44CA2C43DE8400F414A7 /* TabGridView.swift */; };
650C44D32C43EC9F00F414A7 /* CustomSheetDragGesture.swift in Sources */ = {isa = PBXBuildFile; fileRef = 650C44D22C43EC9F00F414A7 /* CustomSheetDragGesture.swift */; };
651B80C52C5D34D600AACB35 /* SheetPosition.swift in Sources */ = {isa = PBXBuildFile; fileRef = 651B80C42C5D34D600AACB35 /* SheetPosition.swift */; };
654551DE2C51066F0049B59B /* TabModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 654551DD2C51066F0049B59B /* TabModel.swift */; };
654551E72C510C9A0049B59B /* Media.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 654551E62C510C9A0049B59B /* Media.xcassets */; };
655B17602C53AD0F00507A3F /* SheetMask.swift in Sources */ = {isa = PBXBuildFile; fileRef = 655B175F2C53AD0F00507A3F /* SheetMask.swift */; };
Expand Down Expand Up @@ -217,7 +214,6 @@
463CEDD92B8545E0001D951C /* BookInformationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookInformationView.swift; sourceTree = "<group>"; };
463CEDE32B8559E3001D951C /* Bilbary for iPhone.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Bilbary for iPhone.app"; sourceTree = BUILT_PRODUCTS_DIR; };
463CEDE52B8559E3001D951C /* Bilbary.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Bilbary.swift; sourceTree = "<group>"; };
463CEDF12B855D00001D951C /* TabButtonItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabButtonItem.swift; sourceTree = "<group>"; };
463CEDF92B8569BE001D951C /* BilbaryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BilbaryView.swift; sourceTree = "<group>"; wrapsLines = 1; };
463EBC172B91CE9400BB9A57 /* Utilities.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Utilities.swift; sourceTree = "<group>"; };
463EBC1A2B91DD4800BB9A57 /* Book+BookCover.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Book+BookCover.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -247,9 +243,7 @@
46A485B82B87392B00C6C7E3 /* EPUBView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EPUBView.swift; sourceTree = "<group>"; };
650AFE0F2C3E8B4700FEA8D0 /* determineHigherValue.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = determineHigherValue.swift; sourceTree = "<group>"; };
650AFE112C3E8B7B00FEA8D0 /* timerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = timerView.swift; sourceTree = "<group>"; };
650C44C62C43239100F414A7 /* SheetCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SheetCoordinator.swift; sourceTree = "<group>"; };
650C44CA2C43DE8400F414A7 /* TabGridView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabGridView.swift; sourceTree = "<group>"; };
650C44D22C43EC9F00F414A7 /* CustomSheetDragGesture.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomSheetDragGesture.swift; sourceTree = "<group>"; };
651B80C42C5D34D600AACB35 /* SheetPosition.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SheetPosition.swift; sourceTree = "<group>"; };
654551DD2C51066F0049B59B /* TabModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabModel.swift; sourceTree = "<group>"; };
654551E62C510C9A0049B59B /* Media.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Media.xcassets; sourceTree = "<group>"; };
655B175F2C53AD0F00507A3F /* SheetMask.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SheetMask.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -619,7 +613,6 @@
650C44CC2C43E14200F414A7 /* Viiews */ = {
isa = PBXGroup;
children = (
650C44CA2C43DE8400F414A7 /* TabGridView.swift */,
65BCDC562C42E5D60064FBBD /* CustomSheetView.swift */,
463CEDF92B8569BE001D951C /* BilbaryView.swift */,
650AFE112C3E8B7B00FEA8D0 /* timerView.swift */,
Expand All @@ -630,13 +623,11 @@
650C44CF2C43E1A100F414A7 /* iiPhone Models */ = {
isa = PBXGroup;
children = (
650C44C62C43239100F414A7 /* SheetCoordinator.swift */,
650C44D22C43EC9F00F414A7 /* CustomSheetDragGesture.swift */,
650AFE0F2C3E8B4700FEA8D0 /* determineHigherValue.swift */,
651B80C42C5D34D600AACB35 /* SheetPosition.swift */,
65BCDC582C42EF860064FBBD /* extensions.swift */,
46724EBA2C40614B009254EB /* AppModel.swift */,
655B175F2C53AD0F00507A3F /* SheetMask.swift */,
463CEDF12B855D00001D951C /* TabButtonItem.swift */,
);
path = "iiPhone Models";
sourceTree = "<group>";
Expand Down Expand Up @@ -948,19 +939,15 @@
65F2FD892C4562E400D455BC /* FadeOut.metal in Sources */,
464F8F2F2B913BB4009102CB /* UIWindow.swift in Sources */,
462E0DD92B87E9B1001D2161 /* PressActions.swift in Sources */,
650C44C72C43239100F414A7 /* SheetCoordinator.swift in Sources */,
463CEDF22B855D00001D951C /* TabButtonItem.swift in Sources */,
65BCDC522C42CF360064FBBD /* RPopover.swift in Sources */,
463EBC3A2B9223E800BB9A57 /* PermissionsModel.swift in Sources */,
650C44D32C43EC9F00F414A7 /* CustomSheetDragGesture.swift in Sources */,
65BCDC532C42CF4C0064FBBD /* RButton.swift in Sources */,
463EBC2D2B9223CF00BB9A57 /* Book.swift in Sources */,
463EBC2E2B9223D900BB9A57 /* RCustomizerModel+RCustomizerModelStorage.swift in Sources */,
463EBC362B9223E300BB9A57 /* GoalModelStorage.swift in Sources */,
462E0DF12B88A87C001D2161 /* GoalReadTime.swift in Sources */,
463EBC1F2B91F7A400BB9A57 /* Book+BookContent.swift in Sources */,
463EBC222B91FA3500BB9A57 /* Book+Equatable.swift in Sources */,
650C44CB2C43DE8400F414A7 /* TabGridView.swift in Sources */,
65BCDC542C42CF510064FBBD /* RBarRow.swift in Sources */,
463EBC392B9223E300BB9A57 /* GoalStreakDuration.swift in Sources */,
46724EBB2C40614B009254EB /* AppModel.swift in Sources */,
Expand All @@ -987,6 +974,7 @@
650AFE122C3E8B7B00FEA8D0 /* timerView.swift in Sources */,
463EBC3D2B9223EF00BB9A57 /* UNHelper.swift in Sources */,
650AFE102C3E8B4700FEA8D0 /* determineHigherValue.swift in Sources */,
651B80C52C5D34D600AACB35 /* SheetPosition.swift in Sources */,
463EBC302B9223D900BB9A57 /* RCColor.swift in Sources */,
463EBC352B9223D900BB9A57 /* RCFontFace.swift in Sources */,
463EBC252B91FA5900BB9A57 /* Book+Hashable.swift in Sources */,
Expand Down

0 comments on commit e725d45

Please sign in to comment.