All Projects → mozilla-mobile → Scrollingcardview

mozilla-mobile / Scrollingcardview

Licence: mpl-2.0
A card view widget for iOS that will grow with its content, enabling scrolling when the content is larger than the view.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Scrollingcardview

Firefox decrypt
Firefox Decrypt is a tool to extract passwords from Mozilla (Firefox™, Waterfox™, Thunderbird®, SeaMonkey®) profiles
Stars: ✭ 735 (+1650%)
Mutual labels:  mozilla
Pulse
We're building the next generation of Firefox, and we're focusing on real-world speed and performance. Pulse lets you give our engineers feedback about your experience on websites that work well in Firefox and on websites that don't.
Stars: ✭ 15 (-64.29%)
Mutual labels:  mozilla
Pontoon
Mozilla's Localization Platform
Stars: ✭ 976 (+2223.81%)
Mutual labels:  mozilla
Swipeablecard
A simple implementation of swipe card like StreetView
Stars: ✭ 812 (+1833.33%)
Mutual labels:  card
Elements Examples
Stripe Elements examples.
Stars: ✭ 874 (+1980.95%)
Mutual labels:  card
Bedrock
Making mozilla.org awesome, one pebble at a time
Stars: ✭ 953 (+2169.05%)
Mutual labels:  mozilla
Cirrus
☁️ The CSS framework for the modern web.
Stars: ✭ 716 (+1604.76%)
Mutual labels:  card
Focus Ios
Firefox Focus for iOS
Stars: ✭ 989 (+2254.76%)
Mutual labels:  mozilla
Xamcustomlayouts
Xamarin.Forms Custom Layouts - Cards
Stars: ✭ 15 (-64.29%)
Mutual labels:  card
Nova Laravel Update Card
Check if you're running the latest Laravel version right from your Nova dashboard.
Stars: ✭ 34 (-19.05%)
Mutual labels:  card
Squib
A Ruby DSL for prototyping card games.
Stars: ✭ 850 (+1923.81%)
Mutual labels:  card
Hotcold
Smart touch typing learning with instant key glow indications, live statistics, live graphs and dynamic course creation.
Stars: ✭ 12 (-71.43%)
Mutual labels:  mozilla
Community User Profile
👨‍💻 Profile page, but for developers.
Stars: ✭ 32 (-23.81%)
Mutual labels:  card
Stealing Ur Feelings
Winner of Mozilla's $50,000 prize for art and advocacy exploring AI
Stars: ✭ 784 (+1766.67%)
Mutual labels:  mozilla
Ecommerce
We're going to take you step-by-step to build a modern, fully open-source, eCommerce web application using Python, Django, Bootstrap, Javascript, and more.
Stars: ✭ 980 (+2233.33%)
Mutual labels:  card
Vue Content Loading
Vue component to easily build (or use presets) SVG loading cards Facebook like.
Stars: ✭ 729 (+1635.71%)
Mutual labels:  card
Multicaptchabot
The best bot for collecting cryptocurrency from freebitco.in, freedoge.co.in and freenem.com 🚀🌔
Stars: ✭ 27 (-35.71%)
Mutual labels:  mozilla
Userplex
Propagate users from Mozilla's Person API to third party systems.
Stars: ✭ 41 (-2.38%)
Mutual labels:  mozilla
Flutter Neumorphic
A complete, ready to use, Neumorphic ui kit for Flutter, 🕶️ dark mode compatible
Stars: ✭ 988 (+2252.38%)
Mutual labels:  card
Marmoset
Marmoset is a single-player implementation of the card game SET.
Stars: ✭ 32 (-23.81%)
Mutual labels:  card

ScrollingCardView

BuddyBuild Version License Platform

ScrollingCardView is an iOS card view widget that:

  • Hugs its content, dynamically expanding the height when the content height expands
  • Will scroll its content if the content is taller than the card

In the following example, the card view height is constrained to be less than or equal to the screen size. First, the content does not fill the screen and neither does the card view:

As the content grows, the card view will expand until the screen size, at which point scrolling is enabled, as demonstrated below:

The card's corner radius, background color, and shadow are customizable.

Motivation

As far as we could find, no existing library met the requirements for the card view we describe above.

We could repurpose an existing card view library and build the growing/scrolling functionality on top of it, but this be hard-to-extend and fragile.

ScrollingCardView was originally created for use in Mozilla's Project Prox.

Usage

// 1. Create your view, enable autolayout, and add it to the view hierarchy.
let cardView = ScrollingCardView()
cardView.translatesAutoresizingMaskIntoConstraints = false
parentView.addSubview(cardView) // e.g. parent could be the ViewController's view


// 2. Constrain the card view as you would any other view.
NSLayoutConstraint.activate([
    cardView.topAnchor.constraint(equalTo: topLayoutGuide.bottomAnchor, constant: 16),
    cardView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 16),
    cardView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -16),

    // If you don't constrain the height, the card will grow to match its
    // intrinsic content size.

    // Or use lessThanOrEqualTo to allow your card view to grow only until a
    // certain size, e.g. the size of the screen.
    cardView.bottomAnchor.constraint(lessThanOrEqualTo: bottomLayoutGuide.topAnchor, constant: -16),

    // Or you can constrain it to a particular height:
    // cardView.bottomAnchor.constraint(equalTo: bottomLayoutGuide.topAnchor, constant: -16),
    // cardView.heightAnchor.constraint(equalToConstant: 300),
])


// 3. Set your card view's content.
let content = UILabel()
content.text = "Hello world!"
content.numberOfLines = 0

cardView.contentView = content

The content can be any view with intrinsic height, or, if you supply a heightAnchor, any view.

You can also customize your card view's appearance:

cardView.backgroundColor = .white

cardView.cornerRadius = 2

cardView.layer.shadowOffset = CGSize(width: 0, height: 2)
cardView.layer.shadowRadius = 2
cardView.layer.shadowOpacity = 0.4

To see this in action, run the example project!

Requirements

  • iOS 9.0+
  • Swift 3

Installation

ScrollingCardView is available through CocoaPods. Add the following to your Podfile:

pod "ScrollingCardView"

Carthage

ScrollingCardView is also available through Carthage. Add the following to your Cartfile:

github "mozilla-mobile/ScrollingCardView" >= 0.1.2

Then drag-and-drop Carthage/Build/iOS/ScrollingCardView.framework into your "Linked Frameworks and Libraries" section and add the copy-frameworks script as specified in the Carthage github readme.

Notes

  • This project is not tested with Interface Builder
  • This project is unlikely to work with non-constraint based layouts

Example

To run the example project:

open Example/ScrollingCardView.xcworkspace

Xcode will open: run from there.

Carthage

To run the Carthage example project:

cd Example_Carthage
carthage update
open Example_Carthage.xcodeproj

Xcode will open: run from there.

Development

Follow the instructions above to open the example project. The library files can be found in:

Pods -> Development Pods -> ScrollingCardView -> ScrollingCardView -> Classes

Testing against external applications

If you're developing against an external application, you can specify a relative path from the application's podfile to your fork of this library:

pod "ScrollingCardView", :path => "../ScrollingCardView"

Run pod install in the external application's directory.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].