Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create initial view to show latest bulletin #3

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,5 @@ fastlane/test_output
.DS_Store

contents.xcworkspacedata

R.generated.swift
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ language: objective-c
osx_image: xcode8
env:
- PLATFORM="ios" SCHEME="FisherHallTests" DESTINATION="platform=iOS Simulator,name=iPhone SE,OS=10.0" SDK="iphonesimulator10.0"
before_install:
- brew update
- brew install rswift
before_script:
- carthage bootstrap --platform $PLATFORM --no-use-binaries
- xcodebuild -project FisherHall.xcodeproj -list
Expand Down
2 changes: 2 additions & 0 deletions Cartfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
github "wvteijlingen/Spine" "master"
github "Quick/Quick"
github "Quick/Nimble"
github "ReactiveX/RxSwift" ~> 3.0
github "mac-cain13/R.swift.Library"
2 changes: 2 additions & 0 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
github "Quick/Nimble" "v5.1.1"
github "Quick/Quick" "v0.10.0"
github "mac-cain13/R.swift.Library" "v3.0.2"
github "antitypical/Result" "3.0.0"
github "ReactiveX/RxSwift" "3.0.1"
github "SwiftyJSON/SwiftyJSON" "3.1.2"
github "Thomvis/BrightFutures" "v5.1.0"
github "wvteijlingen/Spine" "12b71bb45584efc91ce281e01e0e7e86d5cbdc49"
183 changes: 157 additions & 26 deletions FisherHall.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<Testables>
<TestableReference
skipped = "NO">
Expand Down
2 changes: 1 addition & 1 deletion FisherHall/API/Endpoints/AnnouncementEndpoint.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation
import Spine
import BrightFutures
import BrightFutures

class AnnouncementEndpoint {
private static let baseUrl = "https://mcac.church/api/v1/announcements"
Expand Down
3 changes: 3 additions & 0 deletions FisherHall/API/Endpoints/BulletinEndpoint.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Foundation
import Spine
import BrightFutures
import RxSwift

class BulletinEndpoint {
private static let baseUrl = "https://mcac.church/api/v1/bulletins"
Expand All @@ -22,4 +23,6 @@ class BulletinEndpoint {
query.include("announcements")
return client.spine.findOne(query)
}


}
21 changes: 21 additions & 0 deletions FisherHall/API/Endpoints/Rx/RxBulletinEndpoint.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Foundation
import RxSwift

class RxBulletinEndpoint {
private let endpoint: BulletinEndpoint

init(withClient client: FisherHallClient) {
endpoint = BulletinEndpoint(withClient: client)
}

public func getLatestBulletin() -> Observable<BulletinResource> {
return Observable.create { observer in
self.endpoint.getLatestBulletin().onSuccess { resource, _, _ in
observer.on(.next(resource))
observer.on(.completed)
}

return Disposables.create()
}
}
}
16 changes: 16 additions & 0 deletions FisherHall/API/Endpoints/SermonEndpoint.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Foundation
import Spine
import BrightFutures

class SermonEndpoint {
private static let baseUrl = "https://mcac.church/api/v1/sermons"
private let client: FisherHallClient

init(withClient client: FisherHallClient) {
self.client = client
}

public func findById(id: Int) -> Future<(resource: SermonResource, meta: Metadata?, jsonapi: JSONAPIData?), SpineError> {
return client.spine.findOne(String(id), ofType: SermonResource.self)
}
}
5 changes: 5 additions & 0 deletions FisherHall/API/Errors.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Foundation

enum AppError: Error {
case resourceToViewModelConversionError
}
28 changes: 28 additions & 0 deletions FisherHall/API/Resources/SermonResource.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import Foundation
import Spine

class SermonResource: Resource {
var name: String?
var notes: String?
var speaker: String?
var series: String?
var bannerUrl: NSURL?
var audioUrl: NSURL?
var publishedAt: NSDate?

override class var resourceType: ResourceType {
return "sermons"
}

override class var fields: [Field] {
return fieldsFromDictionary([
"name": Attribute(),
"notes": Attribute(),
"speaker": Attribute(),
"series": Attribute(),
"bannerUrl": URLAttribute(),
"audioUrl": URLAttribute(),
"publishedAt": DateAttribute(format: "yyyy-MM-dd'T'HH:mm:ssZZZZZ")
])
}
}
39 changes: 39 additions & 0 deletions FisherHall/AppCoordinator.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import Foundation
import UIKit

class AppCoordinator: Coordinator {
fileprivate let tabBarController: UITabBarController
fileprivate let delegate: AppCoordinatorDelegate
private var childCoordinators: [Coordinator] = []

init(delegate: AppCoordinatorDelegate) {
tabBarController = UITabBarController()
self.delegate = delegate
}

public func start() {
let latestBulletinCoordinator = LatestBulletinCoordinator(delegate: self)
childCoordinators.append(latestBulletinCoordinator)

latestBulletinCoordinator.start()
}
}

extension AppCoordinator: LatestBulletinCoordinatorDelegate {
func didCreateViewController(_ controller: ShowBulletinViewController) {
let bulletinBarItem = UITabBarItem(
title: R.string.localizable.tabBarItemBulletin(),
image: R.image.bulletin(),
selectedImage: R.image.bulletinSelected()
)

controller.tabBarItem = bulletinBarItem
tabBarController.setViewControllers([controller], animated: true)

delegate.didCreateRootViewController(tabBarController)
}
}

protocol AppCoordinatorDelegate {
func didCreateRootViewController(_ controller: UIViewController)
}
62 changes: 20 additions & 42 deletions FisherHall/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,46 +1,24 @@
//
// AppDelegate.swift
// FisherHallClient
//
// Created by Amos Chan on 2016-11-03.
// Copyright © 2016 Amos Chan. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}

func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}

func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


class AppDelegate: UIResponder, UIApplicationDelegate, AppCoordinatorDelegate {
var window: UIWindow?
var coordinator: AppCoordinator?

func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)
coordinator = AppCoordinator(delegate: self)
coordinator!.start()

return true
}

func didCreateRootViewController(_ controller: UIViewController) {
guard let window = self.window else { return }

window.rootViewController = controller
window.makeKeyAndVisible()
}
}

35 changes: 35 additions & 0 deletions FisherHall/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "iphone",
"size" : "29x29",
Expand All @@ -30,6 +35,16 @@
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "57x57",
"scale" : "1x"
},
{
"idiom" : "iphone",
"size" : "57x57",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
Expand Down Expand Up @@ -70,6 +85,26 @@
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "50x50",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "50x50",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "72x72",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "72x72",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
Expand Down
6 changes: 6 additions & 0 deletions FisherHall/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "Google News-2.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "Google News-1.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "Google News.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "Google News.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "Google News-1.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "Google News-2.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions FisherHall/Assets.xcassets/Tab Bar Items/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
26 changes: 0 additions & 26 deletions FisherHall/Base.lproj/Main.storyboard

This file was deleted.

4 changes: 4 additions & 0 deletions FisherHall/Core/Coordinator.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Foundation

protocol Coordinator {
}
Loading