Eat fit is a component for attractive data representation inspired by Google Fit

Overview

EatFit

Yalantis Carthage Compatible

Check this article on our blog.

Preview

Purpose

Eat fit is a component for attractive data representation inspired by Google Fit. It is based on PageViewController, interface for customization is implemented in UITableViewDataSource style.

Supported OS & SDK Versions

  • Swift 5
  • iOS 9.0+
  • Xcode 11

ARC Compatibility

EatFit requires ARC.

Supported orientations

EatFit supports only portrait orientation.

Thread Safety

EatFit is subclassed from UIView and - as with all UIKit components - it should only be accessed from the main thread. You may wish to use threads for loading or updating EatFit contents or items, but always ensure that once your content has loaded, you switch back to the main thread before updating the EatFit.

Installation

Carthage

github "Yalantis/EatFit" ~> 3.0

Manual

To install manually the EatFit component in an app, drag EatFit folder with all contents into your project. Use EatFitViewController as any other view controller in your app. Setup is done via data source pattern. EatFitViewController's data source must adopt protocol EatFitViewControllerDataSource

Memory issues

Inside the component pages are reused just like cells in UITableView. There are no more than 3 pages exist in memory at any moment no matter how many pages the component shows.

Properties

The EatFit has following properties:

	weak var dataSource: EatFitViewControllerDataSource!

Methods

The EatFitViewController class has the following methods:

	func reloadData()

This reloads all the component from the dataSource and refreshes the display.

Data source protocol

The EatFitViewControllerDataSource protocol has the following methods:

    func numberOfPagesForPagingViewController(controller: EatFitViewController) -> Int

Returns the number of pages in the EatFit view controller.

    func chartColorForPage(index: Int, forPagingViewController controller: EatFitViewController) -> UIColor

Returns the tint color for specific page. Tint color defines the chart color and logo color.

    func percentageForPage(index: Int, forPagingViewController controller: EatFitViewController) -> Int

Returns the percentage that defines displayed value of the percentage label and the graphic chart.

    func titleForPage(index: Int, forPagingViewController controller: EatFitViewController) -> String

Returns the title that is displayed at the top of each page.

    func descriptionForPage(index: Int, forPagingViewController controller: EatFitViewController) -> String

Returns the description that is displayed at the bottom of each page.

    func logoForPage(index: Int, forPagingViewController controller: EatFitViewController) -> UIImage

Returns the image for specific page. Actual color of image doesn't matter, it will be colored with page tint color. Perhaps keep in mind that image must be png with opacity.

    func chartThicknessForPagingViewController(controller: EatFitViewController) -> CGFloat

Returns chart thickness in points. It is applied for all pages.

Let us know!

We’d be really happy if you send us links to your projects where you use our component. Just send an email to [email protected] And do let us know if you have any questions or suggestion regarding the animation.

P.S. We’re going to publish more awesomeness wrapped in code and a tutorial on how to make UI for iOS (Android) better than better. Stay tuned!

License

The MIT License (MIT)

Copyright © 2017 Yalantis

