• This repository has been archived on 22/Jan/2019
  • Stars
    star
    347
  • Rank 122,141 (Top 3 %)
  • Language
    Swift
  • License
    Apache License 2.0
  • Created about 9 years ago
  • Updated about 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Model View Presenter Framework written in Swift.

Karumi logoBothamUI Build Status CocoaPods Compatible

BothamUI is MVP (Model-View-Presenter) framework written in Swift.

This project will help you setup all your presentation logic. BothamUI provides classes to represent the main components of this pattern like BothamViewController and BothamPresenter.

In addition we will use a wireframe navigation model and a service locator example[[5] [di]].

Screenshots

Screenshot1

Application UI/UX designs by Luis Herrero.

Data provided by Marvel. © 2015 MARVEL

Usage

This framework contains all the classes needed to implement your presentation logic following the MVP pattern. To use the view package, make your ViewController extend from Botham ViewController and specify in the storyboard wich class and Storyboard ID is linked to:

import BothamUI

class SampleViewController: BothamViewController {
    /*...*/
}

storyboardReference

Storyboard

BothamStoryboard provide a series of methods to help you instantiate view controllers by there storyboard ID. By default instantiateViewController() will search for view controller with the storyboard ID with the same name as the class.

import BothamUI

let mainStoryboard = BothamStoryboard(name: "Main")
let viewController: SampleViewController = mainStoryboard.instantiateViewController("SampleViewController")
let viewController: SampleViewController = mainStoryboard.instantiateViewController()

Presenter

To follow the MVP pattern, BothamUI also provides a BothamPresenter protocol that will be responsible for all your presentation logic. BothamUI will take care of linking your view (a BothamViewController) with your presenter and subscribing it to its lifecycle. In order to do that, create a class that implement BothamPresenter and link it to your view:

import BothamUI

class SamplePresenter: BothamPresenter {
    private weak var ui: SampleUI?

    init(ui: CharacterDetailUI) {
        self.ui = ui
    }
    
    func viewDidLoad() {
        /* ... */
    }
}
protocol SampleUI: BothamUI {
	/* ... */
}
class SampleViewController: BothamViewController, SampleUI {
    /*...*/
}

Dependency injection

BothamUI is built around the concept of dependency injection, all the dependencies are provided by constructor or properties, base on what UIKit allows us.

ViewController Instantiation

In the example a Service Locator is used in order to instantiate view controllers, but you can also use Swinject or others DI frameworks.

class ServiceLocator {

    static let sharedInstance = ServiceLocator()

    func provideSampleViewController() -> SampleViewController {
        let viewController: SampleViewController = provideMainStoryboard().viewController()
        viewController.presenter = SamplePresenter(ui: viewController)
        return viewController
    }
}

Lifecycle

Once both, view and presenter, are linked you can react to your view lifecycle directly from the presenter. You will be also able to call your view easily from the presenter:

class SamplePresenter: BothamPresenter {
    private weak var ui: SampleUI?

    init(ui: CharacterDetailUI) {
        self.ui = ui
    }
    
    func viewDidLoad() {
        self.ui?.showMessage("Welcome to Botham")
    }
}

To understand when the lifecycle methods are called take a look at the following table:

BothamPresenter UIViewController
viewDidLoad viewDidLoad
viewWillAppear viewWillAppear
viewDidAppear viewDidAppear
viewWillDisappear viewWillDisappear
viewDidDisappear viewDidDisappear

Caveats

  • ViewControllers instantiated view UIStoryboard, can't reference Generic Type.
  • Presenter and ViewController have a circular reference (like a ViewController and Datasource).

CocoaPods

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

$ gem install cocoapods

CocoaPods 0.39.0+ is required to build BothamUI.

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

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'BothamUI', '~> 1.0'

Then, run the following command:

$ pod install

Do you want to contribute?

Feel free to report us or add any useful feature to the library, we will be glad to improve it with your help.

Keep in mind that your PRs must be validated by Travis-CI.

License

Copyright 2015 Karumi

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

More Repositories

1

Dexter

Android library that simplifies the process of requesting permissions at runtime.
Java
5,233
star
2

Rosie

Rosie is an Android framework to create applications following the principles of Clean Architecture.
Java
1,824
star
3

ExpandableSelector

ExpandableSelector is an Android library created to show a list of Button/ImageButton widgets inside a animated container which can be collapsed or expanded.
Java
693
star
4

KataSuperHeroesAndroid

Super Heroes Kata for Android Developers. The main goal is to practice UI Testing.
Java
683
star
5

HeaderRecyclerView

HeaderRecyclerView is an Android library created to be able to use RecyclerView.Adapter with a header in a easy way. To use this library create your RecyclerView.Adapter classes extending from HeaderRecyclerViewAdapter.
Java
501
star
6

Dividers

Dividers is a simple Android library to create easy separators for your RecyclerViews
Java
483
star
7

AndroidAudit

Your Android app as a crime scene!!!
468
star
8

KataScreenshotAndroid

Screenshot Kata for Android Developers. The main goal is to practice UI Testing.
Java
265
star
9

KataContactsJava

KataContacts written in Java. The main goal is to practice Clean Architecture Development.
Java
111
star
10

project-quality-assurance

Define a general guidance for tech projects quality assurance at Karumi.
102
star
11

KataSuperHeroesKotlin

Super Heroes Kata for Android Developers in Kotlin. The main goal is to practice UI Testing.
Kotlin
86
star
12

KataScreenshotKotlin

Screenshot Kata for Android Developers with Kotlin. The main goal is to practice UI Screenshot Testing.
Kotlin
76
star
13

