Giter Site home page Giter Site logo

ipages's People

Contributors

alexfine avatar blsage avatar devyhan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ipages's Issues

Examples need to be relocated

Currently the example file adds two dependencies to every project that aren’t needed.

You should’ve created a new folder called “Example” at the root of the repo with an example Xcode project.

Crush and Swipes

iPages {
            ForEach(0..<10) {
                Text("Index \($0)")
            }
        }

Will swipe itself

and if I set array in forEach I get error:

Fatal error: Index out of range: file Swift/ContiguousArrayBuffer.swift, line 444

Снимок экрана 2020-11-02 в 15 53 05

Change state in parent view of iPage will trigger unwanted animation

Hi there, thanks for the quick fix yesterday now it works like charm!

Just encounter another issue, when I change the state of iPage parents view, iPage will trigger an unwanted animation.

Example code:

struct TabViewParentView: View {
    @State var selectedIndex: Int = 0
    @State var tabViewIsHidden: Bool = false

    var body: some View {
        ZStack {
            iPages(selection: $selectedIndex) {
                ProfileView()
                SecondView()
                ThirdView()
            }
            .hideDots(true)

            VStack {
                Button {
                    tabViewIsHidden = !tabViewIsHidden
                } label: {
                    Text("HELLO THERE!")
                }

                Spacer()

                Text("TEXT")
                    .foregroundColor(.white)
                    .opacity(tabViewIsHidden ? 0 : 1)
            }
        }
    }

}

When the button pressed and @State tabViewIsHidden was changed, the iPage will scroll to the same page with animation:

Demo:

Screen Recording 2020-10-27 at 1 30 29 pm

I wonder if it is possible to prevent this? This is needed for making my custom tab view control, I was making an auto dismissed tab view control, but when I change the state, this unwanted animation was triggered.

Observable object with iPages

So, first of all, I'm a total SwiftUI beginner so bare with me.

I'm working on my first app in which I would like a page view controller that allows me to swipe between views. In my app I'm fetching calendar events which I'm accessing in my views through an observable object. The problem is that when I'm trying to access my observed object in iPages, the array is empty and I can't understand why. Here is a simplified example:

class EventsRepository: ObservableObject {
    static let shared = EventsRepository()
    // Code
    @Published var events: [EKEvent]?
    // Code
    let events = self.eventStore.events(matching: predicate)
}
import iPages
struct ContentView: View {
@ObservedObject var eventsRepository = EventsRepository.shared
@State private var currentPage = 0
    var body: some View {
    
        Text(String(describing: eventsRepository.events)) // This is **not** empty
        
        iPages(selection: $currentPage) {
            Text(String(describing: eventsRepository.events)) // This **is** nil
        }
    }
}

If this is not a problem with iPages I would really appreciate if you could try to explain to me what I'm doing wrong.

Thanks!

iPages doesn't detect window resizing on macOS

When I try to resize windows on macOS, iPages doesn't change its width/height to match the new window size.

Sample code:

import SwiftUI
import iPages

struct ExampleApp: App {
    @SceneBuilder var body: some Scene {
        WindowGroup {
            iPages {
                Text("Hello World")
                Text("Hello World")
                Text("Hello World")
                Text("Hello World")
            }
        }
    }
}

Eliminates some UI elements if inside VStacks

This is a bit of a weird one an potentially not iPages related. I'm curious if you can recreate this issue.

I was using the default apple PageTabViewStyle but saw this library and gave it a shot. My app has buttons that show up based on if statements. This worked fine with PagesTabView, but upon adding iPages, the buttons inside if statements disappear. If I remove the if statement the buttons pop back up.

Not quite sure what the issue is. I've attached my ContentView.swift file below, with most of my code removed for clarity.

`
import SwiftUI
import HealthKit
import HealthKitUI
import iPages

class SummaryHolder: ObservableObject {
@published var theSummary: HKActivitySummary = HKActivitySummary();
}

struct ContentView: View {
var body: some View {
iPages{
ZStack{
LinearGradient(gradient: Gradient(colors: [.black, Color("darkBlue")]),
startPoint: .topLeading,
endPoint: .bottomTrailing).ignoresSafeArea()
VStack {
VStack {
if movePercent >= 50 {
Button(action: /@START_MENU_TOKEN@//@Placeholder=Action@/{}/@END_MENU_TOKEN@/) {
DispenseButton(title: "One Spin",
textColor: .blue,
backgroundColor: .white)
}
}

                if movePercent >= 75 {
                Button(action: /*@START_MENU_TOKEN@*//*@PLACEHOLDER=Action@*/{}/*@END_MENU_TOKEN@*/) {
                    DispenseButton(title: "Two Spins",
                                   textColor: .blue,
                                   backgroundColor: .white)
                }
                }
                
                if movePercent >= 100 {
                Button(action: /*@START_MENU_TOKEN@*//*@PLACEHOLDER=Action@*/{}/*@END_MENU_TOKEN@*/) {
                    DispenseButton(title: "Three Spins",
                                   textColor: .blue,
                                   backgroundColor: .white)
                }
                }
                
                if movePercent < 50 {
                    Image(systemName: "exclamationmark.triangle.fill") .renderingMode(.original)
                        .resizable()
                        .aspectRatio(contentMode: .fit)
                        .frame(width: 180, height: 180, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
                    
                    Text("Get moving and try again later").font(.system(size: 20, weight: .bold, design: .default))
                        .foregroundColor(.white)
                        .padding().multilineTextAlignment(.center)
                }
            }
            Spacer()
        }
    }
        Text("Add Bluetooth Menu here").tabItem {
                Image(systemName: (selected == 0 ? "sun.fill" : "sun"))
                Text("Home")
            }
    }.hideDots(false).edgesIgnoringSafeArea(.all)
}

}

struct ContentView_Previews: PreviewProvider {
static var previews: some View {
Group {
ContentView()
}
}
}
`

Error when try to use combined with ForEach

Hello, I'm trying to fill iPages using ForEach but I get this error. "Thread 1: Fatal error: Index out of range", on line 78 of PageViewController.swift of the iPages project.

This is the correct code to use or not support dynamic views ?

Thanks

                    iPages {
                        ForEach(notifications, id: \.self) { notification in
                            VStack {
                                Text(notification.subject)
                                    .font(.title2)
                                    .fontWeight(/*@START_MENU_TOKEN@*/.bold/*@END_MENU_TOKEN@*/)
                                Text(notification.kind)
                                    .font(.title2)
                                Text(notification.updatedAt)
                                    .font(.title3)
                            }
                        }
                    }

Can't use custom Views

Hello!

Absolutely love the look of this but I've been struggling to get it working with custom views. I keep getting an error saying Cannot convert value of type someCustomView to closure result type '[UIViewController]'

Is there something I'm doing wrong?

Here's a screenshot of my code too:
Screenshot 2020-10-22 at 12 16 30

Thanks in advance!

Setting disableBounce to true breaks switching tab via binding

If you set disableBounce to true it's no longer possible to change the selected tab via the binding.

Edit: only the first and last tab aren't accessible via the binding. The navigation to tabs between them is still working.

Interactive example to reproduce:

struct ContentView: View {
    @State var selection = 0
    @State var bounceDisabled = false
    var body: some View {
        VStack {
            Button("Tab 0", action: { selection = 0 })
            Button("Tab 1", action: { selection = 1 })
            Button("Toggle bounce", action: { bounceDisabled.toggle() } )
            Text("Selected tab: \(selection)")
            Text(bounceDisabled ? "Bounce disabled" : "Bounce enabled")
            
            iPages(selection: $selection) {
                Text("Tab 0")
                Text("Tab 1")
            }
            .disableBounce(bounceDisabled)
        }
    }
}

After putting view inside iPage {}, change state will not update the child view

Hi, This is a nice package and quite easy to use.

Just encounter the issue: after putting my custom view inside an iPage view, all the child view lost the ability to react to state changes:

Example:

struct SetUpView: View {
    @State var foo: String = "Hello"

    var body: some View {
        ZStack {
            Text("\(foo)")

            Button("Button") {
                foo = "123"
            }
        }
        .ignoresSafeArea(.all)
    }
}

After putting this view inside iPage, when the button clicked, the text won't get changed.

            iPages {
                SetUpView()
            }
            .ignoresSafeArea(.all)

and it works normal when put outside the iPage block.

Any solution?

Selection binding brakes swiping

That's what happens when I try to scroll between several pages with selection binding:

Video:
https://streamable.com/aiva4p

Code:

struct TestView: View {
    @State var selectedIdx = 0

    var body: some View {
        iPages(selection: $selectedIdx) {
            Color.red
            Color.blue
            Color.yellow
        }
        .onChange(of: selectedIdx) { value in
            print("INDEX: \(value)")
         }
    }
}

iPages Review

Swiping is dope. Super natural spring. I really fuck with that. Similar to the other repositories, all comments here are ease of use or aesthetic related. The engine runs well!

  1. Page number confusion. I wanted to see if currentPage was zero indexed or 1 indexed and it wasn't in the documentation. Easy thing to add.

  2. The app crashes when you enter a negative current page. Consider making current page an unsigned int, so change Int to UInt. I think that makes more sense in this context bc you could never have a negative page count.

  3. The app crashes when you enter a non-valid current page. Thoughts on just making it instead go to the nearest page? If you enter page 9 and there are 6 pages just send it to page six.

  4. An aesthetic point, but I did very much expect some dots at the bottom of the view. At least something to indicate the type of element I was dealing with. My first step was to I look at the init's & the modifiers to try to see if I was simply missing that option and didn't see anything.

  5. It was really difficult to figure out the default height and width of the view. It was also difficult to figure out if that height and width was inherited from the subviews. Unsure the best way to communicate that information, but definitely confusing.

  6. We should toss in a sexy dummy view that'd be cool.

Customised views cannot be passed in iPages Initializer

I'm trying out iPages however I encountered the following issue.

It's a very basic usage - one master view initializes iPages and two subviews A and B.

MasterView.swift

import SwiftUI
import iPages

struct MasterView: View {
    @State var currentPage: Int = 0
    var body: some View {
        iPages([SubViewA(), SubViewB()], currentPage: $currentPage)
    }
}

SubViewA.swift

import SwiftUI

struct SubViewA: View {
    var body: some View {
        Text("this is subview A")
    }
}

SubViewB.swift

import SwiftUI

struct SubViewB: View {
    var body: some View {
        Text("this is subview B")
    }
}

The above code does not compile with the unhelpful error as follows.
image

Environment
XCode: Version 12.0.1
macOS: Catalina 10.15.7

Please can anyone suggest if I'm doing anything incorrect or there is a bug somewhere in the library? Thanks in advance!

macOS support

Currently there's no Mac support (except Catalyst), it'd be great to be able to use iPages on macOS.

Uncaught Exception Crash

Stack


2022-08-22 19:46:00.438076-0400 tweetmarks[43546:3140745] *** Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency', reason: 'child view controller:<_TtGC7SwiftUI19UIHostingControllerVS_7AnyView_: 0x11dc0e5f0> should have parent view controller:<UIPageViewController: 0x10621aa00> but requested parent is:<UIPageViewController: 0x1061fd200>'
*** First throw call stack:
(0x18a4a9288 0x1a31d8744 0x18a500390 0x18ca49dd0 0x18d1b6774 0x18d1b6958 0x18d1b6c50 0x104a95418 0x104a95530 0x1928ae4e8 0x19218a300 0x19223a704 0x192115c10 0x1920f1564 0x1920b31ac 0x1920e9bd4 0x1bca3bb18 0x1bca3b508 0x1bca3a318 0x192061124 0x192d34da8 0x192052784 0x19205e618 0x1920570f8 0x192050110 0x19204f1a4 0x192d35cb0 0x19215c798 0x19204d5b4 0x19204d640 0x19213d540 0x1b9133a10 0x19204d4d8 0x19204d7a8 0x18a4510c4 0x18a420080 0x18a41b13c 0x18a42ebc8 0x1a6599374 0x18cda2b58 0x18cb24090 0x192288f24 0x1921b6e08 0x1921980f4 0x10470c4a8 0x10470d3bc 0x105d99da4)
libc++abi: terminating with uncaught exception of type NSException
dyld4 config: DYLD_LIBRARY_PATH=/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/usr/lib/libMainThreadChecker.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib
*** Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency', reason: 'child view controller:<_TtGC7SwiftUI19UIHostingControllerVS_7AnyView_: 0x11dc0e5f0> should have parent view controller:<UIPageViewController: 0x10621aa00> but requested parent is:<UIPageViewController: 0x1061fd200>'
terminating with uncaught exception of type NSException

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.