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 <arnaud.ringenbach@niji.fr>
This commit is contained in:
aringenbach
2022-02-10 17:13:23 +01:00
committed by GitHub
parent f14147c840
commit 7964d314c8
46 changed files with 504 additions and 155 deletions

View File

@@ -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)];

View File

@@ -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;

View File

@@ -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

View File

@@ -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

View File

@@ -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];

View File

@@ -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;
}
}

View File

@@ -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];
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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];

View File

@@ -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)

View File

@@ -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

View File

@@ -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];
}

View File

@@ -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;
}
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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

View File

@@ -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];
}

View File

@@ -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;
}
}

View File

@@ -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;
}

View File

@@ -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]);

View File

@@ -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

View File

@@ -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;
}
}

View File

@@ -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];

View File

@@ -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)

View File

@@ -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];

View File

@@ -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

View File

@@ -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;

View File

@@ -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;
}
}

View File

@@ -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;

View File

@@ -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

View File

@@ -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)
{

View File

@@ -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];
}

View File

@@ -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];
}

View File

@@ -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;
}
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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];

View File

@@ -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];

View File

@@ -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];

View File

@@ -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];

View File

@@ -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

View File

@@ -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<ARReferenceImage> {
return ARReferenceImage.referenceImages(in: self)
}
@available(iOS 12.0, *)
{{accessModifier}} var referenceObjects: Set<ARReferenceObject> {
return ARReferenceObject.referenceObjects(in: self)
}
#endif
}
#if os(iOS)
@available(iOS 11.3, *)
{{accessModifier}} extension ARReferenceImage {
static func referenceImages(in asset: {{arResourceGroupType}}) -> Set<ARReferenceImage> {
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<ARReferenceObject> {
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 %}

View File

@@ -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

1
changelog.d/pr-5533.misc Normal file
View File

@@ -0,0 +1 @@
SwiftGen: Objective-C support for assets helpers