Skip to content

Commit

Permalink
Merge pull request #18 from Econa77/cleanup-codes
Browse files Browse the repository at this point in the history
Typo fixes and code style unification
  • Loading branch information
gh123man authored Oct 17, 2023
2 parents 68468cd + 21d485e commit 2ddcc6e
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 60 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
{
"object": {
"pins": [
{
"package": "swiftui-introspect",
"repositoryURL": "https://github.com/siteline/SwiftUI-Introspect.git",
"state": {
"branch": null,
"revision": "1136c9a348329887844de9353107c787becc675b",
"version": "0.11.0"
}
"pins" : [
{
"identity" : "swiftui-introspect",
"kind" : "remoteSourceControl",
"location" : "https://github.com/siteline/SwiftUI-Introspect.git",
"state" : {
"revision" : "3ced72fccb284235c266c1e8a32f1bf93129fc74",
"version" : "1.1.0"
}
]
},
"version": 1
}
],
"version" : 2
}
2 changes: 0 additions & 2 deletions Sources/Refresher/BlurView.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#if canImport(UIKit)
import Foundation
import SwiftUI
Expand All @@ -21,5 +20,4 @@ struct BlurView: UIViewRepresentable {
uiView.effect = UIBlurEffect(style: self.style)
}
}

#endif
4 changes: 0 additions & 4 deletions Sources/Refresher/DefaultRefreshView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Foundation
import SwiftUI

struct UIActivityView: UIViewRepresentable {

var style: UIActivityIndicatorView.Style = .medium
@Binding var isAnimating: Bool

Expand All @@ -22,9 +21,7 @@ struct UIActivityView: UIViewRepresentable {
}
}


public struct DefaultRefreshView: View {

@Binding var state: RefresherState
@State var isAnimating = false

Expand Down Expand Up @@ -58,4 +55,3 @@ public struct DefaultRefreshView: View {
}
}
}

6 changes: 0 additions & 6 deletions Sources/Refresher/Math.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
//
// File.swift
//
//
// Created by Brian Floersch on 4/19/22.
//
#if canImport(UIKit)
import Foundation
import UIKit
Expand Down
2 changes: 1 addition & 1 deletion Sources/Refresher/OffsetReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import Foundation
import SwiftUI

struct OffsetReader: View {

var onChange: (CGFloat) -> ()
@State private var frame = CGRect()

public var body: some View {
GeometryReader { geometry in
Spacer(minLength: 0)
Expand Down
16 changes: 6 additions & 10 deletions Sources/Refresher/Refresher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public struct Config {
}

public enum Style {

/// Spinner pulls down and centers on a padding view above the scrollview
case `default`

Expand All @@ -77,7 +76,6 @@ public enum RefreshMode {
}

public struct RefresherState {

/// Updated without animation - NOTE: Both modes are always updated in sequence (this one is first)
public var mode: RefreshMode = .notRefreshing

Expand Down Expand Up @@ -161,7 +159,7 @@ public struct RefreshableScrollView<Content: View, RefreshView: View>: View {
}

@ViewBuilder
private var refershSpinner: some View {
private var refreshSpinner: some View {
if style == .default || style == .overlay {
RefreshSpinnerView(offScreenPoint: config.defaultSpinnerOffScreenPoint,
pullClipPoint: config.defaultSpinnerPullClipPoint,
Expand All @@ -176,7 +174,7 @@ public struct RefreshableScrollView<Content: View, RefreshView: View>: View {
}

@ViewBuilder
private var systemStylerefreshSpinner: some View {
private var systemStyleRefreshSpinner: some View {
if style == .system {
SystemStyleRefreshSpinner(opacityClipPoint: config.systemSpinnerOpacityClipPoint,
state: state,
Expand All @@ -188,7 +186,7 @@ public struct RefreshableScrollView<Content: View, RefreshView: View>: View {
}

@ViewBuilder
private var system2StylerefreshSpinner: some View {
private var system2StyleRefreshSpinner: some View {
if style == .system2 {
System2StyleRefreshSpinner(opacityClipPoint: config.systemSpinnerOpacityClipPoint,
state: state,
Expand All @@ -207,9 +205,8 @@ public struct RefreshableScrollView<Content: View, RefreshView: View>: View {
OffsetReader { val in
offsetChanged(val)
}
systemStylerefreshSpinner
system2StylerefreshSpinner

systemStyleRefreshSpinner
system2StyleRefreshSpinner

// Content wrapper with refresh banner
VStack(spacing: 0) {
Expand All @@ -219,7 +216,7 @@ public struct RefreshableScrollView<Content: View, RefreshView: View>: View {
.offset(y: refreshHeaderOffset)
}
// renders over content
refershSpinner
refreshSpinner
}
}
.introspect(.scrollView, on: .iOS(.v14, .v15, .v16, .v17)) { scrollView in
Expand All @@ -243,7 +240,6 @@ public struct RefreshableScrollView<Content: View, RefreshView: View>: View {
distance = val - headerInset
state.dragPosition = normalize(from: 0, to: config.refreshAt, by: distance)


// If the refresh state has settled, we are not touching the screen, and the offset has settled, we can signal the view to update itself.
if canRefresh, !isFingerDown, distance <= 0 {
renderLock = false
Expand Down
24 changes: 0 additions & 24 deletions Sources/Refresher/RenderControl.swift
Original file line number Diff line number Diff line change
@@ -1,30 +1,6 @@
import Foundation
import SwiftUI

struct DeferedRenderView<Content: View>: View {
struct DeferableView: View, Equatable {
@Binding var signal: Bool
@ViewBuilder var content: Content

static func == (lhs: DeferableView, rhs: DeferableView) -> Bool {
lhs.signal == rhs.signal
}

var body: some View {
content
}
}

@Binding var signal: Bool
@ViewBuilder var content: Content

public var body: some View {
return DeferableView(signal: $signal) {
content
}.equatable()
}
}

struct LockedRenderView<Content: View>: View {
struct LockedView: View, Equatable {
@Binding var lock: Bool
Expand Down

0 comments on commit 2ddcc6e

Please sign in to comment.