Pārlūkot izejas kodu

Added Utils/Constants.Colors + Changed bubble color for hero-sender

Bastian van de Wetering 7 gadi atpakaļ
vecāks
revīzija
49130a3556

+ 8 - 0
deltachat-ios.xcodeproj/project.pbxproj

@@ -65,6 +65,8 @@
 		AEACE2DD1FB323CA00DCDD78 /* ChatViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEACE2DC1FB323CA00DCDD78 /* ChatViewController.swift */; };
 		AEACE2DF1FB3246400DCDD78 /* Message.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEACE2DE1FB3246400DCDD78 /* Message.swift */; };
 		AEACE2E11FB3271700DCDD78 /* SampleData.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEACE2E01FB3271700DCDD78 /* SampleData.swift */; };
+		AEACE2E31FB32B5C00DCDD78 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEACE2E21FB32B5C00DCDD78 /* Constants.swift */; };
+		AEACE2E51FB32E1900DCDD78 /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEACE2E41FB32E1900DCDD78 /* Utils.swift */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXContainerItemProxy section */
@@ -206,6 +208,8 @@
 		AEACE2DC1FB323CA00DCDD78 /* ChatViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatViewController.swift; sourceTree = "<group>"; };
 		AEACE2DE1FB3246400DCDD78 /* Message.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Message.swift; sourceTree = "<group>"; };
 		AEACE2E01FB3271700DCDD78 /* SampleData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SampleData.swift; sourceTree = "<group>"; };
+		AEACE2E21FB32B5C00DCDD78 /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
+		AEACE2E41FB32E1900DCDD78 /* Utils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Utils.swift; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -344,6 +348,8 @@
 				AE0D26FC1FB1FE88002FAFCE /* ChatListController.swift */,
 				AEACE2DC1FB323CA00DCDD78 /* ChatViewController.swift */,
 				AEACE2E01FB3271700DCDD78 /* SampleData.swift */,
+				AEACE2E21FB32B5C00DCDD78 /* Constants.swift */,
+				AEACE2E41FB32E1900DCDD78 /* Utils.swift */,
 			);
 			path = "deltachat-ios";
 			sourceTree = "<group>";
@@ -641,6 +647,7 @@
 				7A7923761FB0A2C800BC2DE5 /* writer.c in Sources */,
 				7A9FB5571FB08557001FEA36 /* stress.c in Sources */,
 				7A9FB53F1FB08557001FEA36 /* mrimap.c in Sources */,
+				AEACE2E51FB32E1900DCDD78 /* Utils.swift in Sources */,
 				7A79236F1FB0A2C800BC2DE5 /* openssl_crypto.c in Sources */,
 				7A9FB5391FB08557001FEA36 /* mrapeerstate.c in Sources */,
 				7A9FB5531FB08557001FEA36 /* mrsmtp.c in Sources */,
@@ -654,6 +661,7 @@
 				7A9FB53C1FB08557001FEA36 /* mrcmdline.c in Sources */,
 				7A79236A1FB0A2C800BC2DE5 /* compress.c in Sources */,
 				7A451DB01FB1F84900177250 /* AppCoordinator.swift in Sources */,
+				AEACE2E31FB32B5C00DCDD78 /* Constants.swift in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

+ 2 - 2
deltachat-ios/ChatViewController.swift

@@ -221,11 +221,11 @@ extension ChatViewController: MessagesDataSource {
 extension ChatViewController: MessagesDisplayDelegate, TextMessageDisplayDelegate {
     
     func backgroundColor(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> UIColor {
-        return isFromCurrentSender(message: message) ? UIColor(red: 69/255, green: 193/255, blue: 89/255, alpha: 1) : UIColor(red: 230/255, green: 230/255, blue: 230/255, alpha: 1)
+        return isFromCurrentSender(message: message) ? Constants.Color.bubble : UIColor(red: 230/255, green: 230/255, blue: 230/255, alpha: 1)
     }
     
     func textColor(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> UIColor {
-        return isFromCurrentSender(message: message) ? .white : .darkText
+        return .darkText
     }
     
     func messageStyle(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> MessageStyle {

+ 18 - 0
deltachat-ios/Constants.swift

@@ -0,0 +1,18 @@
+//
+//  Constants.swift
+//  deltachat-ios
+//
+//  Created by Bastian van de Wetering on 08.11.17.
+//  Copyright © 2017 Jonas Reinsch. All rights reserved.
+//
+
+import UIKit
+
+struct Constants {
+    
+    struct Color {
+        static let bubble = UIColor(netHex: 0xefffde)
+        
+    }
+    
+}

+ 38 - 0
deltachat-ios/Utils.swift

@@ -0,0 +1,38 @@
+//
+//  Utils.swift
+//  deltachat-ios
+//
+//  Created by Bastian van de Wetering on 08.11.17.
+//  Copyright © 2017 Jonas Reinsch. All rights reserved.
+//
+
+import Foundation
+import UIKit
+
+class Utils {
+    
+ 
+    
+    
+    
+}
+
+
+extension UIColor {
+    convenience init(alpha: Int, red: Int, green: Int, blue: Int) {
+        assert(red >= 0 && red <= 255, "Invalid red component")
+        assert(green >= 0 && green <= 255, "Invalid green component")
+        assert(blue >= 0 && blue <= 255, "Invalid blue component")
+        
+        self.init(red: CGFloat(red) / 255, green: CGFloat(green) / 255, blue: CGFloat(blue) / 255, alpha: CGFloat(alpha) / 255)
+    }
+    
+    convenience init(netHex: Int) {
+        var alpha = (netHex >> 24) & 0xff
+        if alpha == 0 {
+            alpha = 255
+        }
+        
+        self.init(alpha: alpha, red:(netHex >> 16) & 0xff, green:(netHex >> 8) & 0xff, blue:netHex & 0xff)
+    }
+}