KataSuperHeroesIOS

Super heroes kata for iOS Developers. The main goal is to practice UI Testing.
Swift
69
star
14

learnyougit

A self-guided workshop to learn the basics and some of the internals of Git
JavaScript
67
star
15

MarvelApiClientAndroid

Api client for Marvel Api
Java
66
star
16

MaxibonKataJava

Maxibon kata for Java Developers. The main goal is to practice property based testing.
Java
65
star
17

KataTODOApiClientKotlin

TODO API Client Kata for Kotlin Developers. The main goal is to practice integration testing using MockWebServer
Kotlin
60
star
18

KataContactsSwift

KataContacts written in Swift. The main goal is to practice Clean Architecture Development.
Swift
60
star
19

KataTODOApiClientJava

TODO API Client Kata for Java Developers. The main goal is to practice integration testing using MockWebServer.
Java
53
star
20

play-framework-kotlin

This repository is to show how to create an Play Framework project using Kotlin
Kotlin
48
star
21

KataContactsKotlin

KataContacts written in Kotlin. The main goal is to practice Clean Architecture Development
Kotlin
48
star
22

Hagu

Gradle plugin to enable Kotlin build configuration secrets for Kotlin, Kotlin-Native / Multiplatform.
Kotlin
47
star
23

KataSuperHeroesJetpack

SuperHeroes kata for Jetpack Developers in Kotlin
Kotlin
47
star
24

WeakDelegate

WeakReference property delegate proposal
Kotlin
47
star
25

KotlinMultiplatformApp

Application example using Kotlin multiplatform
Objective-C
43
star
26

MaxibonKataKotlin

Maxibon kata for Kotlin Developers. The main goal is to practice property based testing.
Kotlin
43
star
27

SuperHeroesKotlin

An example of architecture in kotlin
Kotlin
41
star
28

Reddo

Show messages in a 16x32 led matrix using a Raspberry Pi.
Java
39
star
29

SpringBootKotlin

Spring boot Kotlin example
Kotlin
38
star
30

BothamNetworking

Networking Framework written in Swift.
Swift
26
star
31

MaxibonKataIOS

Maxibon kata for iOS Developers. The main goal is to practice property based testing.
Swift
26
star
32

ControlFlowUI

A library that add control flow functionality to SwitUI, using the power of @functionBuilder and ViewBuilder.
Swift
25
star
33

AndroidAnimations

This is the project where we will analyze study and put into practice how to work with animations in Android
Kotlin
22
star
34

KataTODOApiClientIOS

TODO API Client Kata for iOS Developers. The main goal is to practice integration testing using Nocilla and Nimble.
Swift
21
star
35

FoursquareTop

Code for the app made as part of the NSSpain 2016 talk
Swift
21
star
36

KataSuperHeroesCompose

Super Heroes Kata implemented using Jetpack Compose and Screenshot Testing.
Kotlin
19
star
37

iOSBasicTraining

Code associated to the first level of our iOS Training.
Swift
17
star
38

KataCoroutines

Transform this game-of-life sequential implementation to a parallel version with Kotlin coroutines
Kotlin
16
star
39

ReactNativePlayground

Playground used to learn and experiment with React Native 🚀
TypeScript
16
star
40

KataScreenshotIOS

Screenshot Kata for iOS Developers. The main goal is to practice UI Testing
Swift
16
star
41

KataLogInLogOutKotlin

Solution for the testing kata imparted during the mobile testing training written in Kotlin
Kotlin
15
star
42

MarvelApiClient

Marvel Api Client written in Swift.
Swift
14
star
43

ktlint-sbt

Ktlint Sbt Plugin
Scala
13
star
44

kodein-sample-testing

This repository aims to be a small example of how to use Kodein to provide different implementations for production code and testing code
Kotlin
11
star
45

KataSuperHeroesSpringBoot

This is a spring boot kata for the courses.
Kotlin
10
star
46

EndZone

Swift
10
star
47

hangout-slack-import

Script that help you import your google hangout chat history to Slack
Python
9
star
48

MagicCounterKataAndroid

Magic counter kata for Android developers. The main goal is to unit and integration testing.
Kotlin
9
star
49

KataSuperHeroesReactNative

Super Heroes Kata for React Native Developers in Typescript.
TypeScript
8
star
50

HotSwitchLocalizationTest

Android app implemented to show how to change the language and country used by our apps in runtime without restarting thea app. This only works for API >= 17. For API < 17 the localization change is not applied.
Kotlin
6
star
51

boilerplate-wars

Swift
6
star
52

TestingPlayFramework

Example repository used to show how to test a Play Framework application
Scala
4
star
53

KataContactsCSharp

C#
4
star
54

KataLogInLogOutSwift

Solution for the testing kata imparted during the mobile testing training written in Swift
Swift
4
star
55

LitElementPlayground

Playground used to learn and experiment with Lit Element and Web development
JavaScript
3
star
56

BasicTextFieldKeyboardBug

Repository used to show how to reproduce a bug we've found in BasicTextField component.
Kotlin
3
star
57

ExtensionProtocolforStruct

Swift
3
star
58

infrared-wifi-bridge-led

Open Hardware, Infrared Wifi bridge with an integrated LED Strip.
C
2
star
59

MaxibonKataCSharp

C#
2
star
60

SwiftMonad

Swift
2
star
61

KarumiJekyllTheme

Karumi Official Jekyll Template
CSS
2
star
62

KataSuperHeroesSwiftUI

Swift
2
star
63

MagicCounterKataIOS

Magic counter kata for iOS developers. The main goal is to unit and integration testing.
Swift
1
star