From 93118b4e797a3d021d0a7c082d2229468581aa62 Mon Sep 17 00:00:00 2001 From: Cam McLeod Date: Tue, 16 Jul 2019 09:21:18 -0700 Subject: [PATCH 1/5] logo share view completed changed share track so 'I'm listening to \(currentStation.name) via Swift Radio Pro' is now a subtitle in a watermarked image with the album art, artist and song name to share" --- SwiftRadio.xcodeproj/project.pbxproj | 12 +++- SwiftRadio/LogoShareView.swift | 36 +++++++++++ SwiftRadio/LogoShareView.xib | 79 +++++++++++++++++++++++ SwiftRadio/NowPlayingViewController.swift | 34 +++++++--- 4 files changed, 150 insertions(+), 11 deletions(-) create mode 100644 SwiftRadio/LogoShareView.swift create mode 100644 SwiftRadio/LogoShareView.xib diff --git a/SwiftRadio.xcodeproj/project.pbxproj b/SwiftRadio.xcodeproj/project.pbxproj index 0fd78a45..64049799 100644 --- a/SwiftRadio.xcodeproj/project.pbxproj +++ b/SwiftRadio.xcodeproj/project.pbxproj @@ -36,6 +36,8 @@ 5F22BA551F72AD5A00CB5911 /* AutoTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F22BA3A1F72AD5800CB5911 /* AutoTextView.swift */; }; 5F22BA561F72AD5A00CB5911 /* DesignableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F22BA3B1F72AD5900CB5911 /* DesignableView.swift */; }; 5FDEE0221F72FF980064333C /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5FDEE0211F72FF980064333C /* LaunchScreen.storyboard */; }; + 6258DCD822D93A3500166C65 /* LogoShareView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6258DCD722D93A3500166C65 /* LogoShareView.swift */; }; + 6258DCDA22D93A5400166C65 /* LogoShareView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6258DCD922D93A5400166C65 /* LogoShareView.xib */; }; 81AD229B21646DEA002ADFDD /* FRadioPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81AD229821646DEA002ADFDD /* FRadioPlayer.swift */; }; 81AD229C21646DEA002ADFDD /* FRadioAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81AD229921646DEA002ADFDD /* FRadioAPI.swift */; }; 81AD229D21646DEA002ADFDD /* Reachability.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81AD229A21646DEA002ADFDD /* Reachability.swift */; }; @@ -105,6 +107,8 @@ 5F22BA3A1F72AD5800CB5911 /* AutoTextView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutoTextView.swift; sourceTree = ""; }; 5F22BA3B1F72AD5900CB5911 /* DesignableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DesignableView.swift; sourceTree = ""; }; 5FDEE0211F72FF980064333C /* LaunchScreen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = ""; }; + 6258DCD722D93A3500166C65 /* LogoShareView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogoShareView.swift; sourceTree = ""; }; + 6258DCD922D93A5400166C65 /* LogoShareView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = LogoShareView.xib; sourceTree = ""; }; 81AD229821646DEA002ADFDD /* FRadioPlayer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FRadioPlayer.swift; sourceTree = ""; }; 81AD229921646DEA002ADFDD /* FRadioAPI.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FRadioAPI.swift; sourceTree = ""; }; 81AD229A21646DEA002ADFDD /* Reachability.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Reachability.swift; sourceTree = ""; }; @@ -274,6 +278,8 @@ 94D1D0A41AD6D6230022CA11 /* InfoDetailViewController.swift */, 94452E4E1AD6F24700BFE7A5 /* PopUpMenuViewController.swift */, 9409E13F1ABF78B000312E2B /* NowPlayingViewController.swift */, + 6258DCD722D93A3500166C65 /* LogoShareView.swift */, + 6258DCD922D93A5400166C65 /* LogoShareView.xib */, 942A3F361AE43DF80011396E /* StationsViewController.swift */, ); name = ViewControllers; @@ -373,7 +379,7 @@ }; 9409E1151ABF6FEA00312E2B = { CreatedOnToolsVersion = 6.2; - DevelopmentTeam = G24WJ3XCZ3; + DevelopmentTeam = 79VHH58USY; LastSwiftMigration = 1020; SystemCapabilities = { com.apple.BackgroundModes = { @@ -417,6 +423,7 @@ files = ( 945DB3C21AD58E3A00495EBB /* stations.json in Resources */, 945DB3C51AD5A6E200495EBB /* NothingFoundCell.xib in Resources */, + 6258DCDA22D93A5400166C65 /* LogoShareView.xib in Resources */, CF72ACE721F7155200461EED /* Main.storyboard in Resources */, 5FDEE0221F72FF980064333C /* LaunchScreen.storyboard in Resources */, 9409E1261ABF6FEA00312E2B /* Images.xcassets in Resources */, @@ -454,6 +461,7 @@ 94D1D0A51AD6D6230022CA11 /* InfoDetailViewController.swift in Sources */, 5F22BA4B1F72AD5A00CB5911 /* KeyboardLayoutConstraint.swift in Sources */, 5F22BA421F72AD5A00CB5911 /* SoundPlayer.swift in Sources */, + 6258DCD822D93A3500166C65 /* LogoShareView.swift in Sources */, 5F22BA4A1F72AD5A00CB5911 /* DesignableTextView.swift in Sources */, 949BBB401ACC9DEE005B7C26 /* DataManager.swift in Sources */, 5F22BA4E1F72AD5A00CB5911 /* Misc.swift in Sources */, @@ -639,6 +647,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = 79VHH58USY; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/SwiftRadio", @@ -662,6 +671,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = 79VHH58USY; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/SwiftRadio", diff --git a/SwiftRadio/LogoShareView.swift b/SwiftRadio/LogoShareView.swift new file mode 100644 index 00000000..c336c47b --- /dev/null +++ b/SwiftRadio/LogoShareView.swift @@ -0,0 +1,36 @@ +// +// LogoShareView.swift +// SwiftRadio +// +// Created by Cameron Mcleod on 2019-07-12. +// Copyright © 2019 matthewfecher.com. All rights reserved. +// + +import UIKit + +class LogoShareView: UIView { + + @IBOutlet weak var albumArt: UIImageView! + @IBOutlet weak var radioShoutoutLabel: UILabel! + @IBOutlet weak var trackTitleLabel: UILabel! + @IBOutlet weak var trackArtistLabel: UILabel! + @IBOutlet weak var logoImageView: UIImageView! + + /* + // Only override draw() if you perform custom drawing. + // An empty implementation adversely affects performance during animation. + override func draw(_ rect: CGRect) { + // Drawing code + } + */ + + func shareSetup(albumArt : UIImage, radioShoutout: String, trackTitle: String, trackArtist: String) { + + self.albumArt.image = albumArt + self.radioShoutoutLabel.text = radioShoutout + self.trackTitleLabel.text = trackTitle + self.trackArtistLabel.text = trackArtist + self.logoImageView.image = UIImage(named: "logo") + } + +} diff --git a/SwiftRadio/LogoShareView.xib b/SwiftRadio/LogoShareView.xib new file mode 100644 index 00000000..e61295ae --- /dev/null +++ b/SwiftRadio/LogoShareView.xib @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SwiftRadio/NowPlayingViewController.swift b/SwiftRadio/NowPlayingViewController.swift index eff18a65..1554744c 100644 --- a/SwiftRadio/NowPlayingViewController.swift +++ b/SwiftRadio/NowPlayingViewController.swift @@ -347,17 +347,31 @@ class NowPlayingViewController: UIViewController { } @IBAction func shareButtonPressed(_ sender: UIButton) { - let songToShare = "I'm listening to \(currentTrack.title) on \(currentStation.name) via Swift Radio Pro" - let activityViewController = UIActivityViewController(activityItems: [songToShare, currentTrack.artworkImage!], applicationActivities: nil) - activityViewController.popoverPresentationController?.sourceRect = CGRect(x: view.center.x, y: view.center.y, width: 0, height: 0) - activityViewController.popoverPresentationController?.sourceView = view - activityViewController.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0) - - activityViewController.completionWithItemsHandler = {(activityType: UIActivity.ActivityType?, completed:Bool, returnedItems:[Any]?, error: Error?) in - if completed { - // do something on completion if you want + + let songToShare = "I'm listening to \(currentStation.name) via Swift Radio Pro" + let shareImage : UIImage? + if let objects = Bundle.main.loadNibNamed("LogoShareView", owner: nil, options: [:]), let getView = objects.first { + + if let logoShare = getView as? LogoShareView { + logoShare.shareSetup(albumArt: currentTrack.artworkImage!, radioShoutout: songToShare, trackTitle: currentTrack.title, trackArtist: currentTrack.artist) + UIGraphicsBeginImageContextWithOptions(CGSize(width: logoShare.frame.width, height: logoShare.frame.height), true, 0) + logoShare.drawHierarchy(in: logoShare.frame, afterScreenUpdates: true) + shareImage = UIGraphicsGetImageFromCurrentImageContext() + UIGraphicsEndImageContext(); + + + let activityViewController = UIActivityViewController(activityItems: [shareImage!], applicationActivities: nil) + activityViewController.popoverPresentationController?.sourceRect = CGRect(x: view.center.x, y: view.center.y, width: 0, height: 0) + activityViewController.popoverPresentationController?.sourceView = view + activityViewController.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0) + + activityViewController.completionWithItemsHandler = {(activityType: UIActivity.ActivityType?, completed:Bool, returnedItems:[Any]?, error: Error?) in + if completed { + // do something on completion if you want + } + } + present(activityViewController, animated: true, completion: nil) } } - present(activityViewController, animated: true, completion: nil) } } From 65323c92551ed6bf398131a5e03f9e76848ca49b Mon Sep 17 00:00:00 2001 From: Cam McLeod Date: Wed, 7 Aug 2019 12:06:41 -0700 Subject: [PATCH 2/5] changed labels so long song names clip to two lines --- SwiftRadio/LogoShareView.xib | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SwiftRadio/LogoShareView.xib b/SwiftRadio/LogoShareView.xib index e61295ae..09c27c6b 100644 --- a/SwiftRadio/LogoShareView.xib +++ b/SwiftRadio/LogoShareView.xib @@ -28,13 +28,13 @@ -