Permission is hereby granted free of charge to any person obtaining a copy of this software and associated documentation files (the "Software") to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Comments
  • App is crashing

    App is crashing

    App crash when change view on pageView controller.

    EatFit Demo Project[2416:92427] -[NSConcreteValue doubleValue]: unrecognized selector sent to instance 0x7f9808f17170 2016-07-13 22:31:08.496 EatFit Demo Project[2416:92427] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSConcreteValue doubleValue]: unrecognized selector sent to instance 0x7f9808f17170'

    type: bug 
    opened by nentrast 4
  • How to change background color of the whole view

    How to change background color of the whole view

    I am able to change the color of the chart progress and the image through the provided chartColorForPage method but how can I change the background color of the view... I tried changing self.view.backgroundColor in my ViewController but it had no effect.

    type: enhancement 
    opened by SikandAlex 3
  • Fix 'NSConcreteValue doubleValue unrecognized selector' crash

    Fix 'NSConcreteValue doubleValue unrecognized selector' crash

    This PR fixes crash #4 that occurs when swiping to the next page if the user waits for the entire animation to finish before doing so.

    Steps to reproduce the crash:

    1. (Clone the latest version and) launch the demo app
    2. Wait for the first page to fully finish animating (until the water icon is visible, essentially)
    3. Swipe right

    The drop CAShapeLayer variable in the DropView class crashes when its frame is directly altered in line 44. This happens in the layoutSubviews function when the bounds.width needs to be expressed as a Double and the app crashes subsequently.

    This is a simple fix that performs a ceil() on bounds.width, thus preventing NSConcreteValue from receiving a double instead of a CGFloat.

    opened by NSMyself 3
  • Installation and Demo Project Issue

    Installation and Demo Project Issue

    Hi, I just tried to drag the EatFit folder into my Xcode project and I've got three issues coming up.

    EatFit/Views/SlideLabel.swift:41:9: Value of type 'UILabel' has no member 'ac_trimLeft' EatFit/Views/SlideLabel.swift:42:9: Value of type 'UILabel' has no member 'ac_trimRight' EatFit/Views/SlideLabel.swift:60:9: Value of type 'UILabel' has no member 'animateAlpha'

    Am I doing something wrong is there some code I need to implement to resolve these errors? Also, on the demo project when I move from the "water" progress page to the "food" progress page the application crashes.

    opened by SikandAlex 3
  • Carthage support

    Carthage support

    opened by TofPlay 2
  • percentageLabel text does not appear and does not animate

    percentageLabel text does not appear and does not animate

    I've included an example. I implemented all of the customization functions yet this is the final state of the view after all of the animations have completed.

    screen shot 2016-07-12 at 1 10 34 pm

    type: bug 
    opened by SikandAlex 2
  • any plan to bring it to swift 5?

    any plan to bring it to swift 5?

    Report

    The more information you provide, the faster we can help you.

    ⚠️ Select what you want - a feature request or report a bug. Please remove the section you aren't interested in.

    A feature request

    What do you want to add?

    Please describe what you want to add to the component.

    How should it look like?

    Please add images.

    Report a bug

    What did you do?

    Please replace this with what you did.

    What did you expect to happen?

    Please replace this with what you expected to happen.

    What happened instead?

    Please replace this with what happened instead.

    Your Environment

    • Version of the component: insert here
    • Swift version: insert here
    • iOS version: insert here
    • Device: insert here
    • Xcode version: insert here
    • If you use Cocoapods: run pod env | pbcopy and insert here
    • If you use Carthage: run carthage version | pbcopy and insert here

    Project that demonstrates the bug

    Please add a link to a project we can download that reproduces the bug.

    opened by GINNOV 0
  • Swift 3 and SwiftPM support

    Swift 3 and SwiftPM support

    opened by TofPlay 0
Releases(3.0)
Owner
Yalantis
Knowledge is power and the way to get power is by sharing knowledge. We are open source because this is a smart way to live, work and play.
Yalantis
SwiftyOpenGraph - A swift library that retrieves structured open graph data from webpages.

SwiftyOpenGraph Usage Initialization Base Properties Types Installation License Usage Initialization You use SwiftyOpenGraph by initializing OpenGraph

Quintschaf 1 Jan 6, 2022
A timer that lets you know when your ramen is ready to eat!

Dependencies Ramen Timer requires the following: Gifu SwiftySound On Xcode simply go to File > Add Packages and input the names on the searchbar then

Angel Santiago 1 Nov 3, 2021
🍳 iOS application for DIET and EAT 🍙

diEAT ?? Summary 다이어트 중 식단 ?? 을 한번에 기록하고 한눈에 확인하고싶어서 만들어보는 식단 관리 프로그램 (iOS 어플) It's a dieat management ios application to record dieat ?? at once ?? T

Dayeon Moon 4 Nov 21, 2022
An attractive color generator for Swift. Ported from randomColor.js.

Random Color Swift Inspired by David Merfield's randomColor.js. It is a ported version to Swift. You can use the library to generate attractive random

Wei Wang 624 Jan 3, 2023
Letters animation allows you to click on different letters and accordingly it will animate letters in a cool way. It has a very attractive UI and is very easy to use.

Letters Animation Cool Letters Animation in iOS written in Swift. Preview Table of content :- Description How to add in your project Requirement Licen

MindInventory 31 Oct 4, 2022
Numbers animation allows you to click on different numbers and accordingly it will animate numbers in a cool way. It has a very attractive UI and is very easy to use.

Numbers Animation Cool Numbers Animation in iOS written in Swift. Preview Table of content :- Description How to add in your project Requirement Licen

MindInventory 31 Oct 4, 2022
Reading animation allows you to click on the different page numbers and accordingly it will animate page changes in a cool way. It has a very attractive UI and is very easy to use.

Reading Animation Cool Reading Animation in iOS written in Swift. Preview Table of content :- Description How to add in your project Requirement Licen

MindInventory 42 Oct 4, 2022
A simple and attractive AlertView to ask permission to your users for Push Notification.

A simple and attractive AlertView **to ask permission to your users for Push Notification.** PRESENTATION Ask permission to user for push notification

Boisney Philippe 37 Mar 23, 2022
A simple and attractive AlertView to onboard your users in your amazing world.

AlertOnboarding A simple and attractive AlertView to onboard your users in your amazing world. PRESENTATION This AlertOnboarding was inspired by this

Boisney Philippe 832 Jan 8, 2023
Google Analytics tracker for Apple tvOS provides an easy integration of Google Analytics’ measurement protocol for Apple TV.

Google Analytics tracker for Apple tvOS by Adswerve About Google Analytics tracker for Apple tvOS provides an easy integration of Google Analytics’ me

Adswerve 81 Nov 13, 2022
Google-Blogger-iOS-App - Using Google Blogger API to build an iOS app like Medium

Google Blogger iOS App Using Google Blogger API to build an iOS app like Medium!

Ricky Chuang 9 Dec 13, 2022
JSEN (JSON Swift Enum Notation) is a lightweight enum representation of a JSON, written in Swift.

JSEN /ˈdʒeɪsən/ JAY-sən JSEN (JSON Swift Enum Notation) is a lightweight enum representation of a JSON, written in Swift. A JSON, as defined in the EC

Roger Oba 8 Nov 22, 2022
Mobile Text-to-Image search powered by multimodal semantic representation models(e.g., OpenAI's CLIP)

A Mobile Text-to-Image Search Powered by AI A minimal demo demonstrating semantic multimodal text-to-image search using pretrained vision-language mod

null 66 Jan 5, 2023
Mobile(iOS) Text-to-Image search powered by multimodal semantic representation models(e.g., OpenAI's CLIP)

Mobile Text-to-Image Search(MoTIS) MoTIS is a minimal demo demonstrating semantic multimodal text-to-image search using pretrained vision-language mod

Roy 66 Dec 2, 2022
Converts images to a textual representation.

ConsoleApp7 Essentially, this suite of programs converts images to text, which is made to resemble the original image. There are three targets in this

Cedric 1 Nov 11, 2021
A precise, type-safe representation of a monetary amount in a given currency

Money A precise, type-safe representation of monetary amounts in a given currency. This functionality is discussed in Chapter 3 of Flight School Guide

Flight School 883 Dec 1, 2022
A sample app that implements the ideal UI representation around the loading process

SwiftUILoadingStateSample This is a sample app that implements the ideal UI repr

null 4 May 29, 2022
EmbeddedStringsKit: Representation localized string in code

EmbeddedStringsKit Representation localized string in code Usage public struct L

Muukii 1 Jul 13, 2022
A Swift framework for parsing, formatting and validating international phone numbers. Inspired by Google's libphonenumber.

PhoneNumberKit Swift 5.3 framework for parsing, formatting and validating international phone numbers. Inspired by Google's libphonenumber. Features F

Roy Marmelstein 4.7k Dec 29, 2022