Skip to content

Commit

Permalink
Always show advanced audio options button (#556)
Browse files Browse the repository at this point in the history
Co-authored-by: Zubair Khan <zubair.k.khan@oracle.com>
  • Loading branch information
zukhan and Zubair Khan authored Aug 4, 2023
1 parent e550546 commit 0ce799e
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Features/AudioBannerFeature/AudioBannerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ final class AudioBannerViewController: UIViewController, AdvancedAudioOptionsLis
private func setUpReciterView() {
reciterView.playButton.addTarget(self, action: #selector(reciterPlayTapped), for: .touchUpInside)
reciterView.backgroundButton.addTarget(self, action: #selector(reciterTapped), for: .touchUpInside)
reciterView.moreButton?.addTarget(self, action: #selector(showAdvancedAudioOptionsNotPlaying), for: .touchUpInside)
reciterView.backgroundButton.accessibilityLabel = "Reciter banner"
}

Expand Down Expand Up @@ -283,6 +284,16 @@ final class AudioBannerViewController: UIViewController, AdvancedAudioOptionsLis
present(viewController, animated: true)
}

@objc
private func showAdvancedAudioOptionsNotPlaying() {
logger.info("AudioBanner: more button tapped. State: \(viewModel.playingState)")
guard let options = viewModel.advancedAudioOptionsNotPlaying else {
return
}
let viewController = advancedAudioOptionsBuilder.build(withListener: self, options: options)
present(viewController, animated: true)
}

private func presentReciterList(_ viewController: UIViewController) {
let reciterNavigation = ReciterNavigationController(rootViewController: viewController)
present(reciterNavigation, animated: true, completion: nil)
Expand Down
12 changes: 12 additions & 0 deletions Features/AudioBannerFeature/AudioBannerViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ public final class AudioBannerViewModel: RemoteCommandsHandlerDelegate {

@Published var playingState: PlaybackState = .stopped

var advancedAudioOptionsNotPlaying: AdvancedAudioOptions? {
setAudioRangeForCurrentPage()
return advancedAudioOptions
}

var advancedAudioOptions: AdvancedAudioOptions? {
guard let audioRange, let selectedReciter else {
return nil
Expand Down Expand Up @@ -266,6 +271,13 @@ public final class AudioBannerViewModel: RemoteCommandsHandlerDelegate {
play(from: currentPage.firstVerse, to: nil, verseRuns: .one, listRuns: .one)
}

private func setAudioRangeForCurrentPage() {
guard let currentPage = listener?.visiblePages.min() else { return }
let from = currentPage.firstVerse
let end = lastAyahFinder.findLastAyah(startAyah: from)
audioRange = (start: from, end: end)
}

private func play(from: AyahNumber, to: AyahNumber?, verseRuns: Runs, listRuns: Runs) {
guard let selectedReciter else {
return
Expand Down
1 change: 1 addition & 0 deletions Features/AudioBannerFeature/AudioReciterBarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class AudioReciterBarView: UIView {
@IBOutlet var imageView: UIImageView!
@IBOutlet var titleLabel: UILabel!
@IBOutlet var playButton: UIButton!
@IBOutlet var moreButton: UIButton!
@IBOutlet var backgroundButton: BackgroundColorButton!

// MARK: Private
Expand Down
16 changes: 16 additions & 0 deletions Features/AudioBannerFeature/AudioReciterBarView.xib
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<outlet property="backgroundButton" destination="VB4-iz-Fjs" id="lop-5B-pCU"/>
<outlet property="imageView" destination="dTH-Zk-EFD" id="t7O-4g-8tS"/>
<outlet property="playButton" destination="sZU-5A-szn" id="8mv-3G-2gd"/>
<outlet property="moreButton" destination="cc9-iX-UuJ" id="mZT-Sl-flO"/>
<outlet property="titleLabel" destination="mwa-kP-uKG" id="C4O-P4-UVz"/>
</connections>
</placeholder>
Expand Down Expand Up @@ -68,27 +69,42 @@
<inset key="contentEdgeInsets" minX="4" minY="4" maxX="4" maxY="4"/>
<state key="normal" image="play.fill" catalog="system"/>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="cc9-iX-UuJ">
<rect key="frame" x="536" y="0.0" width="44" height="44"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="44" id="7P3-j1-Frt"/>
</constraints>
<inset key="contentEdgeInsets" minX="4" minY="4" maxX="4" maxY="4"/>
<state key="normal" image="ellipsis.circle" catalog="system">
<preferredSymbolConfiguration key="preferredSymbolConfiguration" scale="large"/>
</state>
</button>
</subviews>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="VB4-iz-Fjs" firstAttribute="top" secondItem="To9-r8-ZrW" secondAttribute="top" id="1sw-so-q9C"/>
<constraint firstItem="iN0-l3-epB" firstAttribute="trailing" relation="lessThanOrEqual" secondItem="cc9-iX-UuJ" secondAttribute="leading" constant="5" id="4Sh-hl-lme"/>
<constraint firstItem="iN0-l3-epB" firstAttribute="centerX" secondItem="To9-r8-ZrW" secondAttribute="centerX" id="Ai9-5S-J7O"/>
<constraint firstItem="iN0-l3-epB" firstAttribute="top" secondItem="To9-r8-ZrW" secondAttribute="top" id="E7m-cK-JGi"/>
<constraint firstAttribute="bottom" secondItem="VB4-iz-Fjs" secondAttribute="bottom" id="F1u-zd-t6X"/>
<constraint firstAttribute="trailing" secondItem="VB4-iz-Fjs" secondAttribute="trailing" id="GDa-vB-b5v"/>
<constraint firstAttribute="bottomMargin" secondItem="iN0-l3-epB" secondAttribute="bottom" id="Nap-ZR-aQy"/>
<constraint firstItem="iN0-l3-epB" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="sZU-5A-szn" secondAttribute="trailing" constant="5" id="Pep-e7-dah"/>
<constraint firstAttribute="bottomMargin" secondItem="cc9-iX-UuJ" secondAttribute="bottom" id="aFy-bF-NaQ"/>
<constraint firstItem="sZU-5A-szn" firstAttribute="leading" secondItem="To9-r8-ZrW" secondAttribute="leadingMargin" id="dKI-iY-cxG"/>
<constraint firstItem="sZU-5A-szn" firstAttribute="top" secondItem="To9-r8-ZrW" secondAttribute="top" id="eqZ-Na-FhW"/>
<constraint firstItem="cc9-iX-UuJ" firstAttribute="top" secondItem="To9-r8-ZrW" secondAttribute="top" id="hl9-zY-59U"/>
<constraint firstItem="VB4-iz-Fjs" firstAttribute="leading" secondItem="To9-r8-ZrW" secondAttribute="leading" id="nse-7O-nlO"/>
<constraint firstAttribute="bottomMargin" secondItem="sZU-5A-szn" secondAttribute="bottom" id="s0f-rK-lE3"/>
<constraint firstItem="cc9-iX-UuJ" firstAttribute="trailing" secondItem="To9-r8-ZrW" secondAttribute="trailingMargin" id="w5H-7B-4be"/>
</constraints>
<nil key="simulatedStatusBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<point key="canvasLocation" x="391" y="253"/>
</view>
</objects>
<resources>
<image name="ellipsis.circle" catalog="system" width="128" height="123"/>
<image name="play.fill" catalog="system" width="117" height="128"/>
<systemColor name="systemGray4Color">
<color red="0.81960784313725488" green="0.81960784313725488" blue="0.83921568627450982" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
Expand Down

0 comments on commit 0ce799e

Please sign in to comment.