Skip to content

Commit

Permalink
fixed the floating button
Browse files Browse the repository at this point in the history
  • Loading branch information
s4rv4d committed Aug 7, 2020
1 parent 880ae83 commit ae681a7
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 38 deletions.
8 changes: 6 additions & 2 deletions docWind.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
40D170AC24ADA93000F51F77 /* MainDocViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40D170AB24ADA93000F51F77 /* MainDocViewModel.swift */; };
40D170AF24ADA95700F51F77 /* CustomNavBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40D170AE24ADA95700F51F77 /* CustomNavBarView.swift */; };
40D170B224ADA9DE00F51F77 /* DocWindFManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40D170B124ADA9DE00F51F77 /* DocWindFManager.swift */; };
40D1B12124DC4E7D00859F1A /* SecondaryButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40D1B12024DC4E7D00859F1A /* SecondaryButtonView.swift */; };
40DD4F7324C02CDC00D37EFA /* SignaturePageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40DD4F7224C02CDC00D37EFA /* SignaturePageView.swift */; };
40DD4F7524C02F3700D37EFA /* ImageAnnotation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40DD4F7424C02F3700D37EFA /* ImageAnnotation.swift */; };
40DD4F7724C087AE00D37EFA /* ImagePanGestureRecognizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40DD4F7624C087AE00D37EFA /* ImagePanGestureRecognizer.swift */; };
Expand Down Expand Up @@ -170,6 +171,7 @@
40D170AB24ADA93000F51F77 /* MainDocViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainDocViewModel.swift; sourceTree = "<group>"; };
40D170AE24ADA95700F51F77 /* CustomNavBarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomNavBarView.swift; sourceTree = "<group>"; };
40D170B124ADA9DE00F51F77 /* DocWindFManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DocWindFManager.swift; sourceTree = "<group>"; };
40D1B12024DC4E7D00859F1A /* SecondaryButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecondaryButtonView.swift; sourceTree = "<group>"; };
40DD4F7224C02CDC00D37EFA /* SignaturePageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignaturePageView.swift; sourceTree = "<group>"; };
40DD4F7424C02F3700D37EFA /* ImageAnnotation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageAnnotation.swift; sourceTree = "<group>"; };
40DD4F7624C087AE00D37EFA /* ImagePanGestureRecognizer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImagePanGestureRecognizer.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -362,6 +364,7 @@
4069EFA024D69D4C003083C6 /* CustomSearchBar.swift */,
40CFB04C24D9794100955957 /* DocumentPickerView.swift */,
402333ED24DA9247007FE8C6 /* ImagePickerView.swift */,
40D1B12024DC4E7D00859F1A /* SecondaryButtonView.swift */,
);
path = "Custom View";
sourceTree = "<group>";
Expand Down Expand Up @@ -609,6 +612,7 @@
40FDE49524AC4C3D006AAFD2 /* IntroView.swift in Sources */,
406E9AFB24B617EE000FB8FD /* CustomHeaderView.swift in Sources */,
40FDE48324AB964B006AAFD2 /* ContentView.swift in Sources */,
40D1B12124DC4E7D00859F1A /* SecondaryButtonView.swift in Sources */,
40EF462C24B4ADF700D07A06 /* ConfPdfView.swift in Sources */,
40D170B224ADA9DE00F51F77 /* DocWindFManager.swift in Sources */,
40FDE49C24AC4EC9006AAFD2 /* Helper+Struct.swift in Sources */,
Expand Down Expand Up @@ -786,7 +790,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.4;
MARKETING_VERSION = 1.5;
PRODUCT_BUNDLE_IDENTIFIER = com.sarvadShetty.docWind;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -810,7 +814,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.4;
MARKETING_VERSION = 1.5;
PRODUCT_BUNDLE_IDENTIFIER = com.sarvadShetty.docWind;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand Down
34 changes: 34 additions & 0 deletions docWind/Custom View/SecondaryButtonView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// SecondaryButtonView.swift
// docWind
//
// Created by Sarvad shetty on 8/6/20.
// Copyright © 2020 Sarvad shetty. All rights reserved.
//

import SwiftUI

