Skip to content
This repository has been archived by the owner on Jun 26, 2019. It is now read-only.

Releases: tmergulhao/Ambience

Updated Swift version

01 Nov 21:27
Compare
Choose a tag to compare
0.1.2

Version update

Nullifying constraint value nullifies state

18 Jan 21:00
Compare
Choose a tag to compare
0.1.1

String describing something obvious.

Automatic persistence of forced state and support for iPad

13 Jan 17:27
Compare
Choose a tag to compare

Ambience persists over app sessions using UserDefaults and also anchors its Ambience Object popover to the sender being it either a UIView or a Bar Button Item

Ambience persistence and UITextField support

10 Jan 18:55
Compare
Choose a tag to compare

Ambience persists using User Defaults and Text Field Placeholder is set to 50% alpha off current Ambience State text color.

Text View now works inside a Collection

06 Jan 19:59
Compare
Choose a tag to compare

Known issues

Text View inside Collection

If you are using a Text View inside a Table View Cell or a Collection View Cell and, in the process of dequeuing it you set its attributed text, beware. Right after assigning the new Attributed Text will need to write a mandatory single line of code to have Ambience work in the Text View properly.

Follow the example:

// Inside the respective Table View Controller

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    let cell : TextTableCell! = tableView.dequeueReusableCell(withIdentifier: "Cell with text") as! TextTableCell
    
    cell.textView?.reinstateAmbience()
    
    return cell
}

Open Ambience to extensions

05 Jan 20:06
Compare
Choose a tag to compare
0.0.4

Open implementations of Ambience

CocoaPods ready

04 Jan 19:21
Compare
Choose a tag to compare
0.0.3

Tag version

Forced states and user control

04 Jan 18:57
Compare
Choose a tag to compare

This release adds support for user control using forced states.

This is procured using a UI Alert View Controller associated to a Storyboard Scene or by simply instantiating a Ambience Object, setting it's view controller and asking it to present the Alert View Controller.

Bare minimal

03 Jan 16:20
Compare
Choose a tag to compare

0.0.1 Bare minimal

Ambience has built-in support for the background color for the following Interface Builder objects:

  • View and all its children;
  • Search, Navigation and Tab bars and all of its children;
  • Text View, Button, and Label and all of its children.

There is also support for the text color for:

  • Text View, Button, and Label and all of its children.

Custom Behaviors

It's also possible to define custom Ambience behavior on any Object that inherits from NSObject. Follow the instructions.

Define an Override of the Ambience Method

In this example, we are implementing the current behavior for Search, Navigation and Tab bars. It guards the notification data for the current state as an Ambience State and sets the bar style accordingly.

public override func ambience(_ notification : Notification) {
    
    super.ambience(notification)
    
    guard let currentState = notification.userInfo?["currentState"] as? AmbienceState else { return }
    
    barStyle = currentState == .invert ? .black : .default
}

The notification user info dictionary also comes with the previous state so that more complex stateful behaviors can be implemented. It may also come with an animated boolean attribute the is usually set to true and, at the first run, set to false so as not to have animation upon view appearance.

Turning Ambience On

If your object is set on Interface Builder, use the Attributes Inspector and set to On the Ambience value.

In case you are setting this object programmatically, just set its ambience boolean value to true before placing it.