Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 1.76 KB | None | 0 0
  1.     func giftMessage(with giftModel: PTChatGiftNotificationModel) -> String {
  2.         switch giftModel.sender {
  3.  
  4.         case .me:
  5.  
  6.             switch giftModel.receiver {
  7.  
  8.             //I to myself
  9.             case .me:
  10.                 return String(format: NSLocalizedString("You sent a %@ to yourself!", comment: "You sent a %@ to yourself!"),
  11.                               giftModel.giftDesciption)
  12.             //I to somebody
  13.             case let .person(_, receiverName):
  14.                 return String(format: NSLocalizedString("You sent a %@ to %@!", comment: "You sent a %@ to %@!"),
  15.                               giftModel.giftDesciption, receiverName)
  16.             // I to room
  17.             case .room:
  18.                 return String(format: NSLocalizedString("You sent a %@ to room!", comment: "You sent a %@ to room!"),
  19.                               giftModel.giftDesciption)
  20.             }
  21.  
  22.         case let .person(_, senderName):
  23.  
  24.             switch giftModel.receiver {
  25.  
  26.             //Somebody to me
  27.             case .me:
  28.                 return String(format: NSLocalizedString("%@ sent a %@ to you!", comment: "%@ sent a %@ to you!"),
  29.                               senderName, giftModel.giftDesciption)
  30.             //Somebody to somebody
  31.             case let .person(_, receiverName):
  32.                 return String(format: NSLocalizedString("%@ sent a %@ to %@!", comment: "You sent a %@ to %@!"),
  33.                               senderName, giftModel.giftDesciption, receiverName)
  34.             //Somebody to room
  35.             case .room:
  36.                 return String(format: NSLocalizedString("%@ sent a %@ to room!", comment: "You sent a %@ to room!"),
  37.                               senderName, giftModel.giftDesciption)
  38.             }
  39.         }
  40.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement