Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T365175 #4921

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

T365175 #4921

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ final class InsertMediaAdvancedSettingsViewController: ViewController {
private let tableView = UITableView()

typealias AdvancedSettings = InsertMediaSettings.Advanced

var isRTL: Bool?

var advancedSettings: AdvancedSettings {
return AdvancedSettings(wrapTextAroundImage: textWrappingSwitch.isOn, imagePosition: imagePositionSettingsViewController.selectedImagePosition(isTextWrappingEnabled: textWrappingSwitch.isOn), imageType: imageTypeSettingsViewController.selectedImageType, imageSize: imageSizeSettingsViewController.selectedImageSize)
return AdvancedSettings(wrapTextAroundImage: textWrappingSwitch.isOn, imagePosition: imagePositionSettingsViewController.selectedImagePosition(isTextWrappingEnabled: textWrappingSwitch.isOn, isRTL: isRTL), imageType: imageTypeSettingsViewController.selectedImageType, imageSize: imageSizeSettingsViewController.selectedImageSize)
}

struct ViewModel {
Expand Down Expand Up @@ -43,7 +45,7 @@ final class InsertMediaAdvancedSettingsViewController: ViewController {

private var viewModels: [ViewModel] {
let textWrappingViewModel = ViewModel(title: WMFLocalizedString("insert-media-image-text-wrapping-setting", value: "Wrap text around image", comment: "Title for image setting that wraps text around image"), accessoryView: textWrappingSwitch, accessoryType: .none, selectionStyle: .none)
let imagePositionViewModel = ViewModel(title: AdvancedSettings.ImagePosition.displayTitle, detailText: imagePositionSettingsViewController.selectedImagePosition(isTextWrappingEnabled: textWrappingSwitch.isOn).displayTitle, isEnabled: textWrappingSwitch.isOn) { [weak self] in
let imagePositionViewModel = ViewModel(title: AdvancedSettings.ImagePosition.displayTitle, detailText: imagePositionSettingsViewController.selectedImagePosition(isTextWrappingEnabled: textWrappingSwitch.isOn, isRTL: isRTL).displayTitle, isEnabled: textWrappingSwitch.isOn) { [weak self] in
guard let self = self else {
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ final class InsertMediaImagePositionSettingsViewController: ViewController {

typealias ImagePosition = InsertMediaSettings.Advanced.ImagePosition

func selectedImagePosition(isTextWrappingEnabled: Bool) -> ImagePosition {
func selectedImagePosition(isTextWrappingEnabled: Bool, isRTL: Bool?) -> ImagePosition {
guard isTextWrappingEnabled else {
return .none
}
guard let selectedIndexPath = selectedIndexPath else {
return .right
guard let selectedIndexPath = selectedIndexPath, isRTL != nil else {
if isRTL! {
return .left
} else {
return .right
}
}
return viewModels[selectedIndexPath.row].imagePosition
}
Expand Down
3 changes: 2 additions & 1 deletion Wikipedia/Code/InsertMediaSettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,15 @@ final class InsertMediaSettingsViewController: ViewController {

private lazy var buttonView: InsertMediaSettingsButtonView = {
let buttonView = InsertMediaSettingsButtonView.wmf_viewFromClassNib()!
let isRTL = UIApplication.shared.wmf_isRTL
let isRTL = MWKLanguageLinkController.isLanguageRTL(forContentLanguageCode: siteURL.wmf_contentLanguageCode)
buttonView.buttonTitle = InsertMediaAdvancedSettingsViewController.title
buttonView.buttonAction = { [weak self] _ in
guard let self = self else {
return
}
imageRecLoggingDelegate?.logInsertMediaSettingsViewControllerDidTapAdvancedSettings()
self.insertMediaAdvancedSettingsViewController.apply(theme: self.theme)
self.insertMediaAdvancedSettingsViewController.isRTL = isRTL
self.navigationController?.pushViewController(self.insertMediaAdvancedSettingsViewController, animated: true)
}
return buttonView
Expand Down