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

Commit 332cadd

Browse files
authored
Merge pull request #2090 from RocketChat/develop
[RELEASE] Merge DEVELOP into BETA
2 parents c420b1e + b6d7535 commit 332cadd

44 files changed

Lines changed: 406 additions & 136 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CONTRIBUTING.md

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,57 @@ In case you're interested in playing around with the code or giving something ba
2020

2121
1. A macOS machine
2222
2. Xcode 9.3.x or higher (Swift 4.1)
23-
3. Install [CocoaPods](https://cocoapods.org/) (note that you will need to install at least Ruby 2.2.3 for this to work)
23+
24+
### Installing dependencies
25+
26+
_(NOTE: Steps 3 and 4 must be executed from project's directory)_
27+
28+
1. Clone this repo:
2429
```
25-
sudo gem install cocoapods
30+
git clone https://github.com/RocketChat/Rocket.Chat.iOS
2631
```
27-
To update cocoapods (not that often needed) run
32+
2. Install [Bundler](https://bundler.io)
2833
```
29-
sudo gem update cocoapods
34+
sudo gem install bundler
3035
```
31-
4. Clone this repo:
36+
To update _Bundler_ (when there is new version available)
3237
```
33-
git clone https://github.com/RocketChat/Rocket.Chat.iOS
38+
sudo gem update bundler
39+
```
40+
3. Install all gem dependencies
41+
```
42+
bundle install (sudo might be required in some cases)
43+
```
44+
To update all gem dependencies (usually executed by maintainer) run
45+
```
46+
bundle update
3447
```
35-
5. Download library dependencies using the cocoapods dependency manager (and update the same way):
48+
To update pod's repository (in case of having those oudated compared to Podfile.lock and in case of `pod install` failure)
3649
```
37-
pod install
50+
bundle exec pod repo update
3851
```
39-
6. Do NOT open the Xcode project directly, instead use the Rocket.Chat.xcworkspace file to open the Xcode workspace.
40-
7. Build the project by ⌘ + R
52+
4. Download library dependencies using the cocoapods dependency manager (and update the same way):
53+
```
54+
bundle exec pod install
55+
```
56+
5. Do NOT open the Xcode project directly, instead use the Rocket.Chat.xcworkspace file to open the Xcode workspace.
57+
6. Build the project by ⌘ + R
4158

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

61+
#### Alternative
62+
63+
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.
64+
```
65+
sudo gem install cocoapods
66+
```
67+
Then you can call all the cocoapods actions without **bundle exe** command.
68+
69+
To update cocoapods (not that often needed, you will be notified during `pod install` when new version is available) run.
70+
```
71+
sudo gem update cocoapods
72+
```
73+
4474
## Issues needing help
4575

4676
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.

Podfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ PODS:
4242
- RealmSwift (3.7.4):
4343
- Realm (= 3.7.4)
4444
- semver (1.1.0)
45-
- SimpleImageViewer (1.1.1):
45+
- SimpleImageViewer (1.2.0):
4646
- FLAnimatedImage
4747
- SlackTextViewController (1.9.6)
4848
- Starscream (2.1.1)
@@ -113,7 +113,7 @@ CHECKOUT OPTIONS:
113113
:commit: 43d99beabd1c39f8988d2e6631a46623b0116906
114114
:git: https://github.com/RocketChat/RCMarkdownParser.git
115115
SimpleImageViewer:
116-
:commit: d76f6757d29746071cb6bd17bba9e636d21b03a8
116+
:commit: 8222c338de0f285ca0c2d556c5d8dedd4a365b52
117117
:git: https://github.com/cardoso/SimpleImageViewer.git
118118
SlackTextViewController:
119119
:commit: 944b7cc4de734638cdefdecb9c7d7846fc3ab252
@@ -141,7 +141,7 @@ SPEC CHECKSUMS:
141141
Realm: a469bb59e33f9926102ccaea4349822c53b9117e
142142
RealmSwift: a45861b21c180f5cf0f122144b9759fa8dde3e9e
143143
semver: 11ae3bc4a6036efbc86b5863ef5fa32c065c8bbd
144-
SimpleImageViewer: f82e45a362e3b4b674e25508f42d534e525a73b7
144+
SimpleImageViewer: 6ed0d2acf7c166a5b4e795bccc7b9ea1b225ff9b
145145
SlackTextViewController: b854e62c1c156336bc4fd409c6ca79b5773e8f9d
146146
Starscream: 142bd8ef24592d985daee9fa48c936070b85b15f
147147
SwiftLint: f6b83e8d95ee1e91e11932d843af4fdcbf3fc764

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
![Rocket.Chat logo](https://raw.githubusercontent.com/RocketChat/Rocket.Chat.Artwork/master/Logos/logo-dark.svg?sanitize=true)
22

3+
4+
![Screenshot](https://user-images.githubusercontent.com/7317008/43209700-eb3ded88-904a-11e8-8ec4-9ac10a39f344.png)
5+
6+
<p align="center">
7+
<a href=https://geo.itunes.apple.com/us/app/rocket-chat/id1148741252?mt=8>
8+
<img alt="Download on the app store" src="https://user-images.githubusercontent.com/7317008/43209852-4ca39622-904b-11e8-8ce1-cdc3aee76ae9.png" width=160>
9+
</a>
10+
</p>
11+
312
# Rocket.Chat iOS native application
413

514
[![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)
@@ -10,12 +19,6 @@
1019

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

13-
# Download from the App Store
14-
15-
[![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)
16-
17-
![Screenshots](https://user-images.githubusercontent.com/193273/35874456-d530ee04-0b6c-11e8-8c19-79dee8140114.png)
18-
1922
# Reporting an Issue
2023

2124
[Github Issues](https://github.com/RocketChat/Rocket.Chat.iOS/issues) are used to track todos, bugs, feature requests, and more.

Rocket.Chat.ShareExtension/Base/SENavigationController.swift

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ final class SENavigationController: UINavigationController {
1616
} ?? []
1717

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

2021
return nil
2122
}
@@ -36,9 +37,24 @@ final class SENavigationController: UINavigationController {
3637

3738
override func viewWillAppear(_ animated: Bool) {
3839
super.viewWillAppear(animated)
40+
41+
view.transform = CGAffineTransform(translationX: 0, y: view.frame.size.height)
42+
43+
UIView.animate(withDuration: 0.25, delay: 0, options: UIViewAnimationOptions(rawValue: 7 << 16), animations: { [weak self] in
44+
self?.view.transform = CGAffineTransform.identity
45+
}, completion: nil)
46+
3947
store.subscribe(self)
4048
}
4149

50+
private func completeRequest() {
51+
UIView.animate(withDuration: 0.20, delay: 0, options: UIViewAnimationOptions(rawValue: 7 << 16), animations: { [weak self] in
52+
self?.view.transform = CGAffineTransform(translationX: 0, y: self?.view.frame.height ?? 0)
53+
}, completion: { [weak self] _ in
54+
self?.extensionContext?.completeRequest(returningItems: nil, completionHandler: nil)
55+
})
56+
}
57+
4258
override func viewDidDisappear(_ animated: Bool) {
4359
super.viewWillDisappear(animated)
4460
store.unsubscribe(self)
@@ -83,7 +99,7 @@ extension SENavigationController: SEStoreSubscriber {
8399
statusReport()
84100
}
85101
case .finish:
86-
self.extensionContext?.completeRequest(returningItems: nil, completionHandler: nil)
102+
completeRequest()
87103
store.clearSubscribers()
88104
store.dispatch(.setContent([]))
89105
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//
2+
// SEStateAPI.swift
3+
// Rocket.Chat.ShareExtension
4+
//
5+
// Created by Matheus Cardoso on 7/23/18.
6+
// Copyright © 2018 Rocket.Chat. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
extension SEState {
12+
var api: API? {
13+
guard
14+
let server = selectedServer,
15+
let api = API(host: server.host, version: Version(0, 60, 0))
16+
else {
17+
return nil
18+
}
19+
20+
api.userId = server.userId
21+
api.authToken = server.token
22+
23+
return api
24+
}
25+
}

Rocket.Chat.ShareExtension/Info.plist

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
<key>CFBundlePackageType</key>
1818
<string>XPC!</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>3.0.1</string>
20+
<string>3.0.3</string>
2121
<key>CFBundleVersion</key>
22-
<string>199</string>
22+
<string>203</string>
2323
<key>ITSEncryptionExportComplianceCode</key>
2424
<string></string>
2525
<key>NSExtension</key>
@@ -53,9 +53,5 @@
5353
<key>NSExtensionPointIdentifier</key>
5454
<string>com.apple.share-services</string>
5555
</dict>
56-
<key>UISupportedInterfaceOrientations</key>
57-
<array>
58-
<string>UIInterfaceOrientationPortrait</string>
59-
</array>
6056
</dict>
6157
</plist>

Rocket.Chat.ShareExtension/Rooms/SERoomsViewController.swift

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ final class SERoomsViewController: SEViewController {
1414
didSet {
1515
title = viewModel.title
1616
navigationItem.searchController?.searchBar.text = viewModel.searchText
17+
navigationItem.searchController?.searchBar.showsCancelButton = viewModel.showsCancelButton
1718
tableView.reloadData()
1819
}
1920
}
@@ -36,6 +37,8 @@ final class SERoomsViewController: SEViewController {
3637
searchController.hidesNavigationBarDuringPresentation = false
3738

3839
navigationItem.searchController = searchController
40+
41+
tableView.keyboardDismissMode = .interactive
3942
}
4043

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

5356
extension SERoomsViewController: UISearchBarDelegate {
54-
func searchBarTextDidEndEditing(_ searchBar: UISearchBar) {
55-
store.dispatch(.setSearchRooms(.none))
56-
}
57-
5857
func searchBarTextDidBeginEditing(_ searchBar: UISearchBar) {
5958
store.dispatch(.setSearchRooms(.started))
6059
}
6160

61+
func searchBarCancelButtonClicked(_ searchBar: UISearchBar) {
62+
store.dispatch(.setSearchRooms(.none))
63+
}
64+
6265
func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {
66+
guard !searchText.isEmpty else {
67+
store.dispatch(.setSearchRooms(.none))
68+
return
69+
}
70+
6371
store.dispatch(.setSearchRooms(.searching(searchText)))
6472
}
6573
}

Rocket.Chat.ShareExtension/Rooms/SERoomsViewModel.swift

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,15 @@ struct SERoomsViewModel {
2929
let title: String
3030
let sections: [SERoomsSection]
3131
let searchText: String
32+
let showsCancelButton: Bool
3233

3334
static var emptyState: SERoomsViewModel {
34-
return SERoomsViewModel(title: "Error", sections: [], searchText: "")
35+
return SERoomsViewModel(
36+
title: "Error",
37+
sections: [],
38+
searchText: "",
39+
showsCancelButton: false
40+
)
3541
}
3642
}
3743

@@ -42,10 +48,13 @@ extension SERoomsViewModel {
4248
switch state.searchRooms {
4349
case .none:
4450
searchText = ""
51+
showsCancelButton = false
4552
case .started:
4653
searchText = ""
54+
showsCancelButton = true
4755
case .searching(let text):
4856
searchText = text
57+
showsCancelButton = true
4958
}
5059

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

61-
let channels = state.displayedRooms.filter { $0.type == .channel }.map(roomToCell)
62-
let groups = state.displayedRooms.filter { $0.type == .group }.map(roomToCell)
63-
let directMessages = state.displayedRooms.filter { $0.type == .directMessage }.map(roomToCell)
70+
let notFavorites = state.displayedRooms.filter { !$0.favorite }
71+
let channels = notFavorites.filter { $0.type == .channel }.map(roomToCell)
72+
let groups = notFavorites.filter { $0.type == .group }.map(roomToCell)
73+
let directMessages = notFavorites.filter { $0.type == .directMessage }.map(roomToCell)
6474

6575
let serverCell = SEServerCellModel(iconUrl: server.iconUrl, name: server.name, host: server.host, selected: false)
6676
let serverSection = searchText.isEmpty ? [SERoomsSection(type: .server, cells: [serverCell])] : []

Rocket.Chat.ShareExtension/State/ActionCreators/SelectServer.swift

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,22 @@ func fetchServers(store: SEStore) -> SEAction {
2727
}
2828

2929
func fetchRooms(store: SEStore) -> SEAction {
30-
guard let realm = DatabaseManager.databaseInstace(index: store.state.selectedServerIndex) else { return .setRooms([]) }
30+
defer {
31+
let request = SubscriptionsRequest(updatedSince: nil)
32+
store.state.api?.fetch(request) { response in
33+
switch response {
34+
case .resource(let resource):
35+
store.dispatch(.setRooms(resource.subscriptions ?? []))
36+
case .error:
37+
store.dispatch(.setRooms([]))
38+
}
39+
}
40+
}
41+
42+
guard let realm = DatabaseManager.databaseInstace(index: store.state.selectedServerIndex) else {
43+
return .setRooms([])
44+
}
45+
3146
let rooms = Array(realm.objects(Subscription.self).map(Subscription.init))
3247
return .setRooms(rooms)
3348
}

Rocket.Chat.ShareExtension/State/ActionCreators/SubmitContent.swift

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,6 @@ fileprivate extension SEStore {
3434
}
3535
}.enumerated().map { ($0, $1) }
3636
}
37-
38-
var api: API? {
39-
let server = state.servers[state.selectedServerIndex]
40-
41-
let api = API(host: server.host, version: Version(0, 60, 0))
42-
api?.userId = server.userId
43-
api?.authToken = server.token
44-
45-
return api
46-
}
4737
}
4838

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

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

72-
let task = store.api?.fetch(request) { response in
62+
let task = store.state.api?.fetch(request) { response in
7363

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

120-
let task = store.api?.fetch(request) { response in
110+
let task = store.state.api?.fetch(request) { response in
121111
switch response {
122112
case .resource:
123113
DispatchQueue.main.async {

0 commit comments

Comments
 (0)