From 7964d314c843c9bca9f843d33c69e34d1a62be30 Mon Sep 17 00:00:00 2001 From: aringenbach <80891108+aringenbach@users.noreply.github.com> Date: Thu, 10 Feb 2022 17:13:23 +0100 Subject: [PATCH] Add objective C support to SwiftGen assets helpers (#5533) * Add objective C support to SwiftGen assets helpers * Use dot notation in ObjC & fix minor issues Co-authored-by: Arnaud Ringenbach --- .../MXKRoomBubbleTableViewCell+Riot.m | 8 +- Riot/Categories/UIViewController+RiotSearch.m | 2 +- Riot/Generated/Images.swift | 17 +- .../AuthenticationViewController.m | 10 +- .../Authentication/Views/AuthInputsView.m | 2 +- .../BugReport/BugReportViewController.m | 8 +- Riot/Modules/Call/CallViewController.m | 24 +- Riot/Modules/Call/Views/IncomingCallView.m | 4 +- .../Recents/DataSources/RecentsDataSource.m | 4 +- .../Common/Recents/RecentsViewController.m | 14 +- .../Members/GroupParticipantsViewController.m | 4 +- .../Contacts/DataSources/ContactsDataSource.m | 6 +- .../Details/ContactDetailsViewController.m | 2 +- .../Favorites/FavouritesViewController.m | 4 +- .../Files/CellData/FilesSearchCellData.m | 8 +- .../Files/Views/FilesSearchTableViewCell.m | 10 +- .../UnifiedSearchViewController.m | 2 +- .../Views/RoomIdOrAliasTableViewCell.m | 2 +- Riot/Modules/Home/HomeViewController.m | 20 +- .../Widgets/WidgetViewController.m | 2 +- .../Library/MediaAlbumContentViewController.m | 4 +- .../MediaPicker/MediaPickerViewController.m | 16 +- Riot/Modules/People/PeopleViewController.m | 6 +- .../Detail/RoomMemberDetailsViewController.m | 4 +- .../Members/RoomParticipantsViewController.m | 4 +- Riot/Modules/Room/RoomViewController.m | 34 +- .../Settings/RoomSettingsViewController.m | 12 +- .../Views/TableViewCellWithCheckBoxAndLabel.m | 4 +- .../Views/TableViewCellWithCheckBoxes.m | 8 +- .../Views/Activities/RoomActivitiesView.m | 8 +- .../Encryption/RoomEncryptedDataBubbleCell.m | 3 +- .../Views/InputToolbar/RoomInputToolbarView.m | 18 +- .../Title/Preview/PreviewRoomTitleView.m | 2 +- .../Views/DirectoryServerTableViewCell.m | 2 +- Riot/Modules/Rooms/RoomsViewController.m | 6 +- .../ManageSessionViewController.m | 4 +- .../Security/SecurityViewController.m | 8 +- .../Modules/Settings/SettingsViewController.m | 8 +- .../StartChat/StartChatViewController.m | 2 +- .../UserDevices/Views/DeviceTableViewCell.m | 6 +- Riot/Utils/EventFormatter.m | 2 +- .../Shared/View/RecentRoomTableViewCell.m | 4 +- RiotShareExtension/target.yml | 1 + .../Templates/Assets/swift4-element.stencil | 337 ++++++++++++++++++ Tools/SwiftGen/swiftgen-config.yml | 2 +- changelog.d/pr-5533.misc | 1 + 46 files changed, 504 insertions(+), 155 deletions(-) create mode 100644 Tools/SwiftGen/Templates/Assets/swift4-element.stencil create mode 100644 changelog.d/pr-5533.misc diff --git a/Riot/Categories/MXKRoomBubbleTableViewCell+Riot.m b/Riot/Categories/MXKRoomBubbleTableViewCell+Riot.m index 98fde6a11..0d8f4ac0a 100644 --- a/Riot/Categories/MXKRoomBubbleTableViewCell+Riot.m +++ b/Riot/Categories/MXKRoomBubbleTableViewCell+Riot.m @@ -697,7 +697,7 @@ NSString *const kMXKRoomBubbleCellKeyVerificationIncomingRequestDeclinePressed = if ([bubbleData isKindOfClass:RoomBubbleCellData.class] && ((RoomBubbleCellData*)bubbleData).componentIndexOfSentMessageTick >= 0) { - UIImage *image = [UIImage imageNamed:@"sent_message_tick"]; + UIImage *image = AssetImages.sentMessageTick.image; image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; tickView = [[UIImageView alloc] initWithImage:image]; tickView.tintColor = ThemeService.shared.theme.textTertiaryColor; @@ -733,7 +733,7 @@ NSString *const kMXKRoomBubbleCellKeyVerificationIncomingRequestDeclinePressed = } else { - UIImage *image = [UIImage imageNamed:@"sending_message_tick"]; + UIImage *image = AssetImages.sendingMessageTick.image; image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; tickView = [[UIImageView alloc] initWithImage:image]; tickView.tintColor = ThemeService.shared.theme.textTertiaryColor; @@ -746,7 +746,7 @@ NSString *const kMXKRoomBubbleCellKeyVerificationIncomingRequestDeclinePressed = if (component.event.sentState == MXEventSentStateFailed) { - tickView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"error_message_tick"]]; + tickView = [[UIImageView alloc] initWithImage:AssetImages.errorMessageTick.image]; [statusViews addObject:tickView]; [self addTickView:tickView atIndex:index]; } @@ -815,7 +815,7 @@ NSString *const kMXKRoomBubbleCellKeyVerificationIncomingRequestDeclinePressed = } // Define 'Edit' button frame - UIImage *editIcon = [UIImage imageNamed:@"edit_icon"]; + UIImage *editIcon = AssetImages.editIcon.image; CGFloat editBtnPosX = self.bubbleInfoContainer.frame.size.width - RoomBubbleCellLayout.timestampLabelWidth - 22 - editIcon.size.width / 2; CGFloat editBtnPosY = isFirstDisplayedComponent ? -13 : component.position.y + self.msgTextViewTopConstraint.constant - self.bubbleInfoContainerTopConstraint.constant - 13; UIButton *editButton = [[UIButton alloc] initWithFrame:CGRectMake(editBtnPosX, editBtnPosY, 44, 44)]; diff --git a/Riot/Categories/UIViewController+RiotSearch.m b/Riot/Categories/UIViewController+RiotSearch.m index 09b7896b3..eef17866e 100644 --- a/Riot/Categories/UIViewController+RiotSearch.m +++ b/Riot/Categories/UIViewController+RiotSearch.m @@ -136,7 +136,7 @@ - (void)addBackgroundImageViewToView:(UIView*)view { - UIImage *searchBgImage = [MXKTools paintImage:[UIImage imageNamed:@"search_bg"] withColor:ThemeService.shared.theme.matrixSearchBackgroundImageTintColor]; + UIImage *searchBgImage = [MXKTools paintImage:AssetImages.searchBg.image withColor:ThemeService.shared.theme.matrixSearchBackgroundImageTintColor]; UIImageView *backgroundImageView = [[UIImageView alloc] initWithImage:searchBgImage]; backgroundImageView.translatesAutoresizingMaskIntoConstraints = NO; diff --git a/Riot/Generated/Images.swift b/Riot/Generated/Images.swift index cec8486d5..26cb7157e 100644 --- a/Riot/Generated/Images.swift +++ b/Riot/Generated/Images.swift @@ -18,8 +18,10 @@ internal typealias AssetImageTypeAlias = ImageAsset.Image // MARK: - Asset Catalogs // swiftlint:disable identifier_name line_length nesting type_body_length type_name -internal enum Asset { - internal enum Images { +@objcMembers +internal class Asset: NSObject { + @objcMembers + @objc(AssetImages) internal class Images: NSObject { internal static let analyticsCheckmark = ImageAsset(name: "AnalyticsCheckmark") internal static let analyticsLogo = ImageAsset(name: "AnalyticsLogo") internal static let socialLoginButtonApple = ImageAsset(name: "social_login_button_apple") @@ -244,7 +246,8 @@ internal enum Asset { internal static let tabRooms = ImageAsset(name: "tab_rooms") internal static let launchScreenLogo = ImageAsset(name: "launch_screen_logo") } - internal enum SharedImages { + @objcMembers + @objc(AssetSharedImages) internal class SharedImages: NSObject { internal static let cancel = ImageAsset(name: "cancel") internal static let e2eVerified = ImageAsset(name: "e2e_verified") internal static let horizontalLogo = ImageAsset(name: "horizontal_logo") @@ -256,7 +259,8 @@ internal enum Asset { // MARK: - Implementation Details -internal struct ImageAsset { +@objcMembers +internal class ImageAsset: NSObject { internal fileprivate(set) var name: String #if os(macOS) @@ -282,6 +286,10 @@ internal struct ImageAsset { return result } + internal init(name: String) { + self.name = name + } + #if os(iOS) || os(tvOS) @available(iOS 8.0, tvOS 9.0, *) internal func image(compatibleWith traitCollection: UITraitCollection) -> Image { @@ -321,3 +329,4 @@ private final class BundleToken { }() } // swiftlint:enable convenience_type + diff --git a/Riot/Modules/Authentication/AuthenticationViewController.m b/Riot/Modules/Authentication/AuthenticationViewController.m index 0ff35511e..776e23373 100644 --- a/Riot/Modules/Authentication/AuthenticationViewController.m +++ b/Riot/Modules/Authentication/AuthenticationViewController.m @@ -136,7 +136,7 @@ static const CGFloat kAuthInputContainerViewMinHeightConstraintConstant = 150.0; self.defaultIdentityServerUrl = RiotSettings.shared.identityServerUrlString; - self.welcomeImageView.image = [UIImage imageNamed:@"horizontal_logo"]; + self.welcomeImageView.image = AssetSharedImages.horizontalLogo.image; [self.submitButton.layer setCornerRadius:5]; self.submitButton.clipsToBounds = YES; @@ -150,8 +150,8 @@ static const CGFloat kAuthInputContainerViewMinHeightConstraintConstant = 150.0; [self.skipButton setTitle:[VectorL10n authSkip] forState:UIControlStateHighlighted]; self.skipButton.enabled = YES; - [self.customServersTickButton setImage:[UIImage imageNamed:@"selection_untick"] forState:UIControlStateNormal]; - [self.customServersTickButton setImage:[UIImage imageNamed:@"selection_untick"] forState:UIControlStateHighlighted]; + [self.customServersTickButton setImage:AssetImages.selectionUntick.image forState:UIControlStateNormal]; + [self.customServersTickButton setImage:AssetImages.selectionUntick.image forState:UIControlStateHighlighted]; if (!BuildSettings.authScreenShowRegister) { @@ -1273,7 +1273,7 @@ static const CGFloat kAuthInputContainerViewMinHeightConstraintConstant = 150.0; [self setHomeServerTextFieldText:self.defaultHomeServerUrl]; [self setIdentityServerTextFieldText:self.defaultIdentityServerUrl]; - [self.customServersTickButton setImage:[UIImage imageNamed:@"selection_untick"] forState:UIControlStateNormal]; + [self.customServersTickButton setImage:AssetImages.selectionUntick.image forState:UIControlStateNormal]; self.customServersContainer.hidden = YES; // Refresh content view height @@ -1297,7 +1297,7 @@ static const CGFloat kAuthInputContainerViewMinHeightConstraintConstant = 150.0; [self setIdentityServerTextFieldText:customIdentityServerURL]; } - [self.customServersTickButton setImage:[UIImage imageNamed:@"selection_tick"] forState:UIControlStateNormal]; + [self.customServersTickButton setImage:AssetImages.selectionTick.image forState:UIControlStateNormal]; self.customServersContainer.hidden = NO; // Refresh content view height diff --git a/Riot/Modules/Authentication/Views/AuthInputsView.m b/Riot/Modules/Authentication/Views/AuthInputsView.m index b4eaad74a..ea0bc4741 100644 --- a/Riot/Modules/Authentication/Views/AuthInputsView.m +++ b/Riot/Modules/Authentication/Views/AuthInputsView.m @@ -1322,7 +1322,7 @@ [phoneNumberPickerNavigationController pushViewController:phoneNumberCountryPicker animated:NO]; - UIBarButtonItem *leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back_icon"] style:UIBarButtonItemStylePlain target:self action:@selector(dismissCountryPicker)]; + UIBarButtonItem *leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:AssetImages.backIcon.image style:UIBarButtonItemStylePlain target:self action:@selector(dismissCountryPicker)]; phoneNumberCountryPicker.navigationItem.leftBarButtonItem = leftBarButtonItem; [self.delegate authInputsView:self presentViewController:phoneNumberPickerNavigationController animated:YES]; diff --git a/Riot/Modules/BugReport/BugReportViewController.m b/Riot/Modules/BugReport/BugReportViewController.m index e43ec06d7..3dd714654 100644 --- a/Riot/Modules/BugReport/BugReportViewController.m +++ b/Riot/Modules/BugReport/BugReportViewController.m @@ -222,11 +222,11 @@ _sendLogs = sendLogs; if (_sendLogs) { - _sendLogsButtonImage.image = [UIImage imageNamed:@"selection_tick"]; + _sendLogsButtonImage.image = AssetImages.selectionTick.image; } else { - _sendLogsButtonImage.image = [UIImage imageNamed:@"selection_untick"]; + _sendLogsButtonImage.image = AssetImages.selectionUntick.image; } } @@ -235,11 +235,11 @@ _sendScreenshot = sendScreenshot; if (_sendScreenshot) { - _sendScreenshotButtonImage.image = [UIImage imageNamed:@"selection_tick"]; + _sendScreenshotButtonImage.image = AssetImages.selectionTick.image; } else { - _sendScreenshotButtonImage.image = [UIImage imageNamed:@"selection_untick"]; + _sendScreenshotButtonImage.image = AssetImages.selectionUntick.image; } } diff --git a/Riot/Modules/Call/CallViewController.m b/Riot/Modules/Call/CallViewController.m index 8f9eab5a1..d4ff8d4d5 100644 --- a/Riot/Modules/Call/CallViewController.m +++ b/Riot/Modules/Call/CallViewController.m @@ -73,20 +73,20 @@ CallAudioRouteMenuViewDelegate> // Back button - UIImage *backButtonImage = [UIImage imageNamed:@"back_icon"]; + UIImage *backButtonImage = AssetImages.backIcon.image; [self.backToAppButton setImage:backButtonImage forState:UIControlStateNormal]; [self.backToAppButton setImage:backButtonImage forState:UIControlStateHighlighted]; // Camera switch - UIImage *cameraSwitchButtonImage = [UIImage imageNamed:@"camera_switch"]; + UIImage *cameraSwitchButtonImage = AssetImages.cameraSwitch.image; [self.cameraSwitchButton setImage:cameraSwitchButtonImage forState:UIControlStateNormal]; [self.cameraSwitchButton setImage:cameraSwitchButtonImage forState:UIControlStateHighlighted]; // Audio mute - UIImage *audioMuteOffButtonImage = [UIImage imageNamed:@"call_audio_mute_off_icon"]; - UIImage *audioMuteOnButtonImage = [UIImage imageNamed:@"call_audio_mute_on_icon"]; + UIImage *audioMuteOffButtonImage = AssetImages.callAudioMuteOffIcon.image; + UIImage *audioMuteOnButtonImage = AssetImages.callAudioMuteOnIcon.image; [self.audioMuteButton setImage:audioMuteOffButtonImage forState:UIControlStateNormal]; [self.audioMuteButton setImage:audioMuteOffButtonImage forState:UIControlStateHighlighted]; @@ -94,8 +94,8 @@ CallAudioRouteMenuViewDelegate> // Video mute - UIImage *videoOffButtonImage = [UIImage imageNamed:@"call_video_mute_off_icon"]; - UIImage *videoOnButtonImage = [UIImage imageNamed:@"call_video_mute_on_icon"]; + UIImage *videoOffButtonImage = AssetImages.callVideoMuteOffIcon.image; + UIImage *videoOnButtonImage = AssetImages.callVideoMuteOnIcon.image; [self.videoMuteButton setImage:videoOffButtonImage forState:UIControlStateNormal]; [self.videoMuteButton setImage:videoOffButtonImage forState:UIControlStateHighlighted]; @@ -103,14 +103,14 @@ CallAudioRouteMenuViewDelegate> // More - UIImage *moreButtonImage = [UIImage imageNamed:@"call_more_icon"]; + UIImage *moreButtonImage = AssetImages.callMoreIcon.image; [self.moreButtonForVoice setImage:moreButtonImage forState:UIControlStateNormal]; [self.moreButtonForVideo setImage:moreButtonImage forState:UIControlStateNormal]; // Hang up - UIImage *hangUpButtonImage = [UIImage imageNamed:@"call_hangup_large"]; + UIImage *hangUpButtonImage = AssetImages.callHangupLarge.image; [self.endCallButton setTitle:nil forState:UIControlStateNormal]; [self.endCallButton setTitle:nil forState:UIControlStateHighlighted]; @@ -269,17 +269,17 @@ CallAudioRouteMenuViewDelegate> switch (self.mxCall.audioOutputRouter.currentRoute.routeType) { case MXiOSAudioOutputRouteTypeBuiltIn: - [self.speakerButton setImage:[UIImage imageNamed:@"call_speaker_off_icon"] + [self.speakerButton setImage:AssetImages.callSpeakerOffIcon.image forState:UIControlStateNormal]; break; case MXiOSAudioOutputRouteTypeLoudSpeakers: - [self.speakerButton setImage:[UIImage imageNamed:@"call_speaker_on_icon"] + [self.speakerButton setImage:AssetImages.callSpeakerOnIcon.image forState:UIControlStateNormal]; break; case MXiOSAudioOutputRouteTypeExternalWired: case MXiOSAudioOutputRouteTypeExternalBluetooth: case MXiOSAudioOutputRouteTypeExternalCar: - [self.speakerButton setImage:[UIImage imageNamed:@"call_speaker_external_icon"] + [self.speakerButton setImage:AssetImages.callSpeakerExternalIcon.image forState:UIControlStateNormal]; break; } @@ -484,7 +484,7 @@ CallAudioRouteMenuViewDelegate> andFontSize:fontSize]; } - return [MXKTools paintImage:[UIImage imageNamed:@"placeholder"] + return [MXKTools paintImage:AssetImages.placeholder.image withColor:self.overriddenTheme.tintColor]; } diff --git a/Riot/Modules/Call/Views/IncomingCallView.m b/Riot/Modules/Call/Views/IncomingCallView.m index 35500cf4e..b58145546 100644 --- a/Riot/Modules/Call/Views/IncomingCallView.m +++ b/Riot/Modules/Call/Views/IncomingCallView.m @@ -89,7 +89,7 @@ static const CGFloat kButtonSize = 80.0; UIColor *answerButtonBorderColor = ThemeService.shared.theme.tintColor; - self.answerButton = [[CircleButton alloc] initWithImage:[UIImage imageNamed:@"voice_call_hangon_icon"] + self.answerButton = [[CircleButton alloc] initWithImage:AssetImages.voiceCallHangonIcon.image borderColor:answerButtonBorderColor]; self.answerButton.defaultBackgroundColor = ThemeService.shared.theme.backgroundColor; self.answerButton.tintColor = answerButtonBorderColor; @@ -103,7 +103,7 @@ static const CGFloat kButtonSize = 80.0; UIColor *rejectButtonBorderColor = ThemeService.shared.theme.warningColor; - self.rejectButton = [[CircleButton alloc] initWithImage:[UIImage imageNamed:@"voice_call_hangup_icon"] + self.rejectButton = [[CircleButton alloc] initWithImage:AssetImages.voiceCallHangupIcon.image borderColor:rejectButtonBorderColor]; self.rejectButton.defaultBackgroundColor = ThemeService.shared.theme.backgroundColor; self.rejectButton.tintColor = rejectButtonBorderColor; diff --git a/Riot/Modules/Common/Recents/DataSources/RecentsDataSource.m b/Riot/Modules/Common/Recents/DataSources/RecentsDataSource.m index 2e16761eb..faaa6554b 100644 --- a/Riot/Modules/Common/Recents/DataSources/RecentsDataSource.m +++ b/Riot/Modules/Common/Recents/DataSources/RecentsDataSource.m @@ -821,11 +821,11 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou UIImage *chevron; if (shrinkedSectionsBitMask & sectionBitwise) { - chevron = [UIImage imageNamed:@"disclosure_icon"]; + chevron = AssetImages.disclosureIcon.image; } else { - chevron = [UIImage imageNamed:@"shrink_icon"]; + chevron = AssetImages.shrinkIcon.image; } UIImageView *chevronView = [[UIImageView alloc] initWithImage:chevron]; chevronView.tintColor = ThemeService.shared.theme.textSecondaryColor; diff --git a/Riot/Modules/Common/Recents/RecentsViewController.m b/Riot/Modules/Common/Recents/RecentsViewController.m index 852a336a2..41b8c20ae 100644 --- a/Riot/Modules/Common/Recents/RecentsViewController.m +++ b/Riot/Modules/Common/Recents/RecentsViewController.m @@ -1109,7 +1109,7 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro }]; directChatAction.backgroundColor = actionBackgroundColor; - UIImage *directChatImage = [UIImage imageNamed:@"room_action_direct_chat"]; + UIImage *directChatImage = AssetImages.roomActionDirectChat.image; directChatImage = [directChatImage vc_tintedImageUsingColor:isDirect ? selectedColor : unselectedColor]; directChatAction.image = [directChatImage vc_notRenderedImage]; @@ -1136,13 +1136,13 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro muteAction.backgroundColor = actionBackgroundColor; UIImage *notificationImage; - if([BuildSettings showNotificationsV2]) + if([BuildSettings showNotificationsV2] && isMuted) { - notificationImage = isMuted ? [UIImage imageNamed:@"room_action_notification_muted"] : [UIImage imageNamed:@"room_action_notification"]; + notificationImage = AssetImages.roomActionNotificationMuted.image; } else { - notificationImage = [UIImage imageNamed:@"room_action_notification"]; + notificationImage = AssetImages.roomActionNotification.image; } notificationImage = [notificationImage vc_tintedImageUsingColor:isMuted ? unselectedColor : selectedColor]; @@ -1173,7 +1173,7 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro }]; favouriteAction.backgroundColor = actionBackgroundColor; - UIImage *favouriteImage = [UIImage imageNamed:@"room_action_favourite"]; + UIImage *favouriteImage = AssetImages.roomActionFavourite.image; favouriteImage = [favouriteImage vc_tintedImageUsingColor:isFavourite ? selectedColor : unselectedColor]; favouriteAction.image = [favouriteImage vc_notRenderedImage]; @@ -1190,7 +1190,7 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro }]; priorityAction.backgroundColor = actionBackgroundColor; - UIImage *priorityImage = isInLowPriority ? [UIImage imageNamed:@"room_action_priority_high"] : [UIImage imageNamed:@"room_action_priority_low"]; + UIImage *priorityImage = isInLowPriority ? AssetImages.roomActionPriorityHigh.image : AssetImages.roomActionPriorityLow.image; priorityImage = [priorityImage vc_tintedImageUsingColor:unselectedColor]; priorityAction.image = [priorityImage vc_notRenderedImage]; @@ -1204,7 +1204,7 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro }]; leaveAction.backgroundColor = actionBackgroundColor; - UIImage *leaveImage = [UIImage imageNamed:@"room_action_leave"]; + UIImage *leaveImage = AssetImages.roomActionLeave.image; leaveImage = [leaveImage vc_tintedImageUsingColor:unselectedColor]; leaveAction.image = [leaveImage vc_notRenderedImage]; diff --git a/Riot/Modules/Communities/Members/GroupParticipantsViewController.m b/Riot/Modules/Communities/Members/GroupParticipantsViewController.m index c78907883..26cf2b02d 100644 --- a/Riot/Modules/Communities/Members/GroupParticipantsViewController.m +++ b/Riot/Modules/Communities/Members/GroupParticipantsViewController.m @@ -475,7 +475,7 @@ addParticipantButtonImageView.backgroundColor = [UIColor clearColor]; addParticipantButtonImageView.contentMode = UIViewContentModeCenter; - addParticipantButtonImageView.image = [UIImage imageNamed:@"add_group_participant"]; + addParticipantButtonImageView.image = AssetImages.addGroupParticipant.image; CGFloat side = 78.0f; NSLayoutConstraint* widthConstraint = [NSLayoutConstraint constraintWithItem:addParticipantButtonImageView @@ -537,7 +537,7 @@ contactsDataSource.displaySearchInputInContactsList = YES; contactsDataSource.forceMatrixIdInDisplayName = YES; // Add a plus icon to the contact cell in the contacts picker, in order to make it more understandable for the end user. - contactsDataSource.contactCellAccessoryImage = [[UIImage imageNamed:@"plus_icon"] vc_tintedImageUsingColor:ThemeService.shared.theme.textPrimaryColor]; + contactsDataSource.contactCellAccessoryImage = [AssetImages.plusIcon.image vc_tintedImageUsingColor:ThemeService.shared.theme.textPrimaryColor]; // List all the participants matrix user id to ignore them during the contacts search. for (Contact *contact in actualParticipants) diff --git a/Riot/Modules/Contacts/DataSources/ContactsDataSource.m b/Riot/Modules/Contacts/DataSources/ContactsDataSource.m index fd84c8c03..9a2935903 100644 --- a/Riot/Modules/Contacts/DataSources/ContactsDataSource.m +++ b/Riot/Modules/Contacts/DataSources/ContactsDataSource.m @@ -844,11 +844,11 @@ UIImage *chevron; if (shrinkedSectionsBitMask & sectionBitwise) { - chevron = [UIImage imageNamed:@"disclosure_icon"]; + chevron = AssetImages.disclosureIcon.image; } else { - chevron = [UIImage imageNamed:@"shrink_icon"]; + chevron = AssetImages.shrinkIcon.image; } UIImageView *chevronView = [[UIImageView alloc] initWithImage:chevron]; chevronView.tintColor = ThemeService.shared.theme.textSecondaryColor; @@ -892,7 +892,7 @@ checkboxLabel.textColor = ThemeService.shared.theme.textPrimaryColor; // Set the right value of the tick box - localContactsCheckbox.image = hideNonMatrixEnabledContacts ? [UIImage imageNamed:@"selection_tick"] : [UIImage imageNamed:@"selection_untick"]; + localContactsCheckbox.image = hideNonMatrixEnabledContacts ? AssetImages.selectionTick.image : AssetImages.selectionUntick.image; localContactsCheckbox.tintColor = ThemeService.shared.theme.tintColor; // Add the check box container diff --git a/Riot/Modules/Contacts/Details/ContactDetailsViewController.m b/Riot/Modules/Contacts/Details/ContactDetailsViewController.m index 8527ba72c..fe2b2d6e1 100644 --- a/Riot/Modules/Contacts/Details/ContactDetailsViewController.m +++ b/Riot/Modules/Contacts/Details/ContactDetailsViewController.m @@ -733,7 +733,7 @@ } else { - roomCell.avatarImageView.image = [UIImage imageNamed:@"start_chat"]; + roomCell.avatarImageView.image = AssetImages.startChat.image; roomCell.avatarImageView.defaultBackgroundColor = [UIColor clearColor]; roomCell.titleLabel.text = [VectorL10n roomParticipantsActionStartNewChat]; } diff --git a/Riot/Modules/Favorites/FavouritesViewController.m b/Riot/Modules/Favorites/FavouritesViewController.m index 23b43b856..62ef8cd8f 100644 --- a/Riot/Modules/Favorites/FavouritesViewController.m +++ b/Riot/Modules/Favorites/FavouritesViewController.m @@ -155,11 +155,11 @@ { if (ThemeService.shared.isCurrentThemeDark) { - return [UIImage imageNamed:@"favourites_empty_screen_artwork_dark"]; + return AssetImages.favouritesEmptyScreenArtworkDark.image; } else { - return [UIImage imageNamed:@"favourites_empty_screen_artwork"]; + return AssetImages.favouritesEmptyScreenArtwork.image; } } diff --git a/Riot/Modules/GlobalSearch/Files/CellData/FilesSearchCellData.m b/Riot/Modules/GlobalSearch/Files/CellData/FilesSearchCellData.m index 6e509e089..5a183820f 100644 --- a/Riot/Modules/GlobalSearch/Files/CellData/FilesSearchCellData.m +++ b/Riot/Modules/GlobalSearch/Files/CellData/FilesSearchCellData.m @@ -132,19 +132,19 @@ if ([msgtype isEqualToString:kMXMessageTypeImage]) { - return [UIImage imageNamed:@"file_photo_icon"]; + return AssetImages.filePhotoIcon.image; } else if ([msgtype isEqualToString:kMXMessageTypeAudio]) { - return [UIImage imageNamed:@"file_music_icon"]; + return AssetImages.fileMusicIcon.image; } else if ([msgtype isEqualToString:kMXMessageTypeVideo]) { - return [UIImage imageNamed:@"file_video_icon"]; + return AssetImages.fileVideoIcon.image; } else if ([msgtype isEqualToString:kMXMessageTypeFile]) { - return [UIImage imageNamed:@"file_doc_icon"]; + return AssetImages.fileDocIcon.image; } return nil; diff --git a/Riot/Modules/GlobalSearch/Files/Views/FilesSearchTableViewCell.m b/Riot/Modules/GlobalSearch/Files/Views/FilesSearchTableViewCell.m index e2633d41c..287a71a6f 100644 --- a/Riot/Modules/GlobalSearch/Files/Views/FilesSearchTableViewCell.m +++ b/Riot/Modules/GlobalSearch/Files/Views/FilesSearchTableViewCell.m @@ -107,19 +107,19 @@ switch (type) { case MXKAttachmentTypeImage: - image = [UIImage imageNamed:@"file_photo_icon"]; + image = AssetImages.filePhotoIcon.image; break; case MXKAttachmentTypeAudio: - image = [UIImage imageNamed:@"file_music_icon"]; + image = AssetImages.fileMusicIcon.image; break; case MXKAttachmentTypeVoiceMessage: - image = [UIImage imageNamed:@"file_music_icon"]; + image = AssetImages.fileMusicIcon.image; break; case MXKAttachmentTypeVideo: - image = [UIImage imageNamed:@"file_video_icon"]; + image = AssetImages.fileVideoIcon.image; break; case MXKAttachmentTypeFile: - image = [UIImage imageNamed:@"file_doc_icon"]; + image = AssetImages.fileDocIcon.image; break; default: break; diff --git a/Riot/Modules/GlobalSearch/UnifiedSearchViewController.m b/Riot/Modules/GlobalSearch/UnifiedSearchViewController.m index 7c8d816db..78eeaa4b7 100644 --- a/Riot/Modules/GlobalSearch/UnifiedSearchViewController.m +++ b/Riot/Modules/GlobalSearch/UnifiedSearchViewController.m @@ -251,7 +251,7 @@ peopleSearchDataSource.showLocalContacts = NO; peopleSearchDataSource.areSectionsShrinkable = YES; peopleSearchDataSource.displaySearchInputInContactsList = YES; - peopleSearchDataSource.contactCellAccessoryImage = [[UIImage imageNamed: @"disclosure_icon"] vc_tintedImageUsingColor:ThemeService.shared.theme.textSecondaryColor];; + peopleSearchDataSource.contactCellAccessoryImage = [AssetImages.disclosureIcon.image vc_tintedImageUsingColor:ThemeService.shared.theme.textSecondaryColor];; [peopleSearchViewController displayList:peopleSearchDataSource]; // Check whether there are others sessions diff --git a/Riot/Modules/GlobalSearch/Views/RoomIdOrAliasTableViewCell.m b/Riot/Modules/GlobalSearch/Views/RoomIdOrAliasTableViewCell.m index 0a798aefc..820f2ac03 100644 --- a/Riot/Modules/GlobalSearch/Views/RoomIdOrAliasTableViewCell.m +++ b/Riot/Modules/GlobalSearch/Views/RoomIdOrAliasTableViewCell.m @@ -49,7 +49,7 @@ } else { - self.avatarImageView.image = [MXKTools paintImage:[UIImage imageNamed:@"placeholder"] + self.avatarImageView.image = [MXKTools paintImage:AssetImages.placeholder.image withColor:ThemeService.shared.theme.tintColor]; } diff --git a/Riot/Modules/Home/HomeViewController.m b/Riot/Modules/Home/HomeViewController.m index 3a02c310e..e94b4c472 100644 --- a/Riot/Modules/Home/HomeViewController.m +++ b/Riot/Modules/Home/HomeViewController.m @@ -89,7 +89,7 @@ self.recentsTableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; // Add the (+) button programmatically - plusButtonImageView = [self vc_addFABWithImage:[UIImage imageNamed:@"plus_floating_action"] + plusButtonImageView = [self vc_addFABWithImage:AssetImages.plusFloatingAction.image target:self action:@selector(onPlusButtonPressed)]; @@ -416,19 +416,19 @@ // Update the edition menu content (Use the button tag to store the current value). tableViewCell.directChatButton.tag = room.isDirect; [tableViewCell.directChatButton addTarget:self action:@selector(onDirectChatButtonPressed:) forControlEvents:UIControlEventTouchUpInside]; - tableViewCell.directChatImageView.image = [UIImage imageNamed:@"room_action_direct_chat"]; + tableViewCell.directChatImageView.image = AssetImages.roomActionDirectChat.image; tableViewCell.directChatImageView.tintColor = room.isDirect ? selectedColor : unselectedColor; tableViewCell.notificationsButton.tag = room.isMute || room.isMentionsOnly; [tableViewCell.notificationsButton addTarget:self action:@selector(onNotificationsButtonPressed:) forControlEvents:UIControlEventTouchUpInside]; - if ([BuildSettings showNotificationsV2]) + if ([BuildSettings showNotificationsV2] && tableViewCell.notificationsButton.tag) { - tableViewCell.notificationsImageView.image = tableViewCell.notificationsButton.tag ? [UIImage imageNamed:@"room_action_notification_muted"] : [UIImage imageNamed:@"room_action_notification"]; + tableViewCell.notificationsImageView.image = AssetImages.roomActionNotificationMuted.image; } else { - tableViewCell.notificationsImageView.image = [UIImage imageNamed:@"room_action_notification"]; + tableViewCell.notificationsImageView.image = AssetImages.roomActionNotification.image; } tableViewCell.notificationsImageView.tintColor = tableViewCell.notificationsButton.tag ? unselectedColor : selectedColor; @@ -446,16 +446,16 @@ tableViewCell.favouriteButton.tag = (currentTag && [kMXRoomTagFavourite isEqualToString:currentTag.name]); [tableViewCell.favouriteButton addTarget:self action:@selector(onFavouriteButtonPressed:) forControlEvents:UIControlEventTouchUpInside]; - tableViewCell.favouriteImageView.image = [UIImage imageNamed:@"room_action_favourite"]; + tableViewCell.favouriteImageView.image = AssetImages.roomActionFavourite.image; tableViewCell.favouriteImageView.tintColor = tableViewCell.favouriteButton.tag ? selectedColor : unselectedColor; tableViewCell.priorityButton.tag = (currentTag && [kMXRoomTagLowPriority isEqualToString:currentTag.name]); [tableViewCell.priorityButton addTarget:self action:@selector(onPriorityButtonPressed:) forControlEvents:UIControlEventTouchUpInside]; - tableViewCell.priorityImageView.image = tableViewCell.priorityButton.tag ? [UIImage imageNamed:@"room_action_priority_high"] : [UIImage imageNamed:@"room_action_priority_low"]; + tableViewCell.priorityImageView.image = tableViewCell.priorityButton.tag ? AssetImages.roomActionPriorityHigh.image : AssetImages.roomActionPriorityLow.image; tableViewCell.priorityImageView.tintColor = unselectedColor; [tableViewCell.leaveButton addTarget:self action:@selector(onLeaveButtonPressed:) forControlEvents:UIControlEventTouchUpInside]; - tableViewCell.leaveImageView.image = [UIImage imageNamed:@"room_action_leave"]; + tableViewCell.leaveImageView.image = AssetImages.roomActionLeave.image; tableViewCell.leaveImageView.tintColor = unselectedColor; } } @@ -1048,11 +1048,11 @@ { if (ThemeService.shared.isCurrentThemeDark) { - return [UIImage imageNamed:@"home_empty_screen_artwork_dark"]; + return AssetImages.homeEmptyScreenArtworkDark.image; } else { - return [UIImage imageNamed:@"home_empty_screen_artwork"]; + return AssetImages.homeEmptyScreenArtwork.image; } } diff --git a/Riot/Modules/Integrations/Widgets/WidgetViewController.m b/Riot/Modules/Integrations/Widgets/WidgetViewController.m index a5e93b152..77056bcb0 100644 --- a/Riot/Modules/Integrations/Widgets/WidgetViewController.m +++ b/Riot/Modules/Integrations/Widgets/WidgetViewController.m @@ -60,7 +60,7 @@ NSString *const kJavascriptSendResponseToPostMessageAPI = @"riotIOS.sendResponse { self.navigationItem.title = widget.name ? widget.name : widget.type; - UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"room_context_menu_more"] style:UIBarButtonItemStylePlain target:self action:@selector(onMenuButtonPressed:)]; + UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithImage:AssetImages.roomContextMenuMore.image style:UIBarButtonItemStylePlain target:self action:@selector(onMenuButtonPressed:)]; self.navigationItem.rightBarButtonItem = menuButton; } diff --git a/Riot/Modules/MediaPicker/Library/MediaAlbumContentViewController.m b/Riot/Modules/MediaPicker/Library/MediaAlbumContentViewController.m index c01c845e6..440aeb027 100644 --- a/Riot/Modules/MediaPicker/Library/MediaAlbumContentViewController.m +++ b/Riot/Modules/MediaPicker/Library/MediaAlbumContentViewController.m @@ -268,10 +268,10 @@ }]; - cell.bottomLeftIcon.image = [UIImage imageNamed:@"video_icon"]; + cell.bottomLeftIcon.image = AssetImages.videoIcon.image; cell.bottomLeftIcon.hidden = (asset.mediaType == PHAssetMediaTypeImage); - cell.bottomRightIcon.image = [UIImage imageNamed:@"selection_tick"]; + cell.bottomRightIcon.image = AssetImages.selectionTick.image; cell.bottomRightIcon.tintColor = ThemeService.shared.theme.tintColor; cell.bottomRightIcon.hidden = !selectedAssets || (NSNotFound == [selectedAssets indexOfObject:asset]); diff --git a/Riot/Modules/MediaPicker/MediaPickerViewController.m b/Riot/Modules/MediaPicker/MediaPickerViewController.m index 48ff40d19..8905b926b 100644 --- a/Riot/Modules/MediaPicker/MediaPickerViewController.m +++ b/Riot/Modules/MediaPicker/MediaPickerViewController.m @@ -729,8 +729,8 @@ videoPlayerControl = [UIButton buttonWithType:UIButtonTypeCustom]; [videoPlayerControl addTarget:self action:@selector(controlVideoPlayer) forControlEvents:UIControlEventTouchUpInside]; videoPlayerControl.frame = CGRectMake(0, 0, 44, 44); - [videoPlayerControl setImage:[UIImage imageNamed:@"camera_play"] forState:UIControlStateNormal]; - [videoPlayerControl setImage:[UIImage imageNamed:@"camera_play"] forState:UIControlStateHighlighted]; + [videoPlayerControl setImage:AssetImages.cameraPlay.image forState:UIControlStateNormal]; + [videoPlayerControl setImage:AssetImages.cameraPlay.image forState:UIControlStateHighlighted]; [validationView addSubview:videoPlayerControl]; videoPlayerControl.center = validationView.imageView.center; @@ -796,8 +796,8 @@ [videoPlayer.player seekToTime:kCMTimeZero]; [videoPlayer.view removeFromSuperview]; - [videoPlayerControl setImage:[UIImage imageNamed:@"camera_play"] forState:UIControlStateNormal]; - [videoPlayerControl setImage:[UIImage imageNamed:@"camera_play"] forState:UIControlStateHighlighted]; + [videoPlayerControl setImage:AssetImages.cameraPlay.image forState:UIControlStateNormal]; + [videoPlayerControl setImage:AssetImages.cameraPlay.image forState:UIControlStateHighlighted]; } else { @@ -815,8 +815,8 @@ [videoPlayer.player play]; - [videoPlayerControl setImage:[UIImage imageNamed:@"camera_stop"] forState:UIControlStateNormal]; - [videoPlayerControl setImage:[UIImage imageNamed:@"camera_stop"] forState:UIControlStateHighlighted]; + [videoPlayerControl setImage:AssetImages.cameraStop.image forState:UIControlStateNormal]; + [videoPlayerControl setImage:AssetImages.cameraStop.image forState:UIControlStateHighlighted]; [validationView bringSubviewToFront:videoPlayerControl]; } } @@ -860,7 +860,7 @@ }]; - cell.bottomLeftIcon.image = [UIImage imageNamed:@"video_icon"]; + cell.bottomLeftIcon.image = AssetImages.videoIcon.image; cell.bottomLeftIcon.hidden = (asset.mediaType == PHAssetMediaTypeImage); // Disable user interaction in mxkImageView, in order to let collection handle user selection @@ -968,7 +968,7 @@ if (collection.assetCollectionSubtype == PHAssetCollectionSubtypeSmartAlbumVideos) { - cell.bottomLeftIcon.image = [UIImage imageNamed:@"video_icon"]; + cell.bottomLeftIcon.image = AssetImages.videoIcon.image; cell.bottomLeftIcon.hidden = NO; } else diff --git a/Riot/Modules/People/PeopleViewController.m b/Riot/Modules/People/PeopleViewController.m index 43bb1754c..028ec8eef 100644 --- a/Riot/Modules/People/PeopleViewController.m +++ b/Riot/Modules/People/PeopleViewController.m @@ -69,7 +69,7 @@ self.recentsTableView.tag = RecentsDataSourceModePeople; // Add the (+) button programmatically - plusButtonImageView = [self vc_addFABWithImage:[UIImage imageNamed:@"people_floating_action"] + plusButtonImageView = [self vc_addFABWithImage:AssetImages.peopleFloatingAction.image target:self action:@selector(onPlusButtonPressed)]; } @@ -177,11 +177,11 @@ { if (ThemeService.shared.isCurrentThemeDark) { - return [UIImage imageNamed:@"people_empty_screen_artwork_dark"]; + return AssetImages.peopleEmptyScreenArtworkDark.image; } else { - return [UIImage imageNamed:@"people_empty_screen_artwork"]; + return AssetImages.peopleEmptyScreenArtwork.image; } } diff --git a/Riot/Modules/Room/Members/Detail/RoomMemberDetailsViewController.m b/Riot/Modules/Room/Members/Detail/RoomMemberDetailsViewController.m index 687587dfe..b5928f009 100644 --- a/Riot/Modules/Room/Members/Detail/RoomMemberDetailsViewController.m +++ b/Riot/Modules/Room/Members/Detail/RoomMemberDetailsViewController.m @@ -350,7 +350,7 @@ return [AvatarGenerator generateAvatarForMatrixItem:self.mxRoomMember.userId withDisplayName:self.mxRoomMember.displayname]; } - return [MXKTools paintImage:[UIImage imageNamed:@"placeholder"] + return [MXKTools paintImage:AssetImages.placeholder.image withColor:ThemeService.shared.theme.tintColor]; } @@ -984,7 +984,7 @@ } else { - roomCell.avatarImageView.image = [UIImage imageNamed:@"start_chat"]; + roomCell.avatarImageView.image = AssetImages.startChat.image; roomCell.avatarImageView.defaultBackgroundColor = [UIColor clearColor]; roomCell.avatarImageView.userInteractionEnabled = NO; roomCell.titleLabel.text = [VectorL10n roomParticipantsActionStartNewChat]; diff --git a/Riot/Modules/Room/Members/RoomParticipantsViewController.m b/Riot/Modules/Room/Members/RoomParticipantsViewController.m index bdf4465b6..5eadaa9b7 100644 --- a/Riot/Modules/Room/Members/RoomParticipantsViewController.m +++ b/Riot/Modules/Room/Members/RoomParticipantsViewController.m @@ -145,7 +145,7 @@ // Add invite members button programmatically - [self vc_addFABWithImage:[UIImage imageNamed:@"add_member_floating_action"] + [self vc_addFABWithImage:AssetImages.addMemberFloatingAction.image target:self action:@selector(onAddParticipantButtonPressed)]; @@ -562,7 +562,7 @@ contactsDataSource.displaySearchInputInContactsList = YES; contactsDataSource.forceMatrixIdInDisplayName = YES; // Add a plus icon to the contact cell in the contacts picker, in order to make it more understandable for the end user. - contactsDataSource.contactCellAccessoryImage = [[UIImage imageNamed:@"plus_icon"] vc_tintedImageUsingColor:ThemeService.shared.theme.textPrimaryColor]; + contactsDataSource.contactCellAccessoryImage = [AssetImages.plusIcon.image vc_tintedImageUsingColor:ThemeService.shared.theme.textPrimaryColor]; // List all the participants matrix user id to ignore them during the contacts search. for (Contact *contact in actualParticipants) diff --git a/Riot/Modules/Room/RoomViewController.m b/Riot/Modules/Room/RoomViewController.m index d5f40da02..1c0e72410 100644 --- a/Riot/Modules/Room/RoomViewController.m +++ b/Riot/Modules/Room/RoomViewController.m @@ -442,7 +442,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; if (ThemeService.shared.isCurrentThemeDark) { - [self.scrollToBottomButton setImage:[UIImage imageNamed:@"scrolldown_dark"] forState:UIControlStateNormal]; + [self.scrollToBottomButton setImage:AssetImages.scrolldownDark.image forState:UIControlStateNormal]; self.jumpToLastUnreadBanner.backgroundColor = ThemeService.shared.theme.colors.navigation; [self.jumpToLastUnreadBanner vc_removeShadow]; @@ -450,7 +450,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; } else { - [self.scrollToBottomButton setImage:[UIImage imageNamed:@"scrolldown"] forState:UIControlStateNormal]; + [self.scrollToBottomButton setImage:AssetImages.scrolldown.image forState:UIControlStateNormal]; self.jumpToLastUnreadBanner.backgroundColor = ThemeService.shared.theme.colors.background; [self.jumpToLastUnreadBanner vc_addShadowWithColor:ThemeService.shared.theme.shadowColor @@ -1429,7 +1429,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; - (UIBarButtonItem *)videoCallBarButtonItem { - UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"video_call"] + UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithImage:AssetImages.videoCall.image style:UIBarButtonItemStylePlain target:self action:@selector(onVideoCallPressed:)]; @@ -1440,7 +1440,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; - (UIBarButtonItem *)threadMoreBarButtonItem { - UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"room_context_menu_more"] + UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithImage:AssetImages.roomContextMenuMore.image style:UIBarButtonItemStylePlain target:self action:@selector(onButtonPressed:)]; @@ -1452,7 +1452,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; - (BadgedBarButtonItem *)threadListBarButtonItem { UIButton *button = [UIButton new]; - UIImage *icon = [[UIImage imageNamed:@"threads_icon"] vc_resizedWith:CGSizeMake(21, 21)]; + UIImage *icon = [AssetImages.threadsIcon.image vc_resizedWith:CGSizeMake(21, 21)]; button.contentEdgeInsets = UIEdgeInsetsMake(4, 8, 4, 8); [button setImage:icon forState:UIControlStateNormal]; @@ -1609,7 +1609,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; if (self.roomDataSource.room.summary.membersCount.joined == 2 && self.roomDataSource.room.isDirect) { // voice call button for Matrix call - UIBarButtonItem *itemVoice = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"voice_call_hangon_icon"] + UIBarButtonItem *itemVoice = [[UIBarButtonItem alloc] initWithImage:AssetImages.voiceCallHangonIcon.image style:UIBarButtonItemStylePlain target:self action:@selector(onVoiceCallPressed:)]; @@ -1638,7 +1638,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; { // show Join button CallTileActionButton *button = [CallTileActionButton new]; - [button setImage:[UIImage imageNamed:@"call_video_icon"] + [button setImage:AssetImages.callVideoIcon.image forState:UIControlStateNormal]; [button setTitle:[VectorL10n roomJoinGroupCall] forState:UIControlStateNormal]; @@ -1660,7 +1660,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; UIBarButtonItem *item = [self videoCallBarButtonItem]; if (!self.canEditJitsiWidget) { - item.image = [[UIImage imageNamed:@"video_call"] vc_withAlpha:0.3]; + item.image = [AssetImages.videoCall.image vc_withAlpha:0.3]; } [rightBarButtonItems addObject:item]; } @@ -1669,7 +1669,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; if ([self widgetsCount:NO]) { - UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"integrations_icon"] + UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithImage:AssetImages.integrationsIcon.image style:UIBarButtonItemStylePlain target:self action:@selector(onIntegrationsPressed:)]; @@ -1986,7 +1986,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; NSMutableArray *actionItems = [NSMutableArray new]; if (RiotSettings.shared.roomScreenAllowMediaLibraryAction) { - [actionItems addObject:[[RoomActionItem alloc] initWithImage:[UIImage imageNamed:@"action_media_library"] andAction:^{ + [actionItems addObject:[[RoomActionItem alloc] initWithImage:AssetImages.actionMediaLibrary.image andAction:^{ MXStrongifyAndReturnIfNil(self); if ([self.inputToolbarView isKindOfClass:RoomInputToolbarView.class]) { ((RoomInputToolbarView *) self.inputToolbarView).actionMenuOpened = NO; @@ -1996,7 +1996,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; } if (RiotSettings.shared.roomScreenAllowStickerAction) { - [actionItems addObject:[[RoomActionItem alloc] initWithImage:[UIImage imageNamed:@"action_sticker"] andAction:^{ + [actionItems addObject:[[RoomActionItem alloc] initWithImage:AssetImages.actionSticker.image andAction:^{ MXStrongifyAndReturnIfNil(self); if ([self.inputToolbarView isKindOfClass:RoomInputToolbarView.class]) { ((RoomInputToolbarView *) self.inputToolbarView).actionMenuOpened = NO; @@ -2006,7 +2006,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; } if (RiotSettings.shared.roomScreenAllowFilesAction) { - [actionItems addObject:[[RoomActionItem alloc] initWithImage:[UIImage imageNamed:@"action_file"] andAction:^{ + [actionItems addObject:[[RoomActionItem alloc] initWithImage:AssetImages.actionFile.image andAction:^{ MXStrongifyAndReturnIfNil(self); if ([self.inputToolbarView isKindOfClass:RoomInputToolbarView.class]) { ((RoomInputToolbarView *) self.inputToolbarView).actionMenuOpened = NO; @@ -2016,7 +2016,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; } if (BuildSettings.pollsEnabled && self.displayConfiguration.sendingPollsEnabled) { - [actionItems addObject:[[RoomActionItem alloc] initWithImage:[UIImage imageNamed:@"action_poll"] andAction:^{ + [actionItems addObject:[[RoomActionItem alloc] initWithImage:AssetImages.actionPoll.image andAction:^{ MXStrongifyAndReturnIfNil(self); if ([self.inputToolbarView isKindOfClass:RoomInputToolbarView.class]) { ((RoomInputToolbarView *) self.inputToolbarView).actionMenuOpened = NO; @@ -2026,7 +2026,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; } if (BuildSettings.locationSharingEnabled) { - [actionItems addObject:[[RoomActionItem alloc] initWithImage:[UIImage imageNamed:@"action_location"] andAction:^{ + [actionItems addObject:[[RoomActionItem alloc] initWithImage:AssetImages.actionLocation.image andAction:^{ MXStrongifyAndReturnIfNil(self); if ([self.inputToolbarView isKindOfClass:RoomInputToolbarView.class]) { ((RoomInputToolbarView *) self.inputToolbarView).actionMenuOpened = NO; @@ -2036,7 +2036,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; } if (RiotSettings.shared.roomScreenAllowCameraAction) { - [actionItems addObject:[[RoomActionItem alloc] initWithImage:[UIImage imageNamed:@"action_camera"] andAction:^{ + [actionItems addObject:[[RoomActionItem alloc] initWithImage:AssetImages.actionCamera.image andAction:^{ MXStrongifyAndReturnIfNil(self); if ([self.inputToolbarView isKindOfClass:RoomInputToolbarView.class]) { ((RoomInputToolbarView *) self.inputToolbarView).actionMenuOpened = NO; @@ -2553,7 +2553,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; } else { - previewHeader.roomAvatarPlaceholder = [MXKTools paintImage:[UIImage imageNamed:@"placeholder"] + previewHeader.roomAvatarPlaceholder = [MXKTools paintImage:AssetImages.placeholder.image withColor:ThemeService.shared.theme.tintColor]; } } @@ -3717,7 +3717,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; { MXKPasteboardManager.shared.pasteboard.URL = url; [self.view vc_toastWithMessage:VectorL10n.roomEventCopyLinkInfo - image:[UIImage imageNamed:@"link_icon"] + image:AssetImages.linkIcon.image duration:2.0 position:ToastPositionBottom additionalMargin:self.roomInputToolbarContainerHeightConstraint.constant]; diff --git a/Riot/Modules/Room/Settings/RoomSettingsViewController.m b/Riot/Modules/Room/Settings/RoomSettingsViewController.m index d844deaee..4d07543fe 100644 --- a/Riot/Modules/Room/Settings/RoomSettingsViewController.m +++ b/Riot/Modules/Room/Settings/RoomSettingsViewController.m @@ -1047,7 +1047,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti { MXKPasteboardManager.shared.pasteboard.URL = url; [self.view vc_toastWithMessage:VectorL10n.roomEventCopyLinkInfo - image:[UIImage imageNamed:@"link_icon"] + image:AssetImages.linkIcon.image duration:2.0 position:ToastPositionBottom additionalMargin:0.0]; @@ -2640,7 +2640,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti addAddressCell.mxkLabel.text = nil; addAddressCell.accessoryType = UITableViewCellAccessoryNone; - addAddressCell.accessoryView = [[UIImageView alloc] initWithImage:[[UIImage imageNamed:@"plus_icon"] vc_tintedImageUsingColor:ThemeService.shared.theme.textPrimaryColor]]; + addAddressCell.accessoryView = [[UIImageView alloc] initWithImage:[AssetImages.plusIcon.image vc_tintedImageUsingColor:ThemeService.shared.theme.textPrimaryColor]]; addAddressTextField = addAddressCell.mxkTextField; addAddressTextField.placeholder = [VectorL10n roomDetailsNewAddressPlaceholder:self.mainSession.matrixRestClient.homeserverSuffix]; @@ -2717,7 +2717,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti { if ([alias isEqualToString:canonicalAlias]) { - addressCell.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"main_alias_icon"]]; + addressCell.accessoryView = [[UIImageView alloc] initWithImage:AssetImages.mainAliasIcon.image]; } } } @@ -2741,7 +2741,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti addCommunityCell.mxkLabel.text = nil; addCommunityCell.accessoryType = UITableViewCellAccessoryNone; - addCommunityCell.accessoryView = [[UIImageView alloc] initWithImage:[[UIImage imageNamed:@"plus_icon"] vc_tintedImageUsingColor:ThemeService.shared.theme.textPrimaryColor]]; + addCommunityCell.accessoryView = [[UIImageView alloc] initWithImage:[AssetImages.plusIcon.image vc_tintedImageUsingColor:ThemeService.shared.theme.textPrimaryColor]]; addGroupTextField = addCommunityCell.mxkTextField; addGroupTextField.placeholder = [VectorL10n roomDetailsNewFlairPlaceholder:self.mainSession.matrixRestClient.homeserverSuffix]; @@ -3270,7 +3270,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti completionHandler(YES); }]; removeAddressAction.backgroundColor = ThemeService.shared.theme.headerBackgroundColor; - removeAddressAction.image = [[UIImage imageNamed:@"remove_icon"] vc_notRenderedImage]; + removeAddressAction.image = [AssetImages.removeIcon.image vc_notRenderedImage]; // Create swipe action configuration @@ -3291,7 +3291,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti completionHandler(YES); }]; removeAddressAction.backgroundColor = ThemeService.shared.theme.headerBackgroundColor; - removeAddressAction.image = [[UIImage imageNamed:@"remove_icon"] vc_notRenderedImage]; + removeAddressAction.image = [AssetImages.removeIcon.image vc_notRenderedImage]; // Create swipe action configuration diff --git a/Riot/Modules/Room/Settings/Views/TableViewCellWithCheckBoxAndLabel.m b/Riot/Modules/Room/Settings/Views/TableViewCellWithCheckBoxAndLabel.m index b623ffc7d..718cce122 100644 --- a/Riot/Modules/Room/Settings/Views/TableViewCellWithCheckBoxAndLabel.m +++ b/Riot/Modules/Room/Settings/Views/TableViewCellWithCheckBoxAndLabel.m @@ -34,11 +34,11 @@ { if (enabled) { - _checkBox.image = [UIImage imageNamed:@"selection_tick"]; + _checkBox.image = AssetImages.selectionTick.image; } else { - _checkBox.image = [UIImage imageNamed:@"selection_untick"]; + _checkBox.image = AssetImages.selectionUntick.image; } _enabled = enabled; diff --git a/Riot/Modules/Room/Settings/Views/TableViewCellWithCheckBoxes.m b/Riot/Modules/Room/Settings/Views/TableViewCellWithCheckBoxes.m index 9504214a1..c3a683e7c 100644 --- a/Riot/Modules/Room/Settings/Views/TableViewCellWithCheckBoxes.m +++ b/Riot/Modules/Room/Settings/Views/TableViewCellWithCheckBoxes.m @@ -131,7 +131,7 @@ [checkboxContainer addSubview:checkbox]; // Store the new check box unselected by default - checkbox.image = [UIImage imageNamed:@"selection_untick"]; + checkbox.image = AssetImages.selectionUntick.image; checkbox.tintColor = ThemeService.shared.theme.tintColor; checkbox.tag = 0; [checkBoxesArray addObject:checkbox]; @@ -263,7 +263,7 @@ if (isSelected && !checkBox.tag) { - checkBox.image = [UIImage imageNamed:@"selection_tick"]; + checkBox.image = AssetImages.selectionTick.image; checkBox.tag = 1; if (!self.allowsMultipleSelection) @@ -276,7 +276,7 @@ checkBox = checkBoxesArray[k]; if (checkBox.tag) { - checkBox.image = [UIImage imageNamed:@"selection_untick"]; + checkBox.image = AssetImages.selectionUntick.image; checkBox.tag = 0; } } @@ -285,7 +285,7 @@ } else if (!isSelected && checkBox.tag) { - checkBox.image = [UIImage imageNamed:@"selection_untick"]; + checkBox.image = AssetImages.selectionUntick.image; checkBox.tag = 0; } } diff --git a/Riot/Modules/Room/Views/Activities/RoomActivitiesView.m b/Riot/Modules/Room/Views/Activities/RoomActivitiesView.m index f32e4cc68..6acd41443 100644 --- a/Riot/Modules/Room/Views/Activities/RoomActivitiesView.m +++ b/Riot/Modules/Room/Views/Activities/RoomActivitiesView.m @@ -124,7 +124,7 @@ [self.resendButton setTitle:[VectorL10n retry] forState:UIControlStateNormal]; self.resendButton.backgroundColor = ThemeService.shared.theme.tintColor; - UIImage *image = [[UIImage imageNamed:@"room_context_menu_delete"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; + UIImage *image = [AssetImages.roomContextMenuDelete.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; [self.deleteButton setImage:image forState:UIControlStateNormal]; self.deleteButton.tintColor = ThemeService.shared.theme.warningColor; @@ -174,7 +174,7 @@ if (labelText.length) { - self.iconImageView.image = [UIImage imageNamed:@"error"]; + self.iconImageView.image = AssetImages.error.image; self.iconImageView.tintColor = ThemeService.shared.theme.noticeColor; self.messageLabel.text = labelText; self.messageLabel.textColor = ThemeService.shared.theme.warningColor; @@ -192,7 +192,7 @@ if (labelText.length) { - self.iconImageView.image = [UIImage imageNamed:@"typing"]; + self.iconImageView.image = AssetImages.typing.image; self.iconImageView.tintColor = ThemeService.shared.theme.tintColor; self.messageLabel.text = labelText; @@ -309,7 +309,7 @@ self.messageTextView.hidden = NO; self.messageTextView.backgroundColor = [UIColor clearColor]; - self.iconImageView.image = [UIImage imageNamed:@"error"]; + self.iconImageView.image = AssetImages.error.image; self.iconImageView.tintColor = ThemeService.shared.theme.noticeColor; self.iconImageView.hidden = NO; diff --git a/Riot/Modules/Room/Views/BubbleCells/Encryption/RoomEncryptedDataBubbleCell.m b/Riot/Modules/Room/Views/BubbleCells/Encryption/RoomEncryptedDataBubbleCell.m index 6958e3ed5..7a5e50ff9 100644 --- a/Riot/Modules/Room/Views/BubbleCells/Encryption/RoomEncryptedDataBubbleCell.m +++ b/Riot/Modules/Room/Views/BubbleCells/Encryption/RoomEncryptedDataBubbleCell.m @@ -16,6 +16,7 @@ */ #import "RoomEncryptedDataBubbleCell.h" +#import "GeneratedInterface-Swift.h" NSString *const kRoomEncryptedDataBubbleCellTapOnEncryptionIcon = @"kRoomEncryptedDataBubbleCellTapOnEncryptionIcon"; @@ -28,7 +29,7 @@ NSString *const kRoomEncryptedDataBubbleCellTapOnEncryptionIcon = @"kRoomEncrypt return nil; } - return [UIImage imageNamed:@"encryption_warning"]; + return AssetImages.encryptionWarning.image; } + (void)addEncryptionStatusFromBubbleData:(MXKRoomBubbleCellData *)bubbleData inContainerView:(UIView *)containerView diff --git a/Riot/Modules/Room/Views/InputToolbar/RoomInputToolbarView.m b/Riot/Modules/Room/Views/InputToolbar/RoomInputToolbarView.m index cffe8fe1b..63737645b 100644 --- a/Riot/Modules/Room/Views/InputToolbar/RoomInputToolbarView.m +++ b/Riot/Modules/Room/Views/InputToolbar/RoomInputToolbarView.m @@ -127,21 +127,21 @@ static const NSTimeInterval kActionMenuComposerHeightAnimationDuration = .3; self.attachMediaButton.accessibilityLabel = [VectorL10n roomAccessibilityUpload]; - UIImage *image = [UIImage imageNamed:@"input_text_background"]; + UIImage *image = AssetImages.inputTextBackground.image; image = [image resizableImageWithCapInsets:UIEdgeInsetsMake(9, 15, 10, 16)]; self.inputTextBackgroundView.image = image; self.inputTextBackgroundView.tintColor = ThemeService.shared.theme.roomInputTextBorder; if ([ThemeService.shared.themeId isEqualToString:@"light"]) { - [self.attachMediaButton setImage:[UIImage imageNamed:@"upload_icon"] forState:UIControlStateNormal]; + [self.attachMediaButton setImage:AssetImages.uploadIcon.image forState:UIControlStateNormal]; } else if ([ThemeService.shared.themeId isEqualToString:@"dark"] || [ThemeService.shared.themeId isEqualToString:@"black"]) { - [self.attachMediaButton setImage:[UIImage imageNamed:@"upload_icon_dark"] forState:UIControlStateNormal]; + [self.attachMediaButton setImage:AssetImages.uploadIconDark.image forState:UIControlStateNormal]; } else if (ThemeService.shared.theme.userInterfaceStyle == UIUserInterfaceStyleDark) { - [self.attachMediaButton setImage:[UIImage imageNamed:@"upload_icon_dark"] forState:UIControlStateNormal]; + [self.attachMediaButton setImage:AssetImages.uploadIconDark.image forState:UIControlStateNormal]; } self.inputContextImageView.tintColor = ThemeService.shared.theme.textSecondaryColor; @@ -192,8 +192,8 @@ static const NSTimeInterval kActionMenuComposerHeightAnimationDuration = .3; switch (_sendMode) { case RoomInputToolbarViewSendModeReply: - buttonImage = [UIImage imageNamed:@"send_icon"]; - self.inputContextImageView.image = [UIImage imageNamed:@"input_reply_icon"]; + buttonImage = AssetImages.sendIcon.image; + self.inputContextImageView.image = AssetImages.inputReplyIcon.image; self.inputContextLabel.text = [VectorL10n roomMessageReplyingTo:self.eventSenderDisplayName]; self.inputContextViewHeightConstraint.constant = kContextBarHeight; @@ -201,8 +201,8 @@ static const NSTimeInterval kActionMenuComposerHeightAnimationDuration = .3; self.textView.maxHeight -= kContextBarHeight; break; case RoomInputToolbarViewSendModeEdit: - buttonImage = [UIImage imageNamed:@"save_icon"]; - self.inputContextImageView.image = [UIImage imageNamed:@"input_edit_icon"]; + buttonImage = AssetImages.saveIcon.image; + self.inputContextImageView.image = AssetImages.inputEditIcon.image; self.inputContextLabel.text = [VectorL10n roomMessageEditing]; self.inputContextViewHeightConstraint.constant = kContextBarHeight; @@ -210,7 +210,7 @@ static const NSTimeInterval kActionMenuComposerHeightAnimationDuration = .3; self.textView.maxHeight -= kContextBarHeight; break; default: - buttonImage = [UIImage imageNamed:@"send_icon"]; + buttonImage = AssetImages.sendIcon.image; if (previousMode != _sendMode) { diff --git a/Riot/Modules/Room/Views/Title/Preview/PreviewRoomTitleView.m b/Riot/Modules/Room/Views/Title/Preview/PreviewRoomTitleView.m index 81a128564..7e8456a5b 100644 --- a/Riot/Modules/Room/Views/Title/Preview/PreviewRoomTitleView.m +++ b/Riot/Modules/Room/Views/Title/Preview/PreviewRoomTitleView.m @@ -102,7 +102,7 @@ andImageOrientation:UIImageOrientationUp toFitViewSize:self.roomAvatar.frame.size withMethod:MXThumbnailingMethodCrop - previewImage:[MXKTools paintImage:[UIImage imageNamed:@"placeholder"] + previewImage:[MXKTools paintImage:AssetImages.placeholder.image withColor:ThemeService.shared.theme.tintColor] mediaManager:self.mxRoom.mxSession.mediaManager]; } diff --git a/Riot/Modules/Rooms/DirectoryPicker/Views/DirectoryServerTableViewCell.m b/Riot/Modules/Rooms/DirectoryPicker/Views/DirectoryServerTableViewCell.m index fed334510..6ec9484e6 100644 --- a/Riot/Modules/Rooms/DirectoryPicker/Views/DirectoryServerTableViewCell.m +++ b/Riot/Modules/Rooms/DirectoryPicker/Views/DirectoryServerTableViewCell.m @@ -63,7 +63,7 @@ [self.iconImageView setImageURI:iconURL withType:nil andImageOrientation:UIImageOrientationUp - previewImage:[MXKTools paintImage:[UIImage imageNamed:@"placeholder"] + previewImage:[MXKTools paintImage:AssetImages.placeholder.image withColor:ThemeService.shared.theme.tintColor] mediaManager:cellData.mediaManager]; } diff --git a/Riot/Modules/Rooms/RoomsViewController.m b/Riot/Modules/Rooms/RoomsViewController.m index 71975e939..6e2adfc62 100644 --- a/Riot/Modules/Rooms/RoomsViewController.m +++ b/Riot/Modules/Rooms/RoomsViewController.m @@ -58,7 +58,7 @@ self.recentsTableView.tag = RecentsDataSourceModeRooms; // Add the (+) button programmatically - plusButtonImageView = [self vc_addFABWithImage:[UIImage imageNamed:@"rooms_floating_action"] + plusButtonImageView = [self vc_addFABWithImage:AssetImages.roomsFloatingAction.image target:self action:@selector(onPlusButtonPressed)]; } @@ -157,11 +157,11 @@ { if (ThemeService.shared.isCurrentThemeDark) { - return [UIImage imageNamed:@"rooms_empty_screen_artwork_dark"]; + return AssetImages.roomsEmptyScreenArtworkDark.image; } else { - return [UIImage imageNamed:@"rooms_empty_screen_artwork"]; + return AssetImages.roomsEmptyScreenArtwork.image; } } diff --git a/Riot/Modules/Settings/Security/ManageSession/ManageSessionViewController.m b/Riot/Modules/Settings/Security/ManageSession/ManageSessionViewController.m index 42920094f..ab7edff15 100644 --- a/Riot/Modules/Settings/Security/ManageSession/ManageSessionViewController.m +++ b/Riot/Modules/Settings/Security/ManageSession/ManageSessionViewController.m @@ -383,12 +383,12 @@ enum { if (deviceInfo.trustLevel.isVerified) { cell.textLabel.text = [VectorL10n manageSessionTrusted]; - cell.imageView.image = [UIImage imageNamed:@"encryption_trusted"]; + cell.imageView.image = AssetImages.encryptionTrusted.image; } else { cell.textLabel.text = [VectorL10n manageSessionNotTrusted]; - cell.imageView.image = [UIImage imageNamed:@"encryption_warning"]; + cell.imageView.image = AssetImages.encryptionWarning.image; } return cell; diff --git a/Riot/Modules/Settings/Security/SecurityViewController.m b/Riot/Modules/Settings/Security/SecurityViewController.m index 99b7f7c93..7082ba3bf 100644 --- a/Riot/Modules/Settings/Security/SecurityViewController.m +++ b/Riot/Modules/Settings/Security/SecurityViewController.m @@ -1097,19 +1097,19 @@ TableViewSectionsDelegate> { if ([deviceId isEqualToString:self.mainSession.myDeviceId]) { - return [UIImage imageNamed:@"encryption_warning"]; + return AssetImages.encryptionWarning.image; } else { - return [UIImage imageNamed:@"encryption_normal"]; + return AssetImages.encryptionNormal.image; } } - UIImage* shieldImageForDevice = [UIImage imageNamed:@"encryption_warning"]; + UIImage* shieldImageForDevice = AssetImages.encryptionWarning.image; MXDeviceInfo *device = [self.mainSession.crypto deviceWithDeviceId:deviceId ofUser:self.mainSession.myUser.userId]; if (device.trustLevel.isVerified) { - shieldImageForDevice = [UIImage imageNamed:@"encryption_trusted"]; + shieldImageForDevice = AssetImages.encryptionTrusted.image; } return shieldImageForDevice; diff --git a/Riot/Modules/Settings/SettingsViewController.m b/Riot/Modules/Settings/SettingsViewController.m index c9c738f66..04eaa5519 100644 --- a/Riot/Modules/Settings/SettingsViewController.m +++ b/Riot/Modules/Settings/SettingsViewController.m @@ -1838,7 +1838,7 @@ TableViewSectionsDelegate> newEmailCell.mxkLabel.text = [VectorL10n settingsAddEmailAddress]; newEmailCell.mxkTextField.text = nil; newEmailCell.mxkTextField.userInteractionEnabled = NO; - newEmailCell.accessoryView = [[UIImageView alloc] initWithImage:[[UIImage imageNamed:@"plus_icon"] vc_tintedImageUsingColor:ThemeService.shared.theme.textPrimaryColor]]; + newEmailCell.accessoryView = [[UIImageView alloc] initWithImage:[AssetImages.plusIcon.image vc_tintedImageUsingColor:ThemeService.shared.theme.textPrimaryColor]]; } else { @@ -1873,7 +1873,7 @@ TableViewSectionsDelegate> newEmailTextField = newEmailCell.mxkTextField; } - UIImage *accessoryViewImage = [[UIImage imageNamed:@"plus_icon"] vc_tintedImageUsingColor:ThemeService.shared.theme.tintColor]; + UIImage *accessoryViewImage = [AssetImages.plusIcon.image vc_tintedImageUsingColor:ThemeService.shared.theme.tintColor]; newEmailCell.accessoryView = [[UIImageView alloc] initWithImage:accessoryViewImage]; } @@ -1891,7 +1891,7 @@ TableViewSectionsDelegate> newPhoneCell.mxkLabel.text = [VectorL10n settingsAddPhoneNumber]; newPhoneCell.mxkTextField.text = nil; newPhoneCell.mxkTextField.userInteractionEnabled = NO; - newPhoneCell.accessoryView = [[UIImageView alloc] initWithImage:[[UIImage imageNamed:@"plus_icon"] vc_tintedImageUsingColor:ThemeService.shared.theme.textPrimaryColor]]; + newPhoneCell.accessoryView = [[UIImageView alloc] initWithImage:[AssetImages.plusIcon.image vc_tintedImageUsingColor:ThemeService.shared.theme.textPrimaryColor]]; cell = newPhoneCell; } @@ -1953,7 +1953,7 @@ TableViewSectionsDelegate> newPhoneNumberCell = newPhoneCell; } - UIImage *accessoryViewImage = [[UIImage imageNamed:@"plus_icon"] vc_tintedImageUsingColor:ThemeService.shared.theme.tintColor]; + UIImage *accessoryViewImage = [AssetImages.plusIcon.image vc_tintedImageUsingColor:ThemeService.shared.theme.tintColor]; newPhoneCell.accessoryView = [[UIImageView alloc] initWithImage:accessoryViewImage]; cell = newPhoneCell; diff --git a/Riot/Modules/StartChat/StartChatViewController.m b/Riot/Modules/StartChat/StartChatViewController.m index 4f2d71dc1..9d8da5e52 100644 --- a/Riot/Modules/StartChat/StartChatViewController.m +++ b/Riot/Modules/StartChat/StartChatViewController.m @@ -105,7 +105,7 @@ dataSource.forceMatrixIdInDisplayName = YES; // Add a plus icon to the contact cell when a search session is in progress, // in order to make it more understandable for the end user. - dataSource.contactCellAccessoryImage = [[UIImage imageNamed:@"plus_icon"] vc_tintedImageUsingColor:ThemeService.shared.theme.textPrimaryColor]; + dataSource.contactCellAccessoryImage = [AssetImages.plusIcon.image vc_tintedImageUsingColor:ThemeService.shared.theme.textPrimaryColor]; [self displayList:dataSource]; diff --git a/Riot/Modules/UserDevices/Views/DeviceTableViewCell.m b/Riot/Modules/UserDevices/Views/DeviceTableViewCell.m index 7fde39ca4..d2f3a045c 100644 --- a/Riot/Modules/UserDevices/Views/DeviceTableViewCell.m +++ b/Riot/Modules/UserDevices/Views/DeviceTableViewCell.m @@ -55,7 +55,7 @@ case MXDeviceUnknown: case MXDeviceUnverified: { - self.deviceStatus.image = [UIImage imageNamed:@"e2e_warning"]; + self.deviceStatus.image = AssetImages.e2eWarning.image; [_verifyButton setTitle:[MatrixKitL10n roomEventEncryptionInfoVerify] forState:UIControlStateNormal]; [_verifyButton setTitle:[MatrixKitL10n roomEventEncryptionInfoVerify] forState:UIControlStateHighlighted]; @@ -65,7 +65,7 @@ } case MXDeviceVerified: { - self.deviceStatus.image = [UIImage imageNamed:@"e2e_verified"]; + self.deviceStatus.image = AssetSharedImages.e2eVerified.image; [_verifyButton setTitle:[MatrixKitL10n roomEventEncryptionInfoUnverify] forState:UIControlStateNormal]; [_verifyButton setTitle:[MatrixKitL10n roomEventEncryptionInfoUnverify] forState:UIControlStateHighlighted]; @@ -76,7 +76,7 @@ } case MXDeviceBlocked: { - self.deviceStatus.image = [UIImage imageNamed:@"e2e_blocked"]; + self.deviceStatus.image = AssetImages.e2eBlocked.image; [_verifyButton setTitle:[MatrixKitL10n roomEventEncryptionInfoVerify] forState:UIControlStateNormal]; [_verifyButton setTitle:[MatrixKitL10n roomEventEncryptionInfoVerify] forState:UIControlStateHighlighted]; diff --git a/Riot/Utils/EventFormatter.m b/Riot/Utils/EventFormatter.m index 32c0eaf1f..88c504bf0 100644 --- a/Riot/Utils/EventFormatter.m +++ b/Riot/Utils/EventFormatter.m @@ -82,7 +82,7 @@ static NSString *const kEventFormatterTimeFormat = @"HH:mm"; CGSize imageSize = CGSizeMake(20, 20); NSTextAttachment *attachment = [[NSTextAttachment alloc] init]; - attachment.image = [[[UIImage imageNamed:@"room_context_menu_delete"] vc_resizedWith:imageSize] vc_tintedImageUsingColor:color]; + attachment.image = [[AssetImages.roomContextMenuDelete.image vc_resizedWith:imageSize] vc_tintedImageUsingColor:color]; attachment.bounds = CGRectMake(0, font.descender, imageSize.width, imageSize.height); NSAttributedString *imageString = [NSAttributedString attributedStringWithAttachment:attachment]; diff --git a/RiotShareExtension/Shared/View/RecentRoomTableViewCell.m b/RiotShareExtension/Shared/View/RecentRoomTableViewCell.m index d5f277193..b33952e20 100644 --- a/RiotShareExtension/Shared/View/RecentRoomTableViewCell.m +++ b/RiotShareExtension/Shared/View/RecentRoomTableViewCell.m @@ -56,8 +56,8 @@ self.contentView.backgroundColor = ThemeService.shared.theme.backgroundColor; self.selectionButton.tintColor = ThemeService.shared.theme.tintColor; - [self.selectionButton setImage:[UIImage imageNamed:@"radio-button-default"] forState:UIControlStateNormal]; - [self.selectionButton setImage:[UIImage imageNamed:@"radio-button-selected"] forState:UIControlStateSelected]; + [self.selectionButton setImage:AssetSharedImages.radioButtonDefault.image forState:UIControlStateNormal]; + [self.selectionButton setImage:AssetSharedImages.radioButtonSelected.image forState:UIControlStateSelected]; [self.selectionButton setTitle:@"" forState:UIControlStateNormal]; [self.selectionButton setTitle:@"" forState:UIControlStateSelected]; diff --git a/RiotShareExtension/target.yml b/RiotShareExtension/target.yml index 945d77d7a..b9c5b32fd 100644 --- a/RiotShareExtension/target.yml +++ b/RiotShareExtension/target.yml @@ -60,6 +60,7 @@ targets: - path: ../Riot/Modules/Common/Recents/Model/RecentCellData.m - path: ../Riot/PropertyWrappers/UserDefaultsBackedPropertyWrapper.swift - path: ../Riot/Generated/Strings.swift + - path: ../Riot/Generated/Images.swift - path: ../Riot/Managers/Locale/LocaleProviderType.swift - path: ../Riot/Managers/Locale/LocaleProvider.swift - path: ../Riot/Modules/Common/SegmentedViewController/SegmentedViewController.xib diff --git a/Tools/SwiftGen/Templates/Assets/swift4-element.stencil b/Tools/SwiftGen/Templates/Assets/swift4-element.stencil new file mode 100644 index 000000000..a614d8715 --- /dev/null +++ b/Tools/SwiftGen/Templates/Assets/swift4-element.stencil @@ -0,0 +1,337 @@ +// swiftlint:disable all +// Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen + +{% if catalogs %} +{% set className %}{{param.className|default:"Asset"}}{% endset %} +{% set arResourceGroupType %}{{param.arResourceGroupTypeName|default:"ARResourceGroupAsset"}}{% endset %} +{% set colorType %}{{param.colorTypeName|default:"ColorAsset"}}{% endset %} +{% set dataType %}{{param.dataTypeName|default:"DataAsset"}}{% endset %} +{% set imageType %}{{param.imageTypeName|default:"ImageAsset"}}{% endset %} +{% set symbolType %}{{param.symbolTypeName|default:"SymbolAsset"}}{% endset %} +{% set forceNamespaces %}{{param.forceProvidesNamespaces|default:"false"}}{% endset %} +{% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %} +#if os(macOS) + import AppKit +#elseif os(iOS) +{% if resourceCount.arresourcegroup > 0 %} + import ARKit +{% endif %} + import UIKit +#elseif os(tvOS) || os(watchOS) + import UIKit +#endif + +// Deprecated typealiases +{% if resourceCount.color > 0 %} +@available(*, deprecated, renamed: "{{colorType}}.Color", message: "This typealias will be removed in SwiftGen 7.0") +{{accessModifier}} typealias {{param.colorAliasName|default:"AssetColorTypeAlias"}} = {{colorType}}.Color +{% endif %} +{% if resourceCount.image > 0 %} +@available(*, deprecated, renamed: "{{imageType}}.Image", message: "This typealias will be removed in SwiftGen 7.0") +{{accessModifier}} typealias {{param.imageAliasName|default:"AssetImageTypeAlias"}} = {{imageType}}.Image +{% endif %} + +// swiftlint:disable superfluous_disable_command file_length implicit_return + +// MARK: - Asset Catalogs + +{% macro enumBlock assets %} + {% call casesBlock assets %} + {% if param.allValues %} + + // swiftlint:disable trailing_comma + {% if resourceCount.arresourcegroup > 0 %} + {{accessModifier}} static let allResourceGroups: [{{arResourceGroupType}}] = [ + {% filter indent:2 %}{% call allValuesBlock assets "arresourcegroup" "" %}{% endfilter %} + ] + {% endif %} + {% if resourceCount.color > 0 %} + {{accessModifier}} static let allColors: [{{colorType}}] = [ + {% filter indent:2 %}{% call allValuesBlock assets "color" "" %}{% endfilter %} + ] + {% endif %} + {% if resourceCount.data > 0 %} + {{accessModifier}} static let allDataAssets: [{{dataType}}] = [ + {% filter indent:2 %}{% call allValuesBlock assets "data" "" %}{% endfilter %} + ] + {% endif %} + {% if resourceCount.image > 0 %} + {{accessModifier}} static let allImages: [{{imageType}}] = [ + {% filter indent:2 %}{% call allValuesBlock assets "image" "" %}{% endfilter %} + ] + {% endif %} + {% if resourceCount.symbol > 0 %} + {{accessModifier}} static let allSymbols: [{{symbolType}}] = [ + {% filter indent:2 %}{% call allValuesBlock assets "symbol" "" %}{% endfilter %} + ] + {% endif %} + // swiftlint:enable trailing_comma + {% endif %} +{% endmacro %} +{% macro casesBlock assets %} + {% for asset in assets %} + {% if asset.type == "arresourcegroup" %} + {{accessModifier}} static let {{asset.name|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}} = {{arResourceGroupType}}(name: "{{asset.value}}") + {% elif asset.type == "color" %} + {{accessModifier}} static let {{asset.name|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}} = {{colorType}}(name: "{{asset.value}}") + {% elif asset.type == "data" %} + {{accessModifier}} static let {{asset.name|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}} = {{dataType}}(name: "{{asset.value}}") + {% elif asset.type == "image" %} + {{accessModifier}} static let {{asset.name|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}} = {{imageType}}(name: "{{asset.value}}") + {% elif asset.type == "symbol" %} + {{accessModifier}} static let {{asset.name|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}} = {{symbolType}}(name: "{{asset.value}}") + {% elif asset.items and ( forceNamespaces == "true" or asset.isNamespaced == "true" ) %} + {{accessModifier}} enum {{asset.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} { + {% filter indent:2 %}{% call casesBlock asset.items %}{% endfilter %} + } + {% elif asset.items %} + {% call casesBlock asset.items %} + {% endif %} + {% endfor %} +{% endmacro %} +{% macro allValuesBlock assets filter prefix %} + {% for asset in assets %} + {% if asset.type == filter %} + {{prefix}}{{asset.name|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}, + {% elif asset.items and ( forceNamespaces == "true" or asset.isNamespaced == "true" ) %} + {% set prefix2 %}{{prefix}}{{asset.name|swiftIdentifier:"pretty"|escapeReservedKeywords}}.{% endset %} + {% call allValuesBlock asset.items filter prefix2 %} + {% elif asset.items %} + {% call allValuesBlock asset.items filter prefix %} + {% endif %} + {% endfor %} +{% endmacro %} +// swiftlint:disable identifier_name line_length nesting type_body_length type_name +@objcMembers +{{accessModifier}} class {{className}}: NSObject { + {% if catalogs.count > 1 or param.forceFileNameEnum %} + {% for catalog in catalogs %} + @objcMembers + @objc({{className}}{{catalog.name|swiftIdentifier:"pretty"|escapeReservedKeywords}}) {{accessModifier}} class {{catalog.name|swiftIdentifier:"pretty"|escapeReservedKeywords}}: NSObject { + {% filter indent:2 %}{% call enumBlock catalog.assets %}{% endfilter %} + } + {% endfor %} + {% else %} + {% call enumBlock catalogs.first.assets %} + {% endif %} +} +// swiftlint:enable identifier_name line_length nesting type_body_length type_name + +// MARK: - Implementation Details +{% if resourceCount.arresourcegroup > 0 %} + +{{accessModifier}} struct {{arResourceGroupType}} { + {{accessModifier}} fileprivate(set) var name: String + + #if os(iOS) + @available(iOS 11.3, *) + {{accessModifier}} var referenceImages: Set { + return ARReferenceImage.referenceImages(in: self) + } + + @available(iOS 12.0, *) + {{accessModifier}} var referenceObjects: Set { + return ARReferenceObject.referenceObjects(in: self) + } + #endif +} + +#if os(iOS) +@available(iOS 11.3, *) +{{accessModifier}} extension ARReferenceImage { + static func referenceImages(in asset: {{arResourceGroupType}}) -> Set { + let bundle = {{param.bundle|default:"BundleToken.bundle"}} + return referenceImages(inGroupNamed: asset.name, bundle: bundle) ?? Set() + } +} + +@available(iOS 12.0, *) +{{accessModifier}} extension ARReferenceObject { + static func referenceObjects(in asset: {{arResourceGroupType}}) -> Set { + let bundle = {{param.bundle|default:"BundleToken.bundle"}} + return referenceObjects(inGroupNamed: asset.name, bundle: bundle) ?? Set() + } +} +#endif +{% endif %} +{% if resourceCount.color > 0 %} + +{{accessModifier}} final class {{colorType}} { + {{accessModifier}} fileprivate(set) var name: String + + #if os(macOS) + {{accessModifier}} typealias Color = NSColor + #elseif os(iOS) || os(tvOS) || os(watchOS) + {{accessModifier}} typealias Color = UIColor + #endif + + @available(iOS 11.0, tvOS 11.0, watchOS 4.0, macOS 10.13, *) + {{accessModifier}} private(set) lazy var color: Color = Color(asset: self) + + #if os(iOS) || os(tvOS) + @available(iOS 11.0, tvOS 11.0, *) + {{accessModifier}} func color(compatibleWith traitCollection: UITraitCollection) -> Color { + let bundle = {{param.bundle|default:"BundleToken.bundle"}} + guard let color = Color(named: name, in: bundle, compatibleWith: traitCollection) else { + fatalError("Unable to load color asset named \(name).") + } + return color + } + #endif + + fileprivate init(name: String) { + self.name = name + } +} + +{{accessModifier}} extension {{colorType}}.Color { + @available(iOS 11.0, tvOS 11.0, watchOS 4.0, macOS 10.13, *) + convenience init!(asset: {{colorType}}) { + let bundle = {{param.bundle|default:"BundleToken.bundle"}} + #if os(iOS) || os(tvOS) + self.init(named: asset.name, in: bundle, compatibleWith: nil) + #elseif os(macOS) + self.init(named: NSColor.Name(asset.name), bundle: bundle) + #elseif os(watchOS) + self.init(named: asset.name) + #endif + } +} +{% endif %} +{% if resourceCount.data > 0 %} + +{{accessModifier}} struct {{dataType}} { + {{accessModifier}} fileprivate(set) var name: String + + @available(iOS 9.0, tvOS 9.0, watchOS 6.0, macOS 10.11, *) + {{accessModifier}} var data: NSDataAsset { + return NSDataAsset(asset: self) + } +} + +@available(iOS 9.0, tvOS 9.0, watchOS 6.0, macOS 10.11, *) +{{accessModifier}} extension NSDataAsset { + convenience init!(asset: {{dataType}}) { + let bundle = {{param.bundle|default:"BundleToken.bundle"}} + #if os(iOS) || os(tvOS) || os(watchOS) + self.init(name: asset.name, bundle: bundle) + #elseif os(macOS) + self.init(name: NSDataAsset.Name(asset.name), bundle: bundle) + #endif + } +} +{% endif %} +{% if resourceCount.image > 0 %} + +@objcMembers +{{accessModifier}} class {{imageType}}: NSObject { + {{accessModifier}} fileprivate(set) var name: String + + #if os(macOS) + {{accessModifier}} typealias Image = NSImage + #elseif os(iOS) || os(tvOS) || os(watchOS) + {{accessModifier}} typealias Image = UIImage + #endif + + @available(iOS 8.0, tvOS 9.0, watchOS 2.0, macOS 10.7, *) + {{accessModifier}} var image: Image { + let bundle = {{param.bundle|default:"BundleToken.bundle"}} + #if os(iOS) || os(tvOS) + let image = Image(named: name, in: bundle, compatibleWith: nil) + #elseif os(macOS) + let name = NSImage.Name(self.name) + let image = (bundle == .main) ? NSImage(named: name) : bundle.image(forResource: name) + #elseif os(watchOS) + let image = Image(named: name) + #endif + guard let result = image else { + fatalError("Unable to load image asset named \(name).") + } + return result + } + + {{accessModifier}} init(name: String) { + self.name = name + } + + #if os(iOS) || os(tvOS) + @available(iOS 8.0, tvOS 9.0, *) + {{accessModifier}} func image(compatibleWith traitCollection: UITraitCollection) -> Image { + let bundle = {{param.bundle|default:"BundleToken.bundle"}} + guard let result = Image(named: name, in: bundle, compatibleWith: traitCollection) else { + fatalError("Unable to load image asset named \(name).") + } + return result + } + #endif +} + +{{accessModifier}} extension {{imageType}}.Image { + @available(iOS 8.0, tvOS 9.0, watchOS 2.0, *) + @available(macOS, deprecated, + message: "This initializer is unsafe on macOS, please use the {{imageType}}.image property") + convenience init!(asset: {{imageType}}) { + #if os(iOS) || os(tvOS) + let bundle = {{param.bundle|default:"BundleToken.bundle"}} + self.init(named: asset.name, in: bundle, compatibleWith: nil) + #elseif os(macOS) + self.init(named: NSImage.Name(asset.name)) + #elseif os(watchOS) + self.init(named: asset.name) + #endif + } +} +{% endif %} +{% if resourceCount.symbol > 0 %} + +{{accessModifier}} struct {{symbolType}} { + {{accessModifier}} fileprivate(set) var name: String + + #if os(iOS) || os(tvOS) || os(watchOS) + @available(iOS 13.0, tvOS 13.0, watchOS 6.0, *) + {{accessModifier}} typealias Configuration = UIImage.SymbolConfiguration + {{accessModifier}} typealias Image = UIImage + + @available(iOS 12.0, tvOS 12.0, watchOS 5.0, *) + {{accessModifier}} var image: Image { + let bundle = {{param.bundle|default:"BundleToken.bundle"}} + #if os(iOS) || os(tvOS) + let image = Image(named: name, in: bundle, compatibleWith: nil) + #elseif os(watchOS) + let image = Image(named: name) + #endif + guard let result = image else { + fatalError("Unable to load symbol asset named \(name).") + } + return result + } + + @available(iOS 13.0, tvOS 13.0, watchOS 6.0, *) + {{accessModifier}} func image(with configuration: Configuration) -> Image { + let bundle = {{param.bundle|default:"BundleToken.bundle"}} + guard let result = Image(named: name, in: bundle, with: configuration) else { + fatalError("Unable to load symbol asset named \(name).") + } + return result + } + #endif +} +{% endif %} +{% if not param.bundle %} + +// swiftlint:disable convenience_type +private final class BundleToken { + static let bundle: Bundle = { + #if SWIFT_PACKAGE + return Bundle.module + #else + return Bundle(for: BundleToken.self) + #endif + }() +} +// swiftlint:enable convenience_type +{% endif %} +{% else %} +// No assets found +{% endif %} + diff --git a/Tools/SwiftGen/swiftgen-config.yml b/Tools/SwiftGen/swiftgen-config.yml index 3d1cd6693..a561f43ae 100755 --- a/Tools/SwiftGen/swiftgen-config.yml +++ b/Tools/SwiftGen/swiftgen-config.yml @@ -28,7 +28,7 @@ xcassets: - Assets/Images.xcassets - Assets/SharedImages.xcassets outputs: - templateName: swift4 + templatePath: Templates/Assets/swift4-element.stencil output: Images.swift plist: inputs: Assets/Riot-Defaults.plist diff --git a/changelog.d/pr-5533.misc b/changelog.d/pr-5533.misc new file mode 100644 index 000000000..6ba114e65 --- /dev/null +++ b/changelog.d/pr-5533.misc @@ -0,0 +1 @@ +SwiftGen: Objective-C support for assets helpers