Skip to content

Commit e9b1a34

Browse files
author
Maurice Breit
committed
team image
1 parent 3626dcb commit e9b1a34

File tree

55 files changed

+5060
-1955
lines changed

Some content is hidden

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

55 files changed

+5060
-1955
lines changed

CoachPlus/CoachPlusInfoDev.plist

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<key>CFBundleShortVersionString</key>
2020
<string>0.1</string>
2121
<key>CFBundleVersion</key>
22-
<string>16</string>
22+
<string>17</string>
2323
<key>LSRequiresIPhoneOS</key>
2424
<true/>
2525
<key>UILaunchStoryboardName</key>
@@ -43,5 +43,9 @@
4343
<string>UIInterfaceOrientationLandscapeLeft</string>
4444
<string>UIInterfaceOrientationLandscapeRight</string>
4545
</array>
46+
<key>NSCameraUsageDescription</key>
47+
<string>Used to select team and user images</string>
48+
<key>NSPhotoLibraryUsageDescription</key>
49+
<string>Used to select team and user images</string>
4650
</dict>
4751
</plist>

CoachPlus/app/team/CreateTeamViewController.swift

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@
88

99
import UIKit
1010
import SkyFloatingLabelTextField
11+
import ImagePicker
1112

12-
class CreateTeamViewController: CoachPlusViewController {
13+
class CreateTeamViewController: CoachPlusViewController, ImagePickerDelegate {
1314

1415
@IBOutlet weak var nameTf: SkyFloatingLabelTextField!
1516

1617
@IBOutlet weak var createBtn: OutlineButton!
1718

1819

20+
var selectedImage:UIImage?
1921

2022

2123

@@ -30,21 +32,61 @@ class CreateTeamViewController: CoachPlusViewController {
3032
// Dispose of any resources that can be recreated.
3133
}
3234

35+
@IBAction func selectImageTapped(_ sender: Any) {
36+
37+
var config = Configuration()
38+
config.doneButtonTitle = "Finish"
39+
config.noImagesTitle = "Sorry! There are no images here!"
40+
config.recordLocation = false
41+
42+
let imagePickerController = ImagePickerController()
43+
imagePickerController.delegate = self
44+
imagePickerController.configuration = config
45+
imagePickerController.imageLimit = 1
46+
present(imagePickerController, animated: true, completion: nil)
47+
}
3348

3449
@IBAction func createBtnTapped(_ sender: Any) {
3550

3651
let teamName = self.nameTf.text
3752

3853
let isPublic = true
3954

55+
var base64String = ""
56+
57+
if (self.selectedImage != nil) {
58+
let imageData:Data = UIImagePNGRepresentation(self.selectedImage!)!
59+
base64String = String.init(format: "%@%@", "data:image/jpeg;base64,", imageData.base64EncodedString())
60+
}
61+
62+
4063
DataHandler.def.createTeam(createTeam: [
4164
"name": teamName,
42-
"isPublic": isPublic
65+
"isPublic": isPublic,
66+
"image": base64String
4367
], successHandler: { response in
4468
self.dismiss(animated: true, completion: nil)
4569
}, failHandler: { err in
46-
print(err)
70+
print(err.message)
4771
})
4872
}
73+
74+
75+
func cancelButtonDidPress(_ imagePicker: ImagePickerController) {
76+
imagePicker.dismiss(animated: true, completion: nil)
77+
}
78+
79+
func wrapperDidPress(_ imagePicker: ImagePickerController, images: [UIImage]) {
80+
//guard images.count > 0 else { return }
81+
}
82+
83+
func doneButtonDidPress(_ imagePicker: ImagePickerController, images: [UIImage]) {
84+
imagePicker.dismiss(animated: true, completion: nil)
85+
86+
if (images.count > 0) {
87+
self.selectedImage = images[0]
88+
}
89+
90+
}
4991

5092
}

CoachPlus/app/team/NewTeam.storyboard

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,21 @@
8989
</textField>
9090
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="phO-Zg-1wv">
9191
<rect key="frame" x="45" y="15" width="285" height="128"/>
92+
<subviews>
93+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="XZW-Fx-Rnt">
94+
<rect key="frame" x="98" y="49" width="89" height="30"/>
95+
<state key="normal" title="Select image">
96+
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
97+
</state>
98+
<connections>
99+
<action selector="selectImageTapped:" destination="nSL-MB-k88" eventType="touchUpInside" id="J2n-ZT-faY"/>
100+
</connections>
101+
</button>
102+
</subviews>
92103
<color key="backgroundColor" red="0.20392156859999999" green="0.50588235290000005" blue="0.72156862749999995" alpha="1" colorSpace="calibratedRGB"/>
93104
<constraints>
105+
<constraint firstItem="XZW-Fx-Rnt" firstAttribute="centerX" secondItem="phO-Zg-1wv" secondAttribute="centerX" id="669-M8-J1N"/>
106+
<constraint firstItem="XZW-Fx-Rnt" firstAttribute="centerY" secondItem="phO-Zg-1wv" secondAttribute="centerY" id="9GI-uy-JSB"/>
94107
<constraint firstAttribute="height" constant="128" id="Gh7-cG-vAK"/>
95108
</constraints>
96109
</view>

CoachPlus/helperclasses/UIImageViewExtension.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,12 @@ extension UIImageView {
3737

3838
let placeholder = UIImage.fontAwesomeIcon(name: .users, textColor: color, size: self.frame.size)
3939

40-
if team != nil && team?.image != nil,
41-
let url = URL(string: team!.image!) {
42-
self.af_setImage(withURL: url, placeholderImage: placeholder)
40+
if (team != nil && team?.image != nil) {
41+
let fullUrl = String.init(format: "%@%@", "https://dev.coach.plus/uploads/", team!.image!)
42+
print(fullUrl)
43+
if let url = URL(string: fullUrl) {
44+
self.af_setImage(withURL: url, placeholderImage: placeholder)
45+
}
4346
} else {
4447
self.image = placeholder
4548
}

CoachPlus/models/Team.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ class Team:JSONable, BackJSONable {
2323
var name: String
2424
var image: String?
2525

26-
init(id:String, isPublic:Bool, name:String) {
26+
init(id:String, isPublic:Bool, name:String, image:String) {
2727
self.id = id
2828
self.isPublic = isPublic
2929
self.name = name
30+
self.image = image
3031
}
3132

3233
required init(json:JSON) {

Podfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def all_pods
1919
pod 'AlamofireImage', '~> 3.1'
2020
pod 'SlideMenuControllerSwift'
2121
pod 'DZNEmptyDataSet'
22+
pod 'ImagePicker'
2223
end
2324

2425
target 'CoachPlus' do

Podfile.lock

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ PODS:
66
- DZNEmptyDataSet (1.8.1)
77
- FontAwesome.swift (1.1.1)
88
- Hero (0.3.6)
9+
- ImagePicker (2.1.1)
910
- IQKeyboardManagerSwift (4.0.6)
1011
- JSONWebToken (2.0.2):
1112
- CryptoSwift (~> 0.6.1)
@@ -25,6 +26,7 @@ DEPENDENCIES:
2526
- DZNEmptyDataSet
2627
- FontAwesome.swift
2728
- Hero
29+
- ImagePicker
2830
- IQKeyboardManagerSwift (= 4.0.6)
2931
- JSONWebToken
3032
- Locksmith
@@ -44,6 +46,7 @@ SPEC CHECKSUMS:
4446
DZNEmptyDataSet: 9525833b9e68ac21c30253e1d3d7076cc828eaa7
4547
FontAwesome.swift: f4ff5a9199dc3b510eba5bb377e834f159aef358
4648
Hero: d3c6f4dd80cdcdbb339be64e57ae3b5c3ab9938c
49+
ImagePicker: fe4c699abb56ff03994fa98d8b02e3883ee118be
4750
IQKeyboardManagerSwift: b3015e819559ca76381f87a0833f44d178564603
4851
JSONWebToken: ca86f02eeb3d1f58ba5197ec2cd53c7de915ecc1
4952
Locksmith: 310b4cc5031af5728bf4db5d4de547a5100c6a3b
@@ -56,6 +59,6 @@ SPEC CHECKSUMS:
5659
SwiftyJSON: c2842d878f95482ffceec5709abc3d05680c0220
5760
SwiftyUserDefaults: 0f1d45fc3aafb9064dac661e367f8f83fe21a4b4
5861

59-
PODFILE CHECKSUM: 2f23ad08f33e2cbbba4132416a3b324b2f86c9c1
62+
PODFILE CHECKSUM: 64b782938924c67aa3d7e1e45188a0a6a61ecde3
6063

6164
COCOAPODS: 1.2.1
818 Bytes
Loading
818 Bytes
Loading
991 Bytes
Loading

0 commit comments

Comments
 (0)