struct SecondaryButtonView: View {

@Binding var tapped: Bool
var icon = "pencil"
var color = Color.blue
var offsetX = 0
var offsetY = 0
var delay = 0.0
let action: () -> Void

var body: some View {
Button(action: action) {
Image(systemName: icon)
.foregroundColor(.white)
.font(.body)
}
.padding()
.background(color)
.mask(Circle())
.offset(x: tapped ? CGFloat(offsetX) : 0, y: tapped ? CGFloat(offsetY) : 0)
.scaleEffect(tapped ? 1 : 0.5)
.animation(Animation.spring(response: 0.2, dampingFraction: 0.5, blendDuration: 0).delay(Double(delay)))
}
}
4 changes: 2 additions & 2 deletions docWind/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@
<string>We need access to your camera to scan documents </string>
<key>NSFaceIDUsageDescription</key>
<string>To unlock app to access it features</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Need access to library to add images to scanned documents</string>
<key>NSUbiquitousContainers</key>
<dict>
<key>com.sarvadShetty.docWindProduction</key>
Expand Down Expand Up @@ -177,7 +179,5 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>NSPhotoLibraryUsageDescription</key>
<string>Need access to library to add images to scanned documents</string>
</dict>
</plist>
80 changes: 46 additions & 34 deletions docWind/Views/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import CoreData
struct ContentView: View {

//MARK: - @State variables
@State private var tapped = false
@State private var isShown = false
@State private var showingActionSheet = false
// @State private var showingActionSheet = false
@State var activeSheet: ActiveContentViewSheet = .intro
@State private var presentAlert = false
@State private var toggleSearchIcon = false
Expand All @@ -34,14 +35,14 @@ struct ContentView: View {
// MARK: - Properties
var body: some View {
NavigationView {
ZStack {
VStack {
VStack(alignment: .leading) {
//check if contents isnt empty
if items.first != nil {
// display contents of file
if (items.first!.fileArray.count == 0) {
NewStarterView()
.padding()
// NewStarterView()
// .padding()
} else {
List {
Section(header: Text("DocWind >").font(.caption), footer: Text("Tap on hold on a cell for more options").font(.caption)) {
Expand All @@ -53,20 +54,38 @@ struct ContentView: View {
.listStyle(GroupedListStyle())
}
} else {
NewStarterView()
.padding()
// NewStarterView()
// .padding()
}
}

VStack {
Spacer()
Button(action: {}) {
Image(systemName: "plus")
.foregroundColor(.blue)
.padding()
// VStack {

ZStack(alignment: .bottom) {
Rectangle().onTapGesture {
print("saravad")
}
.background(Circle()
.opacity(0.2))
.foregroundColor(.clear)
.frame(maxWidth: .infinity, maxHeight: .infinity)
Button(action: showOptions) {
Image(systemName: "plus")
.rotationEffect(.degrees(tapped ? 45 : 0))
.foregroundColor(.white)
.font(.title)
.animation(.spring(response: 0.2, dampingFraction: 0.4, blendDuration: 0))
}
.padding(24)
.background(Color.blue)
.mask(Circle())
.animation(.spring(response: 0.2, dampingFraction: 0.4, blendDuration: 0))
.zIndex(10)
.padding()
// secondary buttons
SecondaryButtonView(tapped: $tapped, icon: "folder.fill", color: .blue, offsetX: 90, action: createDiectory).padding()
SecondaryButtonView(tapped: $tapped, icon: "camera.fill", color: .blue, offsetY: -90, delay: 0.2, action: scanDocumentTapped).padding()
SecondaryButtonView(tapped: $tapped, icon: "arrow.up.doc.fill", color: .blue, offsetX: -90, delay: 0.4, action: {
print("yooo")
}).padding()
}
}

Expand All @@ -77,12 +96,7 @@ struct ContentView: View {
Image(systemName: "gear")
.font(.system(size: 20))
.foregroundColor(.blue)
}
,trailing:
Button(action: showOptions){
Text("Add")
}
)
})
.add(self.searchBar)

}
Expand Down Expand Up @@ -110,16 +124,6 @@ struct ContentView: View {
}
}

// action sheet code
.actionSheet(isPresented: $showingActionSheet) {
ActionSheet(title: Text("Options"), message: Text("Choose an option"), buttons: [
.default(Text("Create a new document"), action: scanDocumentTapped),
.default(Text("Create a new directory"), action: createDiectory),
.default(Text("Import a document"), action: importTapped),
.cancel()
])
}

.alert(isPresented: $showAlert) {
Alert(title: Text(self.alertTitle), message: Text(self.alertMessage), dismissButton: .cancel(Text("Dismiss"), action: {
print("retry")
Expand All @@ -138,24 +142,31 @@ struct ContentView: View {
}

private func showOptions() {
FeedbackManager.mediumFeedback()
self.showingActionSheet.toggle()
DispatchQueue.main.async {
withAnimation {
self.tapped.toggle()
}
}
}

private func createDiectory() {
self.activeSheet = .createdDirec
self.tapped.toggle()
self.isShown.toggle()
}

private func importTapped() {
self.activeSheet = .importDoc
self.isShown.toggle()
print("ere")
// self.activeSheet = .importDoc
// self.tapped.toggle()
// self.isShown.toggle()
}

private func scanDocumentTapped() {
print("❇️ SCAN DOC TAPPED")
//bring uo editing page
self.activeSheet = .createPdf
self.tapped.toggle()
self.isShown.toggle()
//add pages and saves
}
Expand Down Expand Up @@ -208,3 +219,4 @@ struct ContentView: View {
}
}
}

0 comments on commit ae681a7

Please sign in to comment.