Code Monkey home page Code Monkey logo

adaptive-tab-bar's Introduction

ADAPTIVE TAB BAR

'Progressive Reduction' module for adding custom states to Native or Custom UI elements.


We specialize in the designing and coding of custom UI for Mobile Apps and Websites.

Stay tuned for the latest updates:


CocoaPods CocoaPods Twitter Travis Donate

Tab Bar After Install

Animation

Tab Bar After Two Weeks

Animation

Tab Bar After a Month

Animation

Overview

AdaptiveController is module for adding custom states to Native or Custom UI elements. The UI elements evolve over time as the user becomes accustomed to them. An example AdaptiveTabBar is provided.

How to import the control to your project

  1. First, drag and drop the AdaptiveController project file into your project or select "add existing file" and choose the AdaptiveController project
  2. Add AdaptiveController to your Target Dependences in the Build Phase of your project.
  3. Add the AdaptiveController framework in Link Binary With Libraries in Build Phases
  4. Import AdaptiveController where needed.

Using AdaptiveController

First, you should set the install date, current date, count of days to transition to small text state, and count of days to transition to big image state. The AdaptiveDateState object automatically determines what UI state to show:

    var installDate = NSDate(dateString:"2014-09-18")
    var adaptiveState = AdaptiveDateState(installDate: installDate, currentDate:NSDate(), countDaysToSmallTextState:countDaysToSmallTextState, countDaysToImageState:countDaysToImageState)

Or count of launches for different state:

    var curentCountLaunches = 6
    var adaptiveState = AdaptiveLaunchesState(curentCountLaunches:curentCountLaunches, countLaunchesToSmallTextState:5, countLaunchesToImageState:7)

And then you should setup an array of appearances. You should setup button images for each state for each apperance object:

    var buttonsAppearances = buttonsAppearancesGenerate() //func butonsAppearancesGenerate() -> [AdaptiveButtonApperance]

And then you should setup an array of items Appearance object. You should set the button's image for each state for each appearance object.

First, you should setup a dictionary for the extension of the image for each UI state:

    var imageExtensionsForStates:Dictionary = [ kSmallTitleAdaptiveState:"_smalltitle", kImageAdaptiveState:"_bigimage", kSmallTitleAdaptiveState+selected :"_smalltitle", kImageAdaptiveState+selected:"_bigimage" ]

Then you should set the Appearance for each UITabBarItem title for each state, fonts for each state, a default image if you describe an extension for each state, or if you do not describe an extension, you should setup each image for each state.

First, init the appearance object and setup the text for each state. If the text is the same for each state, you can set text for the default state:

    var watchAppearance = AdaptiveButtonAppearance(); 
    watchAppearance.setButonTitle("watch", state: kDefaultAdaptiveState)
    watchAppearance.setButonTitle("watch", state: kSmallTitleAdaptiveState)
    watchAppearance.setButonTitle("", state: kImageAdaptiveState)

Then you should setup your fonts for each state:

    watchAppearance.setButonTitleFontForState(yourDefaultFont, state: kDefaultAdaptiveState)
    watchAppearance.setButonTitleFontForState(yourDefaultSmallTitleModeFont, state: kSmallTitleAdaptiveState)

Then you should set the default image and extensions for each state a function which automaticaly sets images for each state:

    watchAppearance.setImageNamesForStatesImageExtesions("watch", imageExtensionsForState:imageExtensionsForStates)

Then you should setup the appearance insets for each state:

    watchAppearance.setImageInsets(defaultInsets, state: kDefaultAdaptiveState);
    watchAppearance.setImageInsets(defaultSmallTitleModeImageInsets, state: kSmallTitleAdaptiveState)
    watchAppearance.setTitleOffset(defaultOffset, state: kDefaultAdaptiveState)
    watchAppearance.setImageInsets(defaultImageModeInsets, state: kImageAdaptiveState);

Then you should setup сustom UITabBarItems which conform to the AdaptiveButtonsProtocol:

    var arrayButtons = tabBar.items as [AdaptiveTabBarItem]

In your custom tab item, you should implement these methods from the protocol:

    @objc protocol AdaptiveApperanceProtocol {
        optional func setFontToAdaptiveButton(font: UIFont)
        optional func setTitleToAdaptiveButton(text: NSString)
        optional func setImageToAdaptiveButton(image: UIImage?)
        optional func setHighlightedToAdaptiveButton(image: UIImage?)
        optional func setBackgroundImageToAdaptiveButton(image: UIImage?)
        optional func setSelectedImageToAdaptiveButton(image: UIImage?)
        optional func setImageInsetsToAdaptiveButton(insets: UIEdgeInsets)
        optional func setTitleOffsetToAdaptiveButton(offset: UIOffset)
        optional func setTitleColorToAdaptiveButton(titleColor: UIColor)
    }

An example implemetation of a protocol method from our custom tab bar item:

    func setTitleToAdaptiveButton(text: NSString) {
    	self.title = text
	}

Finally, you should init Adaptive State Manager with the objects you've setup:

	AdaptiveButtonsStateManager(state: adaptiveState, buttonsAray:arrayButtons, buttonsAppearance:butonsAppearances)

##Using Custom States For AdaptiveController

Like UITabBar for different custom applications states

We have a default AdaptiveState and with the help of inheritance, we can add new custom states to our state class. The new class in our situation is named AdaptiveDateState

In AdaptiveDateState, we can add new custom states like this:

	let kSmallTitleAdaptiveState = "kImageAdaptiveState"
	let kImageAdaptiveState = "kNormalImageAdaptiveState"

And add methods which decide how the state relates to input parameters:

	var adaptiveState = AdaptiveDateState(installDate: installDate,currentDate:NSDate(),countDaysToSmallTextState:countDaysToSmallTextState,countDaysToImageState:countDaysToImageState)

In AdaptiveDateState, we add custom init methods which decided what states have the Adaptive state object according to the input parameters:

    private func stateRemainDays(remainDays:Int, countDaysToSmallTextState:Int, countDaysToImageState:Int)->String {
        var mode:String = kDefaultAdaptiveState
        print(" DAYS \(remainDays) ")
        if remainDays > countDaysToSmallTextState && remainDays < countDaysToImageState{
            mode = kSmallTitleAdaptiveState
        } else if remainDays > countDaysToImageState {
            mode = kImageAdaptiveState
        }
        print(mode)
        return mode
    }

You can customize different UI components if they adopt to the AdaptiveApperanceProtocol.

πŸ“„ License

Adaptive Tab Bar is released under the MIT license. See LICENSE for details.

This library is a part of a selection of our best UI open-source projects.

If you use the open-source library in your project, please make sure to credit and backlink to www.ramotion.com

πŸ“± Get the Showroom App for iOS to give it a try

Try this UI component and more like this in our iOS app. Contact us if interested.



adaptive-tab-bar's People

Contributors

0ber avatar aleksei1000000 avatar alexmik89 avatar apsanz avatar arcilite avatar artemkyslicyn avatar igork-ramotion avatar ikolpachkov avatar juriv avatar ramotiondev avatar ronnielsen 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

adaptive-tab-bar's Issues

Name inconstency

The name of the project is adaptive-tab-bar, but the description says "AdaptiveController is a 'Progressive Reduction' Swift module for adding custom states to Native or Custom iOS UI elements"

Suggestion for usage, not time-based enhancement

This is a formal suggestion to allow usage-based, not time-based, progressive enhancement.

Here's the issue: Lets say someone downloads your app, and only uses it once a month. They still get a ton of value out of that once a month usage, but still, only once a month. Within a month, they will see no menu text, and maybe they've only used it once before.

If possible, usage based enhancement would be far more indicative of familiarity. I love the idea, but this would be a significant improvement.

font changes and image size changes

These do not appear to work, nothing happens when I try the font face and size and the image doesn't scale up when only the image is showing

Installation on a Framework

Hi, I'm trying to install your beautiful component inside an existing framework, using cocoapods.
After pod install I've copied AdaptiveController into the project (drag&drop -> copy if necessary) and added AdaptiveController into Target Dependences in the Build Phase of my project.
In a framework, I can't add AdaptiveController into Target Dependences in the Build Phase, so I have this -obvious- compile error:

Framework not found AdaptiveController

How can I fix this?

Swift 3 compatibility

Hey, I'd love to see this lib available in Swift 3 so I can implement it in my project.

Thanks πŸ˜„

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.