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

Commit

Permalink
Merge pull request #2094 from RocketChat/beta
Browse files Browse the repository at this point in the history
[RELEASE] Merge BETA into MASTER
  • Loading branch information
rafaelks authored Jul 30, 2018
2 parents dfe2659 + 332cadd commit 6ce3162
Show file tree
Hide file tree
Showing 44 changed files with 406 additions and 136 deletions.
50 changes: 40 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,57 @@ In case you're interested in playing around with the code or giving something ba

1. A macOS machine
2. Xcode 9.3.x or higher (Swift 4.1)
3. Install [CocoaPods](https://cocoapods.org/) (note that you will need to install at least Ruby 2.2.3 for this to work)

### Installing dependencies

_(NOTE: Steps 3 and 4 must be executed from project's directory)_

1. Clone this repo:
```
sudo gem install cocoapods
git clone https://github.com/RocketChat/Rocket.Chat.iOS
```
To update cocoapods (not that often needed) run
2. Install [Bundler](https://bundler.io)
```
sudo gem update cocoapods
sudo gem install bundler
```
4. Clone this repo:
To update _Bundler_ (when there is new version available)
```
git clone https://github.com/RocketChat/Rocket.Chat.iOS
sudo gem update bundler
```
3. Install all gem dependencies
```
bundle install (sudo might be required in some cases)
```
To update all gem dependencies (usually executed by maintainer) run
```
bundle update
```
5. Download library dependencies using the cocoapods dependency manager (and update the same way):
To update pod's repository (in case of having those oudated compared to Podfile.lock and in case of `pod install` failure)
```
pod install
bundle exec pod repo update
```
6. Do NOT open the Xcode project directly, instead use the Rocket.Chat.xcworkspace file to open the Xcode workspace.
7. Build the project by ⌘ + R
4. Download library dependencies using the cocoapods dependency manager (and update the same way):
```
bundle exec pod install
```
5. Do NOT open the Xcode project directly, instead use the Rocket.Chat.xcworkspace file to open the Xcode workspace.
6. Build the project by ⌘ + R

Also refer to [Guidelines](#project.pbxproj) for modifying files.

#### Alternative

You can skip installing Bundler (not recommended) and just install [CocoaPods](https://cocoapods.org/) (note that you will need to install at least Ruby 2.2.3 for this to work). Make sure you have correct version of CocoaPods installed or you might be not able to build project properly.
```
sudo gem install cocoapods
```
Then you can call all the cocoapods actions without **bundle exe** command.

To update cocoapods (not that often needed, you will be notified during `pod install` when new version is available) run.
```
sudo gem update cocoapods
```

## Issues needing help

Didn't found a bug or want a new feature not already reported? Check out [the issues with "help wanted"](https://github.com/RocketChat/Rocket.Chat.iOS/labels/help%20wanted) or other issues, for those no branch exists.
Expand Down
6 changes: 3 additions & 3 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ PODS:
- RealmSwift (3.7.4):
- Realm (= 3.7.4)
- semver (1.1.0)
- SimpleImageViewer (1.1.1):
- SimpleImageViewer (1.2.0):
- FLAnimatedImage
- SlackTextViewController (1.9.6)
- Starscream (2.1.1)
Expand Down Expand Up @@ -113,7 +113,7 @@ CHECKOUT OPTIONS:
:commit: 43d99beabd1c39f8988d2e6631a46623b0116906
:git: https://github.com/RocketChat/RCMarkdownParser.git
SimpleImageViewer:
:commit: d76f6757d29746071cb6bd17bba9e636d21b03a8
:commit: 8222c338de0f285ca0c2d556c5d8dedd4a365b52
:git: https://github.com/cardoso/SimpleImageViewer.git
SlackTextViewController:
:commit: 944b7cc4de734638cdefdecb9c7d7846fc3ab252
Expand Down Expand Up @@ -141,7 +141,7 @@ SPEC CHECKSUMS:
Realm: a469bb59e33f9926102ccaea4349822c53b9117e
RealmSwift: a45861b21c180f5cf0f122144b9759fa8dde3e9e
semver: 11ae3bc4a6036efbc86b5863ef5fa32c065c8bbd
SimpleImageViewer: f82e45a362e3b4b674e25508f42d534e525a73b7
SimpleImageViewer: 6ed0d2acf7c166a5b4e795bccc7b9ea1b225ff9b
SlackTextViewController: b854e62c1c156336bc4fd409c6ca79b5773e8f9d
Starscream: 142bd8ef24592d985daee9fa48c936070b85b15f
SwiftLint: f6b83e8d95ee1e91e11932d843af4fdcbf3fc764
Expand Down
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
![Rocket.Chat logo](https://raw.githubusercontent.com/RocketChat/Rocket.Chat.Artwork/master/Logos/logo-dark.svg?sanitize=true)


![Screenshot](https://user-images.githubusercontent.com/7317008/43209700-eb3ded88-904a-11e8-8ec4-9ac10a39f344.png)

<p align="center">
<a href=https://geo.itunes.apple.com/us/app/rocket-chat/id1148741252?mt=8>
<img alt="Download on the app store" src="https://user-images.githubusercontent.com/7317008/43209852-4ca39622-904b-11e8-8ce1-cdc3aee76ae9.png" width=160>
</a>
</p>

# Rocket.Chat iOS native application

[![Build Status](https://circleci.com/gh/RocketChat/Rocket.Chat.iOS/tree/develop.svg?style=shield)](https://circleci.com/gh/RocketChat/Rocket.Chat.iOS/tree/develop)
Expand All @@ -10,12 +19,6 @@

[About Rocket.Chat](https://github.com/RocketChat/Rocket.Chat/#about-rocketchat)

# Download from the App Store

[![Rocket.Chat on Apple AppStore](https://user-images.githubusercontent.com/551004/29770691-a2082ff4-8bc6-11e7-89a6-964cd405ea8e.png)](https://geo.itunes.apple.com/us/app/rocket-chat/id1148741252?mt=8)

![Screenshots](https://user-images.githubusercontent.com/193273/35874456-d530ee04-0b6c-11e8-8c19-79dee8140114.png)

# Reporting an Issue

[Github Issues](https://github.com/RocketChat/Rocket.Chat.iOS/issues) are used to track todos, bugs, feature requests, and more.
Expand Down
18 changes: 17 additions & 1 deletion Rocket.Chat.ShareExtension/Base/SENavigationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ final class SENavigationController: UINavigationController {
} ?? []

parseItemProviders(store, itemProviders)
UIDevice.current.setValue(UIInterfaceOrientation.portrait.rawValue, forKey: "orientation")

return nil
}
Expand All @@ -36,9 +37,24 @@ final class SENavigationController: UINavigationController {

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

view.transform = CGAffineTransform(translationX: 0, y: view.frame.size.height)

UIView.animate(withDuration: 0.25, delay: 0, options: UIViewAnimationOptions(rawValue: 7 << 16), animations: { [weak self] in
self?.view.transform = CGAffineTransform.identity
}, completion: nil)

store.subscribe(self)
}

private func completeRequest() {
UIView.animate(withDuration: 0.20, delay: 0, options: UIViewAnimationOptions(rawValue: 7 << 16), animations: { [weak self] in
self?.view.transform = CGAffineTransform(translationX: 0, y: self?.view.frame.height ?? 0)
}, completion: { [weak self] _ in
self?.extensionContext?.completeRequest(returningItems: nil, completionHandler: nil)
})
}

override func viewDidDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
store.unsubscribe(self)
Expand Down Expand Up @@ -83,7 +99,7 @@ extension SENavigationController: SEStoreSubscriber {
statusReport()
}
case .finish:
self.extensionContext?.completeRequest(returningItems: nil, completionHandler: nil)
completeRequest()
store.clearSubscribers()
store.dispatch(.setContent([]))
}
Expand Down
25 changes: 25 additions & 0 deletions Rocket.Chat.ShareExtension/Extensions/SEStateAPI.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// SEStateAPI.swift
// Rocket.Chat.ShareExtension
//
// Created by Matheus Cardoso on 7/23/18.
// Copyright © 2018 Rocket.Chat. All rights reserved.
//

import Foundation

extension SEState {
var api: API? {
guard
let server = selectedServer,
let api = API(host: server.host, version: Version(0, 60, 0))
else {
return nil
}

api.userId = server.userId
api.authToken = server.token

return api
}
}
8 changes: 2 additions & 6 deletions Rocket.Chat.ShareExtension/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>3.0.1</string>
<string>3.0.3</string>
<key>CFBundleVersion</key>
<string>199</string>
<string>203</string>
<key>ITSEncryptionExportComplianceCode</key>
<string></string>
<key>NSExtension</key>
Expand Down Expand Up @@ -53,9 +53,5 @@
<key>NSExtensionPointIdentifier</key>
<string>com.apple.share-services</string>
</dict>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
</dict>
</plist>
16 changes: 12 additions & 4 deletions Rocket.Chat.ShareExtension/Rooms/SERoomsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ final class SERoomsViewController: SEViewController {
didSet {
title = viewModel.title
navigationItem.searchController?.searchBar.text = viewModel.searchText
navigationItem.searchController?.searchBar.showsCancelButton = viewModel.showsCancelButton
tableView.reloadData()
}
}
Expand All @@ -36,6 +37,8 @@ final class SERoomsViewController: SEViewController {
searchController.hidesNavigationBarDuringPresentation = false

navigationItem.searchController = searchController

tableView.keyboardDismissMode = .interactive
}

override func stateUpdated(_ state: SEState) {
Expand All @@ -51,15 +54,20 @@ final class SERoomsViewController: SEViewController {
// MARK: UISearchBarDelegate

extension SERoomsViewController: UISearchBarDelegate {
func searchBarTextDidEndEditing(_ searchBar: UISearchBar) {
store.dispatch(.setSearchRooms(.none))
}

func searchBarTextDidBeginEditing(_ searchBar: UISearchBar) {
store.dispatch(.setSearchRooms(.started))
}

func searchBarCancelButtonClicked(_ searchBar: UISearchBar) {
store.dispatch(.setSearchRooms(.none))
}

func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {
guard !searchText.isEmpty else {
store.dispatch(.setSearchRooms(.none))
return
}

store.dispatch(.setSearchRooms(.searching(searchText)))
}
}
Expand Down
18 changes: 14 additions & 4 deletions Rocket.Chat.ShareExtension/Rooms/SERoomsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,15 @@ struct SERoomsViewModel {
let title: String
let sections: [SERoomsSection]
let searchText: String
let showsCancelButton: Bool

static var emptyState: SERoomsViewModel {
return SERoomsViewModel(title: "Error", sections: [], searchText: "")
return SERoomsViewModel(
title: "Error",
sections: [],
searchText: "",
showsCancelButton: false
)
}
}

Expand All @@ -42,10 +48,13 @@ extension SERoomsViewModel {
switch state.searchRooms {
case .none:
searchText = ""
showsCancelButton = false
case .started:
searchText = ""
showsCancelButton = true
case .searching(let text):
searchText = text
showsCancelButton = true
}

let server = state.servers[state.selectedServerIndex]
Expand All @@ -58,9 +67,10 @@ extension SERoomsViewModel {
($0.type.rawValue, $0.name.lowercased()) < ($1.type.rawValue, $1.name.lowercased())
}.map(roomToCell)

let channels = state.displayedRooms.filter { $0.type == .channel }.map(roomToCell)
let groups = state.displayedRooms.filter { $0.type == .group }.map(roomToCell)
let directMessages = state.displayedRooms.filter { $0.type == .directMessage }.map(roomToCell)
let notFavorites = state.displayedRooms.filter { !$0.favorite }
let channels = notFavorites.filter { $0.type == .channel }.map(roomToCell)
let groups = notFavorites.filter { $0.type == .group }.map(roomToCell)
let directMessages = notFavorites.filter { $0.type == .directMessage }.map(roomToCell)

let serverCell = SEServerCellModel(iconUrl: server.iconUrl, name: server.name, host: server.host, selected: false)
let serverSection = searchText.isEmpty ? [SERoomsSection(type: .server, cells: [serverCell])] : []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,22 @@ func fetchServers(store: SEStore) -> SEAction {
}

func fetchRooms(store: SEStore) -> SEAction {
guard let realm = DatabaseManager.databaseInstace(index: store.state.selectedServerIndex) else { return .setRooms([]) }
defer {
let request = SubscriptionsRequest(updatedSince: nil)
store.state.api?.fetch(request) { response in
switch response {
case .resource(let resource):
store.dispatch(.setRooms(resource.subscriptions ?? []))
case .error:
store.dispatch(.setRooms([]))
}
}
}

guard let realm = DatabaseManager.databaseInstace(index: store.state.selectedServerIndex) else {
return .setRooms([])
}

let rooms = Array(realm.objects(Subscription.self).map(Subscription.init))
return .setRooms(rooms)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,6 @@ fileprivate extension SEStore {
}
}.enumerated().map { ($0, $1) }
}

var api: API? {
let server = state.servers[state.selectedServerIndex]

let api = API(host: server.host, version: Version(0, 60, 0))
api?.userId = server.userId
api?.authToken = server.token

return api
}
}

var urlTasks: [URLSessionTask?] = []
Expand All @@ -69,7 +59,7 @@ func submitFiles(store: SEStore, completion: @escaping (() -> Void)) {

store.dispatch(.setContentValue(content.withStatus(.sending), index: index))

let task = store.api?.fetch(request) { response in
let task = store.state.api?.fetch(request) { response in

switch response {
case .resource(let resource):
Expand Down Expand Up @@ -117,7 +107,7 @@ func submitMessages(store: SEStore, completion: @escaping (() -> Void)) {
let content = store.state.content[index]
store.dispatch(.setContentValue(content.withStatus(.sending), index: index))

let task = store.api?.fetch(request) { response in
let task = store.state.api?.fetch(request) { response in
switch response {
case .resource:
DispatchQueue.main.async {
Expand Down
11 changes: 11 additions & 0 deletions Rocket.Chat.ShareExtension/State/SESearchState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,15 @@ enum SESearchState {
case none
case started
case searching(String)

var text: String {
switch self {
case .none:
return ""
case .started:
return ""
case .searching(let query):
return query
}
}
}
8 changes: 8 additions & 0 deletions Rocket.Chat.ShareExtension/State/SEState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ enum SEAction {
struct SEState {
var servers: [SEServer] = []
var selectedServerIndex: Int = 0
var selectedServer: SEServer? {
guard selectedServerIndex < servers.count else {
return nil
}

return servers[selectedServerIndex]
}

var rooms: [Subscription] = []
var currentRoom = Subscription()
var searchRooms: SESearchState = .none
Expand Down
Loading

0 comments on commit 6ce3162

Please sign in to comment.