Giter Site home page Giter Site logo

rechsteiner / parchment Goto Github PK

View Code? Open in Web Editor NEW
3.3K 52.0 412.0 5.64 MB

A paging view with a highly customizable menu ✨

License: MIT License

Swift 99.89% Objective-C 0.11%
swift ios pageviewcontroller uicollectionview ios-ui ios-libraries swift-library swiftui

parchment's People

Contributors

ageevvalentin avatar aikrice avatar alexjameslittle avatar artemkalinovsky avatar ayastrebov avatar cetineremre avatar cheebow avatar dungphamalo avatar econa77 avatar hugehoge avatar ianhoar avatar ikesyo avatar ispiropoulos avatar kitwtnb avatar linizio avatar mimo42 avatar motasay avatar naruu avatar pangmo5 avatar pot8os avatar realbonus avatar rechsteiner avatar rocxteady avatar rono23 avatar ryoabe avatar simorgh3196 avatar sugitatestblue avatar tbaranes avatar voyager163 avatar yosshi4486 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  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

parchment's Issues

Highlighting when scrolling between items

Some strange highlighting in previous and current item when scrolling?
How to remove that ?
Impementation

        let vc = FixedPagingViewController(viewControllers: controllers)
        vc.font = QTFont.with(14)
        vc.backgroundColor = QTColor.darkTurquoise.withNightMode()
        vc.indicatorColor = QTColor.sunYellow
        vc.selectedTextColor = QTColor.sunYellow
        vc.textColor = .white
        vc.selectedBackgroundColor = .clear
        vc.menuBackgroundColor = .clear
        vc.delegate = self
        return vc

Memory leak

If you build Parchment (r.0.5.0) with the "leak checker" tool, you can see a memory leak, if I'm not mistaken, the method is:

override open func layoutAttributesForElements (in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {}

screenshot at sep 26 15-13-36

I may be wrong, but I think the problem is to use self when initializing an array.

screenshot at sep 26 15-21-03

One solution would be to use unowned self as follows.

  lazy var layoutAttributesValues: [UICollectionViewLayoutAttributes] = { [unowned self] in
        return Array(self.layoutAttributes.values)
  }()
    
  override open func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {

    var layoutAttributes: [UICollectionViewLayoutAttributes] = layoutAttributesValues
    
    for attributes in layoutAttributes {
      if let pagingAttributes = attributes as? PagingCellLayoutAttributes {
        pagingAttributes.progress = progressForItem(at: attributes.indexPath)
      }
    }
    
    let indicatorAttributes = layoutAttributesForDecorationView(
      ofKind: PagingIndicatorView.reuseIdentifier,
      at: IndexPath(item: 0, section: 0))
    
    let borderAttributes = layoutAttributesForDecorationView(
      ofKind: PagingBorderView.reuseIdentifier,
      at: IndexPath(item: 1, section: 0))
    
    if let indicatorAttributes = indicatorAttributes {
      layoutAttributes.append(indicatorAttributes)
    }
    
    if let borderAttributes = borderAttributes {
      layoutAttributes.append(borderAttributes)
    }
    
    return layoutAttributes
  }

"I will be grateful to you ... if you correct this issue as soon as possible.
Thank you

Swift Compiler Error - Installing via Cocoapods

Hello.

I just installed this module via Cocoapods and keep getting No such module 'Parchment' error, when importing in my ViewController.

I also get 4 errors within the Parchment lib itself:

screen shot 2018-01-29 at 10 59 54 am

I haven't made any changes to the files. I've cleaned out and reinstalled my pods as well. Willing to try out the carthage install too, but figured I should file an issue ticket.

I'm using xcode 9.2 and swift 4.

Thanks for this project and your support!

Error

why i got this error ?

ld: warning: ignoring file /Users/bozo/Desktop/*****/Parchment.framework/Parchment, file was built for x86_64 which is not the architecture being linked (arm64): /Users/bozo/Desktop/*****/Parchment.framework/Parchment ld: '/Users/bozo/Library/Developer/Xcode/DerivedData/*****-dhuanbzszeeilpdafoqmheorglne/Build/Products/Debug-iphoneos/Nimble/Nimble.framework/Nimble' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. file '/Users/bozo/Library/Developer/Xcode/DerivedData/******-dhuanbzszeeilpdafoqmheorglne/Build/Products/Debug-iphoneos/Nimble/Nimble.framework/Nimble' for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

deinit() of ViewControllers inside FixedPagingViewController is never called

Hello, thanks for creating an awesome library!

In my app, I have a ViewController (let's call: A) that contains FixedPagingViewController that is initialized with 2 viewcontrollers (X & Y). As I just tested, when A is popped off, the function deinit() in X & Y is not called at all. I think if it might lead to a leak memory issue.

Load controllers from storyboard

Hi,

Is it possible for loading view controllers from the storyboard rather? i.e., each tab would be a viewcontroller from the storyboard. If so, can you provide an example?

Thanks,
Karthik

Is it possible to change access for the method

Is it possible to do an open method:
 
public func em_pageViewController (_ pageViewController: EMPageViewController, willStartScrollingFrom startingViewController: UIViewController, destinationViewController: UIViewController) {}

I would like to use his heirs class PaguingViivcontroller.

Many thanks.

NavigationBarExample doesn't work

Two errors in the example project for NavigationBar:

  1. Initializer for conditional binding must have Optional type, not 'UIView'
    and
  2. Cannot convert value of type 'Paging Options' to expected argument type 'NSCoder'

Scrolling bug in the pagingViewController (IconsExample) when applying different width for selected cell in IconsExample

Hey,

I have tried to set up different width for selected cell in IconsExample, wIth selected 60pt and not selected 80pt.

When I slide from controller to controller, relatively fast, pagingViewController on the top occasionally jumps from icon to icon without scrolling animation.

I have added

this

extension ViewController: PagingViewControllerDelegate {
    
    func pagingViewController<T>(_ pagingViewController: PagingViewController<T>, widthForPagingItem pagingItem: T, isSelected: Bool) -> CGFloat {
        
        if isSelected {
            return 80
        } else {
            return 40
        }
    }
    
}

and this

  override func viewDidLoad() {
    ...
    pagingViewController.delegate = self
  }

to the IconsExample ViewController. Did I miss anything? Was that correct?

Loading Current Controller not updating

I am using the following code to try and select a view controller - but its data structure is empty in

    let controllers = viewcontrollers(from: pagingItems)
    pagingViewController =  FixedPagingViewController(viewControllers: controllers, options:    CustomOptions())
   addChildViewController(pagingViewController!)
    viewHolder.addSubview((pagingViewController?.view)!)
    viewHolder.constrainToEdges((pagingViewController?.view)!)
   
    
    // Set our custom data source
    pagingViewController!.itemDelegate = self
    
    // Set the current date as the selected paging item
     let items = pagingViewController.items 
        let index = Defaults[.vcIndex]
        if index < items.count {
            pagingViewController!.selectPagingItem(pagingViewController.items [index])
        }
     pagingViewController?.didMove(toParentViewController: self)

In PagingViewController.swift, dataStructure is empty.

     open func selectPagingItem(_ pagingItem: T, animated: Bool = false) { 
       if let stateMachine = stateMachine {
      if let indexPath = dataStructure.indexPathForPagingItem(pagingItem) {
        let direction = dataStructure.directionForIndexPath(indexPath, currentPagingItem: pagingItem)
        stateMachine.fire(.select(
          pagingItem: pagingItem,
          direction: direction,
          animated: animated))
      }

Reload Cell in Collectionview

hi, i have a problem with lib, please help me, how to reload collectionView in pagingView? i try call pagingViewController.collectionView.reloadData() but not work.

Swipe in last item bug

Hi :),
i think i found a bug, example: if u are in the last menu item on the left or right and swipe to left or right, after swipe u cant select menu items

Different width for a selected cell

Do you think it's possible to have different width for a selected cell?

And update it (width) dynamically (with animation) moving from current to the next cell.

min iOS version

I was wondering, why does this pod min iOS version is 8.2? I think 8.0 should be fine.
If it is possible, to have the min iOS version set to 8.0 please?

Delegate not working in infinite case

Hi, i just tried to use self size logic in calendar example, I mean use approach in delegate example to have cell size fit to text, but my delegate functions dont fire.
Is it possible to have self size cells for infinite usage?

willScrollToItem delegate method is not getting called.

open class PagingViewController<T: PagingItem>:

is not declaring the optional function

    @objc  optional func em_pageViewController(_ pageViewController: EMPageViewController, willStartScrollingFrom startingViewController: UIViewController, destinationViewController:UIViewController)

Which require overriding the function in FixedPagingViewController:

open override func em_pageViewController(_ pageViewController: EMPageViewController, didFinishScrollingFrom startingViewController: UIViewController?, destinationViewController: UIViewController, transitionSuccessful: Bool) `

only then will the delegate method willScrollToItem be called.

Doesn't compile because of inner library error

Added via cocoapods
Version: 0.9.x and 1.0.3
.../Pods/Parchment/Parchment/Classes/PagingOptions.swift:76:50: Type 'UIFont' has no member 'Weight'

In the same time on another pc downloaded this repo and ran examples - they work

How to programmatically select item?

Take the storyboard example project, if I want to programmatically select the secondVC, how do I do it?

If I do:
pagingViewController.select(index: 1)

When I run the app, secondVC isn't shown and the top menu still shows the first one and can't navigate anymore. What am I missing?

Sorry if this is a stupid question, I just can't figure it out!

Swift 4 migration

Hello Martin,

Any plans for swift 4.
Even though Swift 3.x and Swift 4 are interchangeable, it would be great if there were a Swift 4 version!

Thank you! 😄

buggy scrolling in pageViewController on iOS 11 / iPhone X

There is a buggy scrolling in pageViewController on iOS 11 / iPhone X. It scrolls in all directions.
Don't know why but this bug is present on all our devices with our project, and only on iPhone X with your example (icon Example)

simulator screen shot - iphone x - 2017-11-08 at 02 52 34

Apparently, it's linked to this scrollview and to scrollview insets.

screenshot at nov 08 02-53-01

In our project, actually by guess, I have solved this problem with this code, though I am not sure if that's the best solution.

scrollView.contentInsetAdjustmentBehavior = .never

Autolayout issue

I tried to use this library explained in the onboarding page but it gives me a auto-layout warning:

`[LayoutConstraints] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
"<NSLayoutConstraint:0x608000285f00 V:|-(0)-[UICollectionView:0x7f803388e800] (active, names: '|':Parchment.PagingView:0x7f8032d46f50 )>",
"<NSLayoutConstraint:0x608000286090 UICollectionView:0x7f803388e800.height == 40 (active)>",
"<NSLayoutConstraint:0x608000285690 V:[UICollectionView:0x7f803388e800]-(0)-[UIView:0x7f8032d41970] (active)>",
"<NSLayoutConstraint:0x608000282440 V:[UIView:0x7f8032d41970]-(0)-| (active, names: '|':Parchment.PagingView:0x7f8032d46f50 )>",
"<NSLayoutConstraint:0x600000292ac0 'UIView-Encapsulated-Layout-Height' Parchment.PagingView:0x7f8032d46f50.height == 0 (active)>"
)

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x608000285690 V:[UICollectionView:0x7f803388e800]-(0)-[UIView:0x7f8032d41970] (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.`

UIFont has no member weight

screen shot 2017-09-28 at 8 01 14 pm

It is strange because it still exists in the UIKit documentation. I've tried using it in Playground but it refuses to work.

Controller menu missing with different initial screen

Hi,

In the Delegate Example (cities), I've added in a new controller (HomeViewController) as the initial view controller. From which, I need to navigate to the cities controller (ViewController). Layout as in screen shot

ss

When I wire the "Go to cities" button to the cities controller (ViewController) or to the navigation controller attached to it, the top city selection menu bar (in cities controller) goes missing. But, the left/right swipe works taking to the new city. How do I fix this?

Thanks

Paging menu items are not centered initially

I initialized a FixedPagingViewController with two controllers, both with icons. I setup everything inside of viewDidLoad but then I noticed that they are not centered correctly. They only are properly centered after clicking on the other icon or swiping to the other tab. Is this possible a bug? or am I just using it incorrectly

How it looks Initially
screen shot 2017-09-26 at 4 48 36 pm

After switching to another tab
screen shot 2017-09-26 at 4 48 43 pm

Now you can see it is properly centered
screen shot 2017-09-26 at 4 53 13 pm

Thanks!

Allow scrolling in the menu items header

Currently, the menu items only have a swipe gesture to switch between pages. It would be nice to be able to scroll freely inside the menu items collection view.

Add custom page view implementation

We're currently using EMPageViewController as a replacement for UIPageViewController, as it’s more predictable and provides us with much better delegate methods at every step.

Ideally, we would replace this library with our own custom implementation to have even more fined grained control. This would also fix an issue with EMPageViewController where it occasionally won’t do anything when swiping rapidly between many pages (#26).

FixedPagingViewControllerDelegate does not recognize an aborted scroll

Currently FixedPagingViewControllerDelegate does not recognize an aborted scroll. Running the code as noted below increments the index even when a scroll is not completed.

extension UIViewController: FixedPagingViewControllerDelegate{
func fixedPagingViewController(fixedPagingViewController: FixedPagingViewController, willScrollToItem: ViewControllerItem, atIndex index: Int) {
    print("about to move to: \(index)")
}

func fixedPagingViewController(fixedPagingViewController: FixedPagingViewController, didScrollToItem: ViewControllerItem, atIndex index: Int) {
     Defaults[.vcIndex] = index
    print("Moved to: \(index)")
}

}

Suggest something similar to the following changes to FixedPagingViewController that sends destination index only on successful transition

` // MARK: EMPageViewControllerDelegate

open override func em_pageViewController(_ pageViewController: EMPageViewController, didFinishScrollingFrom startingViewController: UIViewController?, destinationViewController: UIViewController, transitionSuccessful: Bool) {
    super.em_pageViewController(pageViewController, didFinishScrollingFrom: startingViewController, destinationViewController: destinationViewController, transitionSuccessful: transitionSuccessful)
    
    if let index = items.index(where: { $0.viewController == destinationViewController }) {
        if let cIndex = currentIndex {
            itemDelegate?.fixedPagingViewController(
                fixedPagingViewController: self,
                didScrollToItem: items[index],
                atIndex: transitionSuccessful ? index  : cIndex )
        }
    }
}

public override func em_pageViewController(_ pageViewController: EMPageViewController, willStartScrollingFrom startingViewController: UIViewController, destinationViewController: UIViewController) {
    if let cIndex = items.index(where: { $0.viewController == startingViewController }) {
        currentIndex = cIndex
    }
    if let index = items.index(where: { $0.viewController == destinationViewController }) {
        itemDelegate?.fixedPagingViewController(
            fixedPagingViewController: self,
            willScrollToItem: items[index],
            atIndex: index)
    }
}`

Add progress value to menu items

Right now the menu items are only updated after a transition has completed. Adding a progress on the PagingCell based on how much the content is scrolled would allow us to smoothly transition between size/color etc.

Not possible to have transparent/ translucent nav. bar

Hello!

We tried but didn't succeed in making the effect when what is vertically scrolled in the view appears underneath the nav. bar in order to have transparency/translucency effect.

Our idea was to make

  1. Fully transparent nav. bar
  2. Make fully transparent menu (horizontal collection view with icons).
  3. Than add custom view (nav. bar view) of a certain height and level of translucency.
    We, actually, succeeded in all of that. The bottleneck appeared to be that we couldn't move the view underneath the nav. bar and the menu itself. We also don't really understand how to change y position of the menu (horizontal collection view with icons), neither of the view, independently of each other.

By view here I mean the any view (tableview, collectionView, ...) that is inserter into the contentView together with the menu (horizontal collection view with icons).

I tried to explain on this picture.
So we need to put the view underneath the nav. bar and the menu. And move it up to the contentView's top margin.

screen shot 2017-02-02 at 19 59 36

Menu on navigationbar

Hi,i want to add menu on navigationbar , how to work it out.
Or Parchment can't do it like that?
I'll be waiting for your reply.

Background color

i want the background color to change based on which item is selected

Scroll menu items alongside content

The position of menu items are only updated after a transition has completed. Updating the scroll offset based on how much the content is scrolled would make the transition much smoother. We could still keep the current behaviour as an option.

Parchment does not work with navigation bars

I'm sorry to bother you yet again but I found this problem.
I had a viewcontroller embed in a uinavigationcontroller and in a uitabbarcontroller.

I compiled the example project you listed and it worked. Then I embed it within a navigation bar but it becomes hidden under the bar. I'm confused because your examples render it correctly.

screen shot 2017-09-29 at 5 21 25 pm

Also, constrain to edges doesn't work in Swift 4.

[Question]

Hi, is possible remove click on menu item?

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.