Welcome to Pagie, a flexible library that helps you navigate between pages using gestures.
Pagie is distributed using the Swift Package Manager. To install it into a project, go to file -> Swift Packages -> add it as a package dependency, then enter a package repository url which is https://github.com/ahmedelserafy7/Pagie.git
, click next and one more next, and finish.
Then import Pagie wherever you’d like to use it:
import Pagie
You can use CocoaPods by adding the following line to your Podfile
:
pod 'Pagie'
- First things first, all you have to do is to import it:
import Pagie
- Rename your
UIViewController
superclass, and set it toPagieHome
.
class ViewController: PagieHome
- Create an instance of
Page
type, and use the initializer to set the initial value of propertiestitle
,subtitle
, andimageName
, and set them toself.pages
.
let page1 = Page(title: "Discover great events happening in your city", subtitle: "Find events by category and browse list of trending events everyday.", imageName: "page1")
let page2 = Page(title: "Maximize the value of every event you attend", subtitle: "Stay updated with event details, meet other attendees and get live announcements about important updates.", imageName: "page2")
let page3 = Page(title: "Make the most out of every event", subtitle: "View updated agenda, sessions details and speakers from your phone.", imageName: "page3")
let page4 = Page(title: "Network like a pro!", subtitle: "Join the event's community, like-minded people and shake hands through the app to keep track of your connections.", imageName: "page4")
let pages: [Page] = [page1, page2, page3, page4]
self.pages = pages
// Define how many dots you like:
pageControl.numberOfPages = self.pages.count
- Don't forget to add your images to the
Assets.xcassets
file of your project.
Since your app is up and running, you may need to configure, customize, and add your own page.
Customize your page control indicator color:
pageControl.pageIndicatorTintColor = .gray
Customize your "current" page control indicator color:
pageControl.currentPageIndicatorTintColor = .magenta
Change your button background color:
getStartedButton.backgroundColor = .cyan
Rename your button name:
getStartedButton.setTitle("Sign up", for: .normal)
Customize your button width and height:
customizeButton(width: 100, height: 100)
Remove your button:
getStartedButton.removeFromSuperview()
Configure getStartedButton
function:
override func handleGetStartedButton() {
print("Hello world!")
}
Setup your login page:
- Declare your
loginId
identifier:
fileprivate let myLoginId = "myLoginId"
- Register a
UICollectionViewCell
subclass for use with your collection view, so that new cells are dequeued and re-use automatically by the system:
collectionView.register(MyLoginCell.self, forCellWithReuseIdentifier: myLoginId)
- Customize your login view cell in code:
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
guard indexPath.item != pages.count else {
guard let loginCell = collectionView.dequeueReusableCell(withReuseIdentifier: myLoginId, for: indexPath) as? MyLoginCell else { return UICollectionViewCell() }
return loginCell
}
return setupPageCell(by: collectionView, and: indexPath)
}
- Create your own custom
UICollectionViewCell
subclass:
import Pagie
class MyLoginCell: LoginCell {
override func setupViews() {
self.backgroundColor = .blue
}
}
Additional sample examples can be found in /PagieExample
.
Start out simple, and customize when needed.
Having trouble working with Pagie? Found a typo in the implementation? Interested in adding a feature or fixing a bug? Then by all means submit an issue or pull request. If this is your first pull request, it may be helpful to read up on the GitHub Flow first.
Please keep this in mind when requesting features and/or submitting pull requests:
- Pagie is developed completely in the open, and your contributions are more than welcome.
- Pagie has been designed as a base for you to customize and fit your page's unique needs.
- It’s highly recommended that you spend a few minutes familiarizing yourself with its internal implementation, so that you’ll be ready to tackle any issues or edge cases that you might encounter.
When submitting a pull request:
- Clone the repo.
- Create a branch off of
master
and give it a meaningful name (e.g.my-awesome-new-feature
). - Open a pull request on GitHub and describe the feature or fix.
Ahmed Elserafy