Swiftpack.co - Package - cgoldsby/TvOSMoreButton

TvOSMoreButton

๐Ÿ“บ A tvOS button which truncates long text with '... More'.

The TvOSMoreButton is a simple view which aims to mirror the behavior of Apple's "... More" button; as seen in the Movie App.

Features

If the text is too long to fit with in the button bounds then the text will be truncated and '... More' will be appended.

By default, if the text is truncated the button will be focusable. If the text is not truncated then the button will not be focusable.

However, you can set focusableMode to manual(_ isFocusable: Bool) to alter the focus behavior. This mode will force the button to be always be focused or never be focused.

When the button is focused, pressing select on the Apple TV remote will trigger a callback.

The majority of the UI properties are configurable; like

  • the button text
  • ellipse text; defaults to '...'
  • trailing text; defaults to "More"
  • trailing text color and font
  • the button text color and font
  • shadows and radius
  • and More ๐Ÿ˜‰

Requirements

  • tvOS 9.0+
  • Xcode 9

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate TvOSMoreButton into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :tvos, '9.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'TvOSMoreButton', '~> 1.3.0'
end

Then, run the following command:

$ pod install

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate TvOSMoreButton into your Xcode project using Carthage, specify it in your Cartfile:

github "cgoldsby/TvOSMoreButton" ~> 1.2.2

Run carthage update to build the framework and drag the built TvOSMoreButton.framework into your Xcode project.

Usage example

Please check out the Example workspace for more details.

    import TvOSMoreButton

    private func setUpUI() {
        tvOSMoreButton.text = // Super long text
        tvOSMoreButton.buttonWasPressed = {
            [weak self] text in
            self?.moreButtonWasPressed(text: text)
        }
    }

    private func moreButtonWasPressed(text: String?) -> Void {
        // Do something. May I suggest using TvOSTextViewerViewController
        // to display the text in a full screen view!
        let viewController = TvOSTextViewerViewController()
        viewController.text = text
        viewController.textColor = .white
        viewController.textEdgeInsets = UIEdgeInsets(top: 100, left: 250, bottom: 100, right: 250)
        present(viewController, animated: true)
    }

If you would like to display a fullscreen view with just the text then definitely check out @dcordero's awesome TvOSTextViewer. So good!

Contribute

We would love for you to contribute to TvOSMoreButton, check the LICENSE file for more info. Feel free to submit any issues or PRs. โค๏ธ

Meta

Special thanks @mona-zsh for her fantastic article on String Truncation.

Chris Goldsby โ€“ @goldsbychris

Distributed under the MIT license. See LICENSE for more information.

Github

link
Stars: 50

Used By

Total: 0

Releases

Support Swift Package Manager (SPM) ๐Ÿ“ฆ -

Support for Swift Package Manager (#35) via Markus Mueller.

Personal thanks to everyone who contributed! ๐Ÿ™‡

Update to Swift 5 ๐Ÿฆ‰ -

Support for building with Xcode 11 and Swift 5.0. This version requires Xcode 11 or later with Swift 5.0 compiler (#33) via David Cordero

More control over when the button is focused ๐Ÿ”ข -

This release adds new functionality, focusableMode to define when the button should be focused (#29).

By default, the focusable mode is set to auto. When the text is too long the button will be focusable, else it will not be focusable. This is the current behavior.

In addition, you can set the focusable mode to manual(_ isFocusable: Bool). This mode will force the button to be always be focused or never be focused.

  • Added focusableMode property (#29) via Roman Gritsuk

Personal thanks to everyone who contributed! ๐Ÿ™‡

Let make 2019 a great year together! ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป

Incorrect Trailing Text Bug Fix ๐Ÿž -

This release fixes a bug (#26) where the trailing text was being truncated.

  • Fixes a bug where the trailing text is being truncated (#28) via Roman Gritsuk

Personal thanks to everyone who contributed! ๐Ÿ™‡

2019 is right around the corner! ๐Ÿ˜‰ ๐ŸŽ†

Incorrect Focus Style Bug Fix ๐Ÿ› -

This release fixes a bug (#24) where the button (un)focused style is not correct.

  • Fixes a bug where the button (un)focused style is not correct (#25) via Chris Goldsby

No API changes.

Have a great winter everyone! Stay warm! And, if I don't see you, "Have a great New Year!" โ›„๏ธ

Swift 4.2 ๐Ÿฆ‰ -

Support for building with Xcode 10 and Swift 4.2. This version requires Xcode 10 or later with Swift 4.2 compiler.

No API changes.

Have a great week everybody! ๐ŸŽธ

Right To Left Support ๐Ÿ‘‰ -

Added textAlignment property to improve right to left text support, e.g. Arabic language.

  • Added textAlignment (#18) via Furkan Hatipoglu

Personal thanks to everyone who contributed! ๐Ÿ™‡

Almost October; may your Halloween be spooky! ๐ŸŽƒ

Bug Fixes ๐Ÿ› -

No API changes.

  • Update UI whenever trailingText & ellipsesString changes via Chris Goldsby

Have a Happy Fall everyone! ๐Ÿ‚

Accessibility Updates โ™ฟ๏ธ -

No API changes.

  • Add UIAccessibility (#14) via Chris Goldsby
  • Code style updates (#13) via Chris Goldsby

Have a Happy Spring everyone! ๐ŸŒป

Improved Carthage Documentation, Objective-C Support, & Deprecated Warning Fixes -

No API changes.

  • Document installation via Carthage (#8) via David Cordero
  • Objective-C Support (#9) via Andrรฉ Silva
  • Fix "characters was deprecated" warning (#10) via David Cordero

What a great release! Personal thanks to everyone who contributed! ๐Ÿ™‡

Have a Happy Fall everyone! ๐Ÿ‚

Swift 4.0 and Xcode 9 -

Xcode 9 and 3.2+ is now required.

Changes This library has been migrated to Swift 4.

No API changes.

Swift 3.2 Support

If your project is using Swift 3.2, you can still use this release by overriding the SWIFT_VERSION to be 4.0 in your Podfile.

post_install do |installer|
    installer.pods_project.targets.each do |target|
        if target.name == 'TvOSMoreButton'
            target.build_configurations.each do |config|
                config.build_settings['SWIFT_VERSION'] = '4.0'
            end
        end
    end
end

Or, you can use the previous release, 1.0.2, which does not require the post_install hook and will compile just fine with Xcode 9 and Swift 3.2.

๐ŸŽ‰

Support More Localizations: ๐Ÿ‡ฒ๐Ÿ‡ฝ, ๐Ÿ‡ฏ๐Ÿ‡ต, ๐Ÿ‡ณ๐Ÿ‡ฑ, ๐Ÿ‡ณ๐Ÿ‡ด, ๐Ÿ‡ท๐Ÿ‡บ -

No API changes.

Added

The TvOSMoreButton is now localized in:

Espaรฑol Mexicano ๐Ÿ‡ฒ๐Ÿ‡ฝ
Japanese ๐Ÿ‡ฏ๐Ÿ‡ต
Dutch ๐Ÿ‡ณ๐Ÿ‡ฑ
Norwegian ๐Ÿ‡ณ๐Ÿ‡ด Russian ๐Ÿ‡ท๐Ÿ‡บ

๐ŸŒ ๐ŸŽ‰

Support More Localizations: ๐Ÿ‡ฉ๐Ÿ‡ช, ๐Ÿ‡ซ๐Ÿ‡ท, ๐Ÿ‡ช๐Ÿ‡ธ, ๐Ÿ‡ฎ๐Ÿ‡น -

No API changes.

Added

The TvOSMoreButton is now localized in:

Espaรฑol ๐Ÿ‡ฉ๐Ÿ‡ช French ๐Ÿ‡ซ๐Ÿ‡ท Deutsch ๐Ÿ‡ช๐Ÿ‡ธ Italian ๐Ÿ‡ฎ๐Ÿ‡น

๐ŸŒ ๐ŸŽ‰

Initial Release ๐ŸŽ‰ -