Latest 1.0.1
Homepage https://github.com/BellAppLab/BLBubbleFilters
License MIT
Platforms ios 9.0, tvos 9.0
Frameworks SpriteKit
Authors

BLBubbleFilters Version License

Platforms
CocoaPods Compatible
Carthage compatible
Twitter

BLBubbleFilters

BLBubbleFilters

BLBubbleFilters gives you bubble filters à la Apple Music.

Inspired by: SIFloatingCollection_Swift

Specs

  • SpriteKit
  • iOS 9+
  • tvOS 9+

Usage

The starting point of using BLBubbleFilters is the BLBubbleScene class. We begin by initialising one:

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    BLBubbleScene *scene = [BLBubbleScene sceneWithSize:CGSizeMake(self.view.bounds.size.width / 2.0, self.view.bounds.size.height / 2.0)];
    scene.backgroundColor = [UIColor whiteColor];
    scene.bubbleDataSource = <#code#>;
    scene.bubbleDelegate = <#code#>;

    [(SKView *)self.view presentScene:scene];
}

Notes:

  1. We highly recommend initialising a BLBubbleScene on viewWillAppear: so it gets correctly adjusted to the screen size.
  2. The example above assumes your view controller’s view is a SKView.

Scene data source

You must provide the BLBubbleScene with a data source conforming to the BLBubbleSceneDataSource protocol. Its two required methods are:

//provides the scene with the number of bubbles to present
- (NSInteger)numberOfBubblesInBubbleScene:(BLBubbleScene *)scene {
    return <#code#>;
}

And:

- (id<BLBubbleModel>)bubbleScene:(BLBubbleScene *)scene
           modelForBubbleAtIndex:(NSInteger)index
{
    return <#code#>;
}

The BLBubbleModel protocol provides a bubble with some of the visual information it needs to draw itself.

Scene delegate

You may set the scene’s delegate, if you’d like to be notified when a bubble is selected:

- (void)bubbleScene:(BLBubbleScene *)scene
    didSelectBubble:(BLBubbleNode *)bubble
            atIndex:(NSInteger)index
{
    //a bubble has been tapped
}

Example

A typical implementation of BLBubbleFilters looks like this:

#import "ViewController.h"
#import <BLBubbleFilters/BLBubbleFilters.h>
#import "Bubble.h"

@interface ViewController () <BLBubbleSceneDataSource, BLBubbleSceneDelegate>

@property (nonatomic, strong) NSArray<Bubble *> *bubbles;

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];

    [self setBubbles:@[[[Bubble alloc] initWithIndex:0],
                       [[Bubble alloc] initWithIndex:1],
                       [[Bubble alloc] initWithIndex:2],
                       [[Bubble alloc] initWithIndex:3]]];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    BLBubbleScene *scene = [BLBubbleScene sceneWithSize:self.view.bounds.size];
    scene.backgroundColor = [UIColor whiteColor];
    scene.bubbleDataSource = self;
    scene.bubbleDelegate = self;

    [(SKView *)self.view presentScene:scene];
}

#pragma mark Bubble Delegate

- (void)bubbleScene:(BLBubbleScene *)scene
    didSelectBubble:(BLBubbleNode *)bubble
            atIndex:(NSInteger)index
{
    NSLog(@"Bubble Pressed! %@", bubble);
    NSLog(@"The bubble is now on state %ld", (long)[bubble.model bubbleState]);
}

#pragma mark Bubble Data Source

- (NSInteger)numberOfBubblesInBubbleScene:(BLBubbleScene *)scene
{
    return self.bubbles.count;
}

- (id<BLBubbleModel>)bubbleScene:(BLBubbleScene *)scene
           modelForBubbleAtIndex:(NSInteger)index
{
    return [self.bubbles objectAtIndex:index];
}

@end

Note: Implementation of the Bubble Data Model is up to you. ;)

Requirements

  • iOS 8+
  • Obj-C
  • SpriteKit

Installation

Cocoapods

pod 'BLBubbleFilters', '~> 1.0'

Then #import <BLBubbleFilters/BLBubbleFilters.h> where needed.

Carthage

github "BellAppLab/BLBubbleFilters" ~> 1.0

Then #import <BLBubbleFilters/BLBubbleFilters.h> where needed.

Git Submodules

cd toYourProjectsFolder
git submodule add -b submodule --name BLBubbleFilters https://github.com/BellAppLab/BLBubbleFilters.git

Then drag the BLBubbleFilters folder into your Xcode project.

Author

Bell App Lab, [email protected]

Credits

Logo image by Jaohuarye from The Noun Project

License

BLBubbleFilters is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "BLBubbleFilters",
    "version": "1.0.1",
    "summary": "BLBubbleFilters gives you bubble filters u00e0 la Apple Music.",
    "screenshots": [
        "https://github.com/BellAppLab/BLBubbleFilters/raw/master/Images/bubble_filters.png",
        "https://github.com/BellAppLab/BLBubbleFilters/raw/master/Images/bubble_filters.gif"
    ],
    "description": "BLBubbleFilters gives you bubble filters u00e0 la Apple Music.nnInspired by: [SIFloatingCollection_Swift](https://github.com/ProudOfZiggy/SIFloatingCollection_Swift).",
    "homepage": "https://github.com/BellAppLab/BLBubbleFilters",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Bell App Lab": "[email protected]"
    },
    "social_media_url": "https://twitter.com/BellAppLab",
    "platforms": {
        "ios": "9.0",
        "tvos": "9.0"
    },
    "module_name": "BLBubbleFilters",
    "header_dir": "Headers",
    "source": {
        "git": "https://github.com/BellAppLab/BLBubbleFilters.git",
        "tag": "1.0.1"
    },
    "source_files": [
        "BLBubbleFilters",
        "Headers"
    ],
    "frameworks": "SpriteKit",
    "ios": {
        "frameworks": "UIKit"
    },
    "tvos": {
        "frameworks": "UIKit"
    }
}

Pin It on Pinterest

Share This