diff --git a/Demo/Assets.xcassets/AppIcon.appiconset/Contents.json b/Demo/Assets.xcassets/AppIcon.appiconset/Contents.json index a324f8c..9dd60fd 100644 --- a/Demo/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/Demo/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -1,5 +1,15 @@ { "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, { "idiom" : "iphone", "size" : "29x29", @@ -32,6 +42,16 @@ "filename" : "180.png", "scale" : "3x" }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, { "idiom" : "ipad", "size" : "29x29", diff --git a/Demo/DemoListViewController.swift b/Demo/DemoListViewController.swift index 93bae8b..3c6638f 100644 --- a/Demo/DemoListViewController.swift +++ b/Demo/DemoListViewController.swift @@ -29,6 +29,7 @@ class DemoListViewController: UITableViewController, NohanaImagePickerController Cell(title: "Large thumbnail", selector: #selector(DemoListViewController.showLargeThumbnailPicker)), Cell(title: "No toolbar", selector: #selector(DemoListViewController.showNoToolbarPicker)), Cell(title: "Disable to pick assets", selector: #selector(DemoListViewController.showDisableToPickAssetsPicker)), + Cell(title: "Custom UI", selector: #selector(DemoListViewController.showCustomUIPicker)), ] override func viewDidAppear(_ animated: Bool) { @@ -38,6 +39,10 @@ class DemoListViewController: UITableViewController, NohanaImagePickerController } } + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + } + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return cells.count } @@ -60,8 +65,6 @@ class DemoListViewController: UITableViewController, NohanaImagePickerController } }) } - - } // MARK: - Photos @@ -123,6 +126,18 @@ class DemoListViewController: UITableViewController, NohanaImagePickerController present(picker, animated: true, completion: nil) } + @objc + func showCustomUIPicker() { + let picker = NohanaImagePickerController() + picker.delegate = self + picker.config.color.background = UIColor(red: 0xcc/0xff, green: 0xff/0xff, blue: 0xff/0xff, alpha: 1) + picker.config.color.separator = UIColor(red: 0x00/0xff, green: 0x66/0xff, blue: 0x66/0xff, alpha: 1) + picker.config.strings.albumListTitle = "🏞" + picker.config.image.droppedSmall = UIImage(named: "btn_select_m") + picker.config.image.pickedSmall = UIImage(named: "btn_selected_m") + present(picker, animated: true, completion: nil) + } + // MARK: - NohanaImagePickerControllerDelegate func nohanaImagePickerDidCancel(_ picker: NohanaImagePickerController) { diff --git a/NohanaImagePicker/Images.xcassets/Contents.json b/Demo/Resources/NohanaImagePicker.xcassets/Contents.json similarity index 100% rename from NohanaImagePicker/Images.xcassets/Contents.json rename to Demo/Resources/NohanaImagePicker.xcassets/Contents.json diff --git a/NohanaImagePicker/Images.xcassets/btn_select_m.imageset/Contents.json b/Demo/Resources/NohanaImagePicker.xcassets/btn_select_m.imageset/Contents.json similarity index 100% rename from NohanaImagePicker/Images.xcassets/btn_select_m.imageset/Contents.json rename to Demo/Resources/NohanaImagePicker.xcassets/btn_select_m.imageset/Contents.json diff --git a/Demo/Resources/NohanaImagePicker.xcassets/btn_select_m.imageset/btn_select_m@2x.png b/Demo/Resources/NohanaImagePicker.xcassets/btn_select_m.imageset/btn_select_m@2x.png new file mode 100644 index 0000000..48313b8 Binary files /dev/null and b/Demo/Resources/NohanaImagePicker.xcassets/btn_select_m.imageset/btn_select_m@2x.png differ diff --git a/Demo/Resources/NohanaImagePicker.xcassets/btn_select_m.imageset/btn_select_m@3x.png b/Demo/Resources/NohanaImagePicker.xcassets/btn_select_m.imageset/btn_select_m@3x.png new file mode 100644 index 0000000..d80368e Binary files /dev/null and b/Demo/Resources/NohanaImagePicker.xcassets/btn_select_m.imageset/btn_select_m@3x.png differ diff --git a/NohanaImagePicker/Images.xcassets/btn_selected_m.imageset/Contents.json b/Demo/Resources/NohanaImagePicker.xcassets/btn_selected_m.imageset/Contents.json similarity index 100% rename from NohanaImagePicker/Images.xcassets/btn_selected_m.imageset/Contents.json rename to Demo/Resources/NohanaImagePicker.xcassets/btn_selected_m.imageset/Contents.json diff --git a/Demo/Resources/NohanaImagePicker.xcassets/btn_selected_m.imageset/btn_selected_m@2x.png b/Demo/Resources/NohanaImagePicker.xcassets/btn_selected_m.imageset/btn_selected_m@2x.png new file mode 100644 index 0000000..418c397 Binary files /dev/null and b/Demo/Resources/NohanaImagePicker.xcassets/btn_selected_m.imageset/btn_selected_m@2x.png differ diff --git a/Demo/Resources/NohanaImagePicker.xcassets/btn_selected_m.imageset/btn_selected_m@3x.png b/Demo/Resources/NohanaImagePicker.xcassets/btn_selected_m.imageset/btn_selected_m@3x.png new file mode 100644 index 0000000..1a45974 Binary files /dev/null and b/Demo/Resources/NohanaImagePicker.xcassets/btn_selected_m.imageset/btn_selected_m@3x.png differ diff --git a/NohanaImagePicker.podspec b/NohanaImagePicker.podspec index c08ce5c..18bb70e 100644 --- a/NohanaImagePicker.podspec +++ b/NohanaImagePicker.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'NohanaImagePicker' - s.version = '0.7.1' + s.version = '0.8.0' s.summary = 'A multiple image picker for iOS app.' s.homepage = 'https://github.com/nohana/NohanaImagePicker' s.license = { :type => 'Apache License v2', :file => 'LICENSE' } diff --git a/NohanaImagePicker.xcodeproj/project.pbxproj b/NohanaImagePicker.xcodeproj/project.pbxproj index 5acaff1..895cc51 100644 --- a/NohanaImagePicker.xcodeproj/project.pbxproj +++ b/NohanaImagePicker.xcodeproj/project.pbxproj @@ -7,7 +7,7 @@ objects = { /* Begin PBXBuildFile section */ - F202573A1C7343D20069B33A /* ImageName.swift in Sources */ = {isa = PBXBuildFile; fileRef = F20257391C7343D20069B33A /* ImageName.swift */; }; + 3569CAA91EC1918E000C41C0 /* NohanaImagePicker.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3569CAA61EC1918E000C41C0 /* NohanaImagePicker.xcassets */; }; F202573C1C7418920069B33A /* PickedAssetList.swift in Sources */ = {isa = PBXBuildFile; fileRef = F202573B1C7418920069B33A /* PickedAssetList.swift */; }; F208E5541CD7370B00FFC9F6 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F208E5531CD7370B00FFC9F6 /* AppDelegate.swift */; }; F208E5591CD7370B00FFC9F6 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F208E5571CD7370B00FFC9F6 /* Main.storyboard */; }; @@ -21,14 +21,13 @@ F218D7DE1C6C3A5B001FCED1 /* AlbumCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F218D7DD1C6C3A5B001FCED1 /* AlbumCell.swift */; }; F23554261C69D19C00796DCA /* NohanaImagePicker.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F23554251C69D19C00796DCA /* NohanaImagePicker.storyboard */; }; F23554281C69D5DB00796DCA /* NohanaImagePickerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F23554271C69D5DB00796DCA /* NohanaImagePickerController.swift */; }; - F237249B1C6DCF96005D1E8A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F237249A1C6DCF96005D1E8A /* Images.xcassets */; }; + F237249B1C6DCF96005D1E8A /* NohanaImagePicker.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F237249A1C6DCF96005D1E8A /* NohanaImagePicker.xcassets */; }; F23CC89E1CB745C800BCE443 /* ActivityIndicatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = F23CC89D1CB745C800BCE443 /* ActivityIndicatable.swift */; }; F24EB6901C68AEED0002EC86 /* AlbumListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F24EB68F1C68AEED0002EC86 /* AlbumListViewController.swift */; }; F25C10C21C8ED9BF007453C3 /* MomentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F25C10C11C8ED9BF007453C3 /* MomentViewController.swift */; }; F25C69881CA23A0A005935D6 /* MomentCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F25C69871CA23A0A005935D6 /* MomentCell.swift */; }; F25C69901CA27311005935D6 /* EmptyIndicatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = F25C698F1CA27311005935D6 /* EmptyIndicatable.swift */; }; F25C69921CA28728005935D6 /* AlbumListEmptyIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = F25C69911CA28728005935D6 /* AlbumListEmptyIndicator.swift */; }; - F25C699B1CA2B79A005935D6 /* ColorConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = F25C699A1CA2B79A005935D6 /* ColorConfig.swift */; }; F26775DE1C701FA7002E786C /* ItemList.swift in Sources */ = {isa = PBXBuildFile; fileRef = F26775DD1C701FA7002E786C /* ItemList.swift */; }; F26775E11C7046C7002E786C /* ExpandingAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F26775E01C7046C7002E786C /* ExpandingAnimationController.swift */; }; F26775E51C70574F002E786C /* AnimatableNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F26775E41C70574F002E786C /* AnimatableNavigationController.swift */; }; @@ -71,7 +70,8 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - F20257391C7343D20069B33A /* ImageName.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageName.swift; sourceTree = ""; }; + 3569CAA61EC1918E000C41C0 /* NohanaImagePicker.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = NohanaImagePicker.xcassets; sourceTree = ""; }; + 3590F1F51EC1A79400F32E06 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/NohanaImagePicker.strings; sourceTree = ""; }; F202573B1C7418920069B33A /* PickedAssetList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PickedAssetList.swift; sourceTree = ""; }; F208E5511CD7370B00FFC9F6 /* Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Demo.app; sourceTree = BUILT_PRODUCTS_DIR; }; F208E5531CD7370B00FFC9F6 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; @@ -85,14 +85,13 @@ F218D7DD1C6C3A5B001FCED1 /* AlbumCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AlbumCell.swift; sourceTree = ""; }; F23554251C69D19C00796DCA /* NohanaImagePicker.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = NohanaImagePicker.storyboard; sourceTree = ""; }; F23554271C69D5DB00796DCA /* NohanaImagePickerController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NohanaImagePickerController.swift; sourceTree = ""; }; - F237249A1C6DCF96005D1E8A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; + F237249A1C6DCF96005D1E8A /* NohanaImagePicker.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = NohanaImagePicker.xcassets; sourceTree = ""; }; F23CC89D1CB745C800BCE443 /* ActivityIndicatable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActivityIndicatable.swift; sourceTree = ""; }; F24EB68F1C68AEED0002EC86 /* AlbumListViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AlbumListViewController.swift; sourceTree = ""; }; F25C10C11C8ED9BF007453C3 /* MomentViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MomentViewController.swift; sourceTree = ""; }; F25C69871CA23A0A005935D6 /* MomentCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MomentCell.swift; sourceTree = ""; }; F25C698F1CA27311005935D6 /* EmptyIndicatable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EmptyIndicatable.swift; sourceTree = ""; }; F25C69911CA28728005935D6 /* AlbumListEmptyIndicator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AlbumListEmptyIndicator.swift; sourceTree = ""; }; - F25C699A1CA2B79A005935D6 /* ColorConfig.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ColorConfig.swift; sourceTree = ""; }; F26775DD1C701FA7002E786C /* ItemList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ItemList.swift; sourceTree = ""; }; F26775E01C7046C7002E786C /* ExpandingAnimationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExpandingAnimationController.swift; sourceTree = ""; }; F26775E41C70574F002E786C /* AnimatableNavigationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnimatableNavigationController.swift; sourceTree = ""; }; @@ -132,9 +131,18 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 3569CAA31EC1918E000C41C0 /* Resources */ = { + isa = PBXGroup; + children = ( + 3569CAA61EC1918E000C41C0 /* NohanaImagePicker.xcassets */, + ); + path = Resources; + sourceTree = ""; + }; F208E5521CD7370B00FFC9F6 /* Demo */ = { isa = PBXGroup; children = ( + 3569CAA31EC1918E000C41C0 /* Resources */, F208E5531CD7370B00FFC9F6 /* AppDelegate.swift */, F208E5681CD738CD00FFC9F6 /* DemoListViewController.swift */, F208E5571CD7370B00FFC9F6 /* Main.storyboard */, @@ -163,7 +171,7 @@ children = ( F23554251C69D19C00796DCA /* NohanaImagePicker.storyboard */, F27029CD1C71C43A001647AB /* NohanaImagePicker.strings */, - F237249A1C6DCF96005D1E8A /* Images.xcassets */, + F237249A1C6DCF96005D1E8A /* NohanaImagePicker.xcassets */, ); name = Resources; sourceTree = ""; @@ -194,12 +202,10 @@ children = ( F26775DD1C701FA7002E786C /* ItemList.swift */, F202573B1C7418920069B33A /* PickedAssetList.swift */, - F20257391C7343D20069B33A /* ImageName.swift */, F26775E71C7073CD002E786C /* Size.swift */, F2DA29761C7749D600B0A8E3 /* NotificationInfo.swift */, F25C698F1CA27311005935D6 /* EmptyIndicatable.swift */, F23CC89D1CB745C800BCE443 /* ActivityIndicatable.swift */, - F25C699A1CA2B79A005935D6 /* ColorConfig.swift */, ); name = Common; sourceTree = ""; @@ -328,6 +334,7 @@ en, Base, ja, + ru, ); mainGroup = F2C08D6A1C68651900B00181; productRefGroup = F2C08D751C68651900B00181 /* Products */; @@ -346,6 +353,7 @@ buildActionMask = 2147483647; files = ( F208E55E1CD7370B00FFC9F6 /* LaunchScreen.storyboard in Resources */, + 3569CAA91EC1918E000C41C0 /* NohanaImagePicker.xcassets in Resources */, F208E55B1CD7370B00FFC9F6 /* Assets.xcassets in Resources */, F208E5591CD7370B00FFC9F6 /* Main.storyboard in Resources */, ); @@ -357,7 +365,7 @@ files = ( F23554261C69D19C00796DCA /* NohanaImagePicker.storyboard in Resources */, F27029CB1C71C43A001647AB /* NohanaImagePicker.strings in Resources */, - F237249B1C6DCF96005D1E8A /* Images.xcassets in Resources */, + F237249B1C6DCF96005D1E8A /* NohanaImagePicker.xcassets in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -385,7 +393,6 @@ F25C10C21C8ED9BF007453C3 /* MomentViewController.swift in Sources */, F25C69881CA23A0A005935D6 /* MomentCell.swift in Sources */, F2FE1F781C901D9400FDBE7B /* MomentSectionHeaderView.swift in Sources */, - F202573A1C7343D20069B33A /* ImageName.swift in Sources */, F23554281C69D5DB00796DCA /* NohanaImagePickerController.swift in Sources */, F25C69921CA28728005935D6 /* AlbumListEmptyIndicator.swift in Sources */, F2131F431C79615700797887 /* SwipeInteractionController.swift in Sources */, @@ -400,7 +407,6 @@ F2DF3B2B1C6CC4DB00C1C0E4 /* AssetDetailListViewController.swift in Sources */, F218D7D61C6B3D22001FCED1 /* PhotoKitAlbumList.swift in Sources */, F24EB6901C68AEED0002EC86 /* AlbumListViewController.swift in Sources */, - F25C699B1CA2B79A005935D6 /* ColorConfig.swift in Sources */, F28F4AC31C6C49EE00B7D725 /* PhotoKitAssetList.swift in Sources */, F26775EA1C71645A002E786C /* ContractingAnimationController.swift in Sources */, ); @@ -438,6 +444,7 @@ children = ( F27029CC1C71C43A001647AB /* en */, F27029CF1C71C4FE001647AB /* ja */, + 3590F1F51EC1A79400F32E06 /* ru */, ); name = NohanaImagePicker.strings; sourceTree = ""; diff --git a/NohanaImagePicker/AlbumListEmptyIndicator.swift b/NohanaImagePicker/AlbumListEmptyIndicator.swift index 9619ef7..5db4d3f 100644 --- a/NohanaImagePicker/AlbumListEmptyIndicator.swift +++ b/NohanaImagePicker/AlbumListEmptyIndicator.swift @@ -16,21 +16,21 @@ class AlbumListEmptyIndicator: UILabel { - init(message: String, description: String, frame: CGRect) { + init(message: String, description: String, frame: CGRect, config: NohanaImagePickerController.Config) { super.init(frame: frame) let centerStyle = NSMutableParagraphStyle() centerStyle.alignment = NSTextAlignment.center let messageAttributes = [ - NSForegroundColorAttributeName : ColorConfig.emptyIndicator, + NSForegroundColorAttributeName : config.color.empty ?? UIColor(red: 0x88/0xff, green: 0x88/0xff, blue: 0x88/0xff, alpha: 1), NSFontAttributeName : UIFont.systemFont(ofSize: 26), NSParagraphStyleAttributeName : centerStyle ] let messageText = NSAttributedString(string: message, attributes: messageAttributes) let descriptionAttributes = [ - NSForegroundColorAttributeName : ColorConfig.emptyIndicator, + NSForegroundColorAttributeName : config.color.empty ?? UIColor(red: 0x88/0xff, green: 0x88/0xff, blue: 0x88/0xff, alpha: 1), NSFontAttributeName : UIFont.systemFont(ofSize: 14), NSParagraphStyleAttributeName : centerStyle ] diff --git a/NohanaImagePicker/AlbumListViewController.swift b/NohanaImagePicker/AlbumListViewController.swift index 2d46690..35db63b 100644 --- a/NohanaImagePicker/AlbumListViewController.swift +++ b/NohanaImagePicker/AlbumListViewController.swift @@ -41,13 +41,13 @@ class AlbumListViewController: UITableViewController, EmptyIndicatable, Activity override func viewDidLoad() { super.viewDidLoad() if let nohanaImagePickerController = nohanaImagePickerController { - title = NSLocalizedString("albumlist.title", tableName: "NohanaImagePicker", bundle: nohanaImagePickerController.assetBundle, comment: "") + view.backgroundColor = nohanaImagePickerController.config.color.background ?? .white + title = nohanaImagePickerController.config.strings.albumListTitle ?? NSLocalizedString("albumlist.title", tableName: "NohanaImagePicker", bundle: nohanaImagePickerController.assetBundle, comment: "") setUpToolbarItems() navigationController?.setToolbarHidden(nohanaImagePickerController.toolbarHidden ,animated: false) } setUpEmptyIndicator() setUpActivityIndicator() - self.view.backgroundColor = ColorConfig.backgroundColor } deinit { @@ -135,11 +135,12 @@ class AlbumListViewController: UITableViewController, EmptyIndicatable, Activity switch sectionType { case .moment: - guard let cell = tableView.dequeueReusableCell(withIdentifier: "MomentAlbumCell") as? AlbumCell else { + guard let cell = tableView.dequeueReusableCell(withIdentifier: "MomentAlbumCell") as? MomentCell else { fatalError("failed to dequeueReusableCellWithIdentifier(\"MomentAlbumCell\")") } if let nohanaImagePickerController = nohanaImagePickerController { - cell.titleLabel?.text = NSLocalizedString("albumlist.moment.title", tableName: "NohanaImagePicker", bundle: nohanaImagePickerController.assetBundle, comment: "") + cell.config = nohanaImagePickerController.config + cell.titleLabel?.text = nohanaImagePickerController.config.strings.albumListMomentTitle ?? NSLocalizedString("albumlist.moment.title", tableName: "NohanaImagePicker", bundle: nohanaImagePickerController.assetBundle, comment: "") } return cell case .albums: @@ -220,9 +221,10 @@ class AlbumListViewController: UITableViewController, EmptyIndicatable, Activity return } emptyIndicator = AlbumListEmptyIndicator( - message: NSLocalizedString("albumlist.empty.message", tableName: "NohanaImagePicker", bundle: nohanaImagePickerController.assetBundle, comment: ""), - description: NSLocalizedString("albumlist.empty.description", tableName: "NohanaImagePicker", bundle: nohanaImagePickerController.assetBundle, comment: ""), - frame: frame) + message: nohanaImagePickerController.config.strings.albumListEmptyMessage ?? NSLocalizedString("albumlist.empty.message", tableName: "NohanaImagePicker", bundle: nohanaImagePickerController.assetBundle, comment: ""), + description: nohanaImagePickerController.config.strings.albumListEmptyDescription ?? NSLocalizedString("albumlist.empty.description", tableName: "NohanaImagePicker", bundle: nohanaImagePickerController.assetBundle, comment: ""), + frame: frame, + config: nohanaImagePickerController.config) } func isEmpty() -> Bool { @@ -272,11 +274,11 @@ extension UIViewController { return } if nohanaImagePickerController.maximumNumberOfSelection == 0 { - let title = String(format: NSLocalizedString("toolbar.title.nolimit", tableName: "NohanaImagePicker", bundle: nohanaImagePickerController.assetBundle, comment: ""), + let title = String(format: nohanaImagePickerController.config.strings.toolbarTitleNoLimit ?? NSLocalizedString("toolbar.title.nolimit", tableName: "NohanaImagePicker", bundle: nohanaImagePickerController.assetBundle, comment: ""), nohanaImagePickerController.pickedAssetList.count) infoButton.title = title } else { - let title = String(format: NSLocalizedString("toolbar.title.haslimit", tableName: "NohanaImagePicker", bundle: nohanaImagePickerController.assetBundle, comment: ""), + let title = String(format: nohanaImagePickerController.config.strings.toolbarTitleHasLimit ?? NSLocalizedString("toolbar.title.haslimit", tableName: "NohanaImagePicker", bundle: nohanaImagePickerController.assetBundle, comment: ""), nohanaImagePickerController.pickedAssetList.count, nohanaImagePickerController.maximumNumberOfSelection) infoButton.title = title diff --git a/NohanaImagePicker/AssetCell.swift b/NohanaImagePicker/AssetCell.swift index 0215bdf..a0bd715 100644 --- a/NohanaImagePicker/AssetCell.swift +++ b/NohanaImagePicker/AssetCell.swift @@ -27,12 +27,11 @@ class AssetCell: UICollectionViewCell { override func willMove(toSuperview newSuperview: UIView?) { super.willMove(toSuperview: newSuperview) if let nohanaImagePickerController = nohanaImagePickerController { - pickButton.setImage( - UIImage(named: ImageName.AssetCell.PickButton.SizeM.dropped, in: nohanaImagePickerController.assetBundle, compatibleWith: nil), - for: UIControlState()) - pickButton.setImage( - UIImage(named: ImageName.AssetCell.PickButton.SizeM.picked, in: nohanaImagePickerController.assetBundle, compatibleWith: nil), - for: .selected) + let droppedImage: UIImage? = nohanaImagePickerController.config.image.droppedSmall ?? UIImage(named: "btn_select_m", in: nohanaImagePickerController.assetBundle, compatibleWith: nil) + let pickedImage: UIImage? = nohanaImagePickerController.config.image.pickedSmall ?? UIImage(named: "btn_selected_m", in: nohanaImagePickerController.assetBundle, compatibleWith: nil) + + pickButton.setImage(droppedImage, for: UIControlState()) + pickButton.setImage(pickedImage, for: .selected) } } diff --git a/NohanaImagePicker/AssetDetailListViewController.swift b/NohanaImagePicker/AssetDetailListViewController.swift index 01afa45..a5c6d72 100644 --- a/NohanaImagePicker/AssetDetailListViewController.swift +++ b/NohanaImagePicker/AssetDetailListViewController.swift @@ -35,12 +35,11 @@ class AssetDetailListViewController: AssetListViewController { override func viewDidLoad() { super.viewDidLoad() if let nohanaImagePickerController = nohanaImagePickerController { - pickButton.setImage( - UIImage(named: ImageName.AssetCell.PickButton.SizeL.dropped, in: nohanaImagePickerController.assetBundle, compatibleWith: nil), - for: UIControlState()) - pickButton.setImage( - UIImage(named: ImageName.AssetCell.PickButton.SizeL.picked, in: nohanaImagePickerController.assetBundle, compatibleWith: nil), - for: .selected) + let droppedImage: UIImage? = nohanaImagePickerController.config.image.droppedLarge ?? UIImage(named: "btn_select_l", in: nohanaImagePickerController.assetBundle, compatibleWith: nil) + let pickedImage: UIImage? = nohanaImagePickerController.config.image.pickedLarge ?? UIImage(named: "btn_selected_l", in: nohanaImagePickerController.assetBundle, compatibleWith: nil) + + pickButton.setImage(droppedImage, for: UIControlState()) + pickButton.setImage(pickedImage, for: .selected) } } diff --git a/NohanaImagePicker/AssetListViewController.swift b/NohanaImagePicker/AssetListViewController.swift index 6aa1cbd..d9d9a5d 100644 --- a/NohanaImagePicker/AssetListViewController.swift +++ b/NohanaImagePicker/AssetListViewController.swift @@ -24,10 +24,10 @@ class AssetListViewController: UICollectionViewController { override func viewDidLoad() { super.viewDidLoad() + view.backgroundColor = nohanaImagePickerController?.config.color.background ?? .white updateTitle() setUpToolbarItems() addPickPhotoKitAssetNotificationObservers() - self.view.backgroundColor = ColorConfig.backgroundColor } var cellSize: CGSize { diff --git a/NohanaImagePicker/ImageName.swift b/NohanaImagePicker/ImageName.swift deleted file mode 100644 index 9f54b81..0000000 --- a/NohanaImagePicker/ImageName.swift +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2016 nohana, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -struct ImageName { - struct AssetCell { - struct PickButton { - struct SizeM { - static let picked = "btn_selected_m" - static let dropped = "btn_select_m" - } - struct SizeL { - static let picked = "btn_selected_l" - static let dropped = "btn_select_l" - } - } - } -} \ No newline at end of file diff --git a/NohanaImagePicker/Images.xcassets/icon_photosize_alert_s.imageset/icon_photosize_alert_s@2x.png b/NohanaImagePicker/Images.xcassets/icon_photosize_alert_s.imageset/icon_photosize_alert_s@2x.png deleted file mode 100644 index 34f67ea..0000000 Binary files a/NohanaImagePicker/Images.xcassets/icon_photosize_alert_s.imageset/icon_photosize_alert_s@2x.png and /dev/null differ diff --git a/NohanaImagePicker/Images.xcassets/icon_photosize_alert_s.imageset/icon_photosize_alert_s@3x.png b/NohanaImagePicker/Images.xcassets/icon_photosize_alert_s.imageset/icon_photosize_alert_s@3x.png deleted file mode 100644 index 80f0203..0000000 Binary files a/NohanaImagePicker/Images.xcassets/icon_photosize_alert_s.imageset/icon_photosize_alert_s@3x.png and /dev/null differ diff --git a/NohanaImagePicker/Images.xcassets/icon_photosize_low_s.imageset/icon_photosize_low_s@2x.png b/NohanaImagePicker/Images.xcassets/icon_photosize_low_s.imageset/icon_photosize_low_s@2x.png deleted file mode 100644 index e4fee63..0000000 Binary files a/NohanaImagePicker/Images.xcassets/icon_photosize_low_s.imageset/icon_photosize_low_s@2x.png and /dev/null differ diff --git a/NohanaImagePicker/Images.xcassets/icon_photosize_low_s.imageset/icon_photosize_low_s@3x.png b/NohanaImagePicker/Images.xcassets/icon_photosize_low_s.imageset/icon_photosize_low_s@3x.png deleted file mode 100644 index 68218a2..0000000 Binary files a/NohanaImagePicker/Images.xcassets/icon_photosize_low_s.imageset/icon_photosize_low_s@3x.png and /dev/null differ diff --git a/NohanaImagePicker/MomentCell.swift b/NohanaImagePicker/MomentCell.swift index eec40d4..55926fc 100644 --- a/NohanaImagePicker/MomentCell.swift +++ b/NohanaImagePicker/MomentCell.swift @@ -17,11 +17,13 @@ import UIKit class MomentCell: AlbumCell { + var config: NohanaImagePickerController.Config! override func draw(_ rect: CGRect) { super.draw(rect) let lineWidth: CGFloat = 1 / UIScreen.main.scale - ColorConfig.AlbumList.momentCellSeparator.setFill() + let separatorColor: UIColor = config.color.separator ?? UIColor(red: 0xbb/0xff, green: 0xbb/0xff, blue: 0xbb/0xff, alpha: 1) + separatorColor.setFill() UIRectFill(CGRect(x: 16, y: frame.size.height - lineWidth, width: frame.size.width, height:lineWidth)) } diff --git a/NohanaImagePicker/NohanaImagePicker.storyboard b/NohanaImagePicker/NohanaImagePicker.storyboard index c8fb638..32abe25 100644 --- a/NohanaImagePicker/NohanaImagePicker.storyboard +++ b/NohanaImagePicker/NohanaImagePicker.storyboard @@ -1,9 +1,13 @@ - - + + + + + - + + @@ -13,10 +17,10 @@ - + - + @@ -30,12 +34,9 @@ @@ -47,7 +48,7 @@ - + @@ -55,7 +56,7 @@ - + @@ -67,7 +68,7 @@ - + @@ -77,7 +78,7 @@ - + @@ -110,7 +111,7 @@ - + @@ -119,7 +120,7 @@ - + @@ -130,7 +131,7 @@ - @@ -168,7 +167,7 @@ - + @@ -188,7 +187,7 @@ - + @@ -205,7 +204,7 @@ - + @@ -234,7 +233,6 @@ - @@ -261,7 +259,6 @@ - @@ -381,18 +376,17 @@ - + @@ -447,13 +438,9 @@ - + - - - - diff --git a/NohanaImagePicker/NohanaImagePicker.xcassets/Contents.json b/NohanaImagePicker/NohanaImagePicker.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/NohanaImagePicker/NohanaImagePicker.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/NohanaImagePicker/Images.xcassets/btn_select_l.imageset/Contents.json b/NohanaImagePicker/NohanaImagePicker.xcassets/btn_select_l.imageset/Contents.json similarity index 100% rename from NohanaImagePicker/Images.xcassets/btn_select_l.imageset/Contents.json rename to NohanaImagePicker/NohanaImagePicker.xcassets/btn_select_l.imageset/Contents.json diff --git a/NohanaImagePicker/Images.xcassets/btn_select_l.imageset/btn_select_l@2x.png b/NohanaImagePicker/NohanaImagePicker.xcassets/btn_select_l.imageset/btn_select_l@2x.png similarity index 100% rename from NohanaImagePicker/Images.xcassets/btn_select_l.imageset/btn_select_l@2x.png rename to NohanaImagePicker/NohanaImagePicker.xcassets/btn_select_l.imageset/btn_select_l@2x.png diff --git a/NohanaImagePicker/Images.xcassets/btn_select_l.imageset/btn_select_l@3x.png b/NohanaImagePicker/NohanaImagePicker.xcassets/btn_select_l.imageset/btn_select_l@3x.png similarity index 100% rename from NohanaImagePicker/Images.xcassets/btn_select_l.imageset/btn_select_l@3x.png rename to NohanaImagePicker/NohanaImagePicker.xcassets/btn_select_l.imageset/btn_select_l@3x.png diff --git a/NohanaImagePicker/Images.xcassets/icon_photosize_low_s.imageset/Contents.json b/NohanaImagePicker/NohanaImagePicker.xcassets/btn_select_m.imageset/Contents.json similarity index 72% rename from NohanaImagePicker/Images.xcassets/icon_photosize_low_s.imageset/Contents.json rename to NohanaImagePicker/NohanaImagePicker.xcassets/btn_select_m.imageset/Contents.json index e884163..a4c6bec 100644 --- a/NohanaImagePicker/Images.xcassets/icon_photosize_low_s.imageset/Contents.json +++ b/NohanaImagePicker/NohanaImagePicker.xcassets/btn_select_m.imageset/Contents.json @@ -6,12 +6,12 @@ }, { "idiom" : "universal", - "filename" : "icon_photosize_low_s@2x.png", + "filename" : "btn_select_m@2x.png", "scale" : "2x" }, { "idiom" : "universal", - "filename" : "icon_photosize_low_s@3x.png", + "filename" : "btn_select_m@3x.png", "scale" : "3x" } ], diff --git a/NohanaImagePicker/Images.xcassets/btn_select_m.imageset/btn_select_m@2x.png b/NohanaImagePicker/NohanaImagePicker.xcassets/btn_select_m.imageset/btn_select_m@2x.png similarity index 100% rename from NohanaImagePicker/Images.xcassets/btn_select_m.imageset/btn_select_m@2x.png rename to NohanaImagePicker/NohanaImagePicker.xcassets/btn_select_m.imageset/btn_select_m@2x.png diff --git a/NohanaImagePicker/Images.xcassets/btn_select_m.imageset/btn_select_m@3x.png b/NohanaImagePicker/NohanaImagePicker.xcassets/btn_select_m.imageset/btn_select_m@3x.png similarity index 100% rename from NohanaImagePicker/Images.xcassets/btn_select_m.imageset/btn_select_m@3x.png rename to NohanaImagePicker/NohanaImagePicker.xcassets/btn_select_m.imageset/btn_select_m@3x.png diff --git a/NohanaImagePicker/Images.xcassets/btn_selected_l.imageset/Contents.json b/NohanaImagePicker/NohanaImagePicker.xcassets/btn_selected_l.imageset/Contents.json similarity index 100% rename from NohanaImagePicker/Images.xcassets/btn_selected_l.imageset/Contents.json rename to NohanaImagePicker/NohanaImagePicker.xcassets/btn_selected_l.imageset/Contents.json diff --git a/NohanaImagePicker/Images.xcassets/btn_selected_l.imageset/btn_selected_l@2x.png b/NohanaImagePicker/NohanaImagePicker.xcassets/btn_selected_l.imageset/btn_selected_l@2x.png similarity index 100% rename from NohanaImagePicker/Images.xcassets/btn_selected_l.imageset/btn_selected_l@2x.png rename to NohanaImagePicker/NohanaImagePicker.xcassets/btn_selected_l.imageset/btn_selected_l@2x.png diff --git a/NohanaImagePicker/Images.xcassets/btn_selected_l.imageset/btn_selected_l@3x.png b/NohanaImagePicker/NohanaImagePicker.xcassets/btn_selected_l.imageset/btn_selected_l@3x.png similarity index 100% rename from NohanaImagePicker/Images.xcassets/btn_selected_l.imageset/btn_selected_l@3x.png rename to NohanaImagePicker/NohanaImagePicker.xcassets/btn_selected_l.imageset/btn_selected_l@3x.png diff --git a/NohanaImagePicker/Images.xcassets/icon_photosize_alert_s.imageset/Contents.json b/NohanaImagePicker/NohanaImagePicker.xcassets/btn_selected_m.imageset/Contents.json similarity index 71% rename from NohanaImagePicker/Images.xcassets/icon_photosize_alert_s.imageset/Contents.json rename to NohanaImagePicker/NohanaImagePicker.xcassets/btn_selected_m.imageset/Contents.json index 6f14b6e..307b92b 100644 --- a/NohanaImagePicker/Images.xcassets/icon_photosize_alert_s.imageset/Contents.json +++ b/NohanaImagePicker/NohanaImagePicker.xcassets/btn_selected_m.imageset/Contents.json @@ -6,12 +6,12 @@ }, { "idiom" : "universal", - "filename" : "icon_photosize_alert_s@2x.png", + "filename" : "btn_selected_m@2x.png", "scale" : "2x" }, { "idiom" : "universal", - "filename" : "icon_photosize_alert_s@3x.png", + "filename" : "btn_selected_m@3x.png", "scale" : "3x" } ], diff --git a/NohanaImagePicker/Images.xcassets/btn_selected_m.imageset/btn_selected_m@2x.png b/NohanaImagePicker/NohanaImagePicker.xcassets/btn_selected_m.imageset/btn_selected_m@2x.png similarity index 100% rename from NohanaImagePicker/Images.xcassets/btn_selected_m.imageset/btn_selected_m@2x.png rename to NohanaImagePicker/NohanaImagePicker.xcassets/btn_selected_m.imageset/btn_selected_m@2x.png diff --git a/NohanaImagePicker/Images.xcassets/btn_selected_m.imageset/btn_selected_m@3x.png b/NohanaImagePicker/NohanaImagePicker.xcassets/btn_selected_m.imageset/btn_selected_m@3x.png similarity index 100% rename from NohanaImagePicker/Images.xcassets/btn_selected_m.imageset/btn_selected_m@3x.png rename to NohanaImagePicker/NohanaImagePicker.xcassets/btn_selected_m.imageset/btn_selected_m@3x.png diff --git a/NohanaImagePicker/NohanaImagePickerController.swift b/NohanaImagePicker/NohanaImagePickerController.swift index e679070..d777016 100644 --- a/NohanaImagePicker/NohanaImagePickerController.swift +++ b/NohanaImagePicker/NohanaImagePickerController.swift @@ -39,7 +39,7 @@ public enum MediaType: Int { open class NohanaImagePickerController: UIViewController { - open var maximumNumberOfSelection: Int = 21 // set 0 to set no limit + open var maximumNumberOfSelection: Int = 21 // set 0 to no limit open var numberOfColumnsInPortrait: Int = 4 open var numberOfColumnsInLandscape: Int = 7 open weak var delegate: NohanaImagePickerControllerDelegate? @@ -49,6 +49,8 @@ open class NohanaImagePickerController: UIViewController { open var canPickAsset = { (asset:Asset) -> Bool in return true } + open var config: Config = Config() + lazy var assetBundle:Bundle = { let bundle = Bundle(for: type(of: self)) if let path = bundle.path(forResource: "NohanaImagePicker", ofType: "bundle") { @@ -136,3 +138,31 @@ open class NohanaImagePickerController: UIViewController { } } +extension NohanaImagePickerController { + public struct Config { + public struct Color { + public var background: UIColor? + public var empty: UIColor? + public var separator: UIColor? + } + public var color = Color() + + public struct Image { + public var pickedSmall: UIImage? + public var pickedLarge: UIImage? + public var droppedSmall: UIImage? + public var droppedLarge: UIImage? + } + public var image = Image() + + public struct Strings { + public var albumListTitle: String? + public var albumListMomentTitle: String? + public var albumListEmptyMessage: String? + public var albumListEmptyDescription: String? + public var toolbarTitleNoLimit: String? + public var toolbarTitleHasLimit: String? + } + public var strings = Strings() + } +} diff --git a/NohanaImagePicker/ColorConfig.swift b/NohanaImagePicker/ru.lproj/NohanaImagePicker.strings similarity index 63% rename from NohanaImagePicker/ColorConfig.swift rename to NohanaImagePicker/ru.lproj/NohanaImagePicker.strings index b133456..f882602 100644 --- a/NohanaImagePicker/ColorConfig.swift +++ b/NohanaImagePicker/ru.lproj/NohanaImagePicker.strings @@ -14,11 +14,9 @@ * limitations under the License. */ -public struct ColorConfig { - public static var backgroundColor = UIColor.white - public static var emptyIndicator = UIColor(red: 0x88/0xff, green: 0x88/0xff, blue: 0x88/0xff, alpha: 1) - - public struct AlbumList { - public static var momentCellSeparator = UIColor(red: 0xbb/0xff, green: 0xbb/0xff, blue: 0xbb/0xff, alpha: 1) - } -} +"albumlist.title" = "Фотографии"; +"albumlist.empty.message" = "Нет фотографий"; +"albumlist.empty.description" = "Получить фото с камеры"; +"albumlist.moment.title" = "Моменты"; +"toolbar.title.nolimit" = "Выбрано: %ld"; +"toolbar.title.haslimit" = "Выбрано: %ld / %ld"; diff --git a/README.md b/README.md index ca51821..493d531 100644 --- a/README.md +++ b/README.md @@ -11,15 +11,20 @@ NohanaImagePicker enables your app to pick images from multiple album, and the m ## Usage ```swift +import UIKit +import Photos import NohanaImagePicker -class ViewController: UIViewController, NohanaImagePickerControllerDelegate { +class MyViewController: UIViewController { + let picker = NohanaImagePickerController() override func viewDidAppear(animated: Bool) { - super.viewDidAppear(true) - let picker = NohanaImagePickerController() - picker.delegate = self - present(picker, animated: true, completion: nil) + super.viewDidAppear(animated) + self.picker.delegate = self + present(self.picker, animated: true, completion: nil) } +} + +extension MyViewController: NohanaImagePickerControllerDelegate { func nohanaImagePickerDidCancel(_ picker: NohanaImagePickerController) { print("🐷Canceled🙅") @@ -30,7 +35,6 @@ class ViewController: UIViewController, NohanaImagePickerControllerDelegate { print("🐷Completed🙆\n\tpickedAssets = \(pickedAssts)") picker.dismiss(animated: true, completion: nil) } - } ``` @@ -59,9 +63,6 @@ picker.shouldShowEmptyAlbum = true picker.canPickAsset = { (asset:Asset) -> Bool in return false } - -// Color -ColorConfig.backgroundColor = UIColor.redColor() ``` ## Requirements @@ -84,6 +85,8 @@ Use [Carthage](https://github.com/Carthage/Carthage). Use [CocoaPods](https://cocoapods.org/). +- Try; ``pod try NohanaImagePicker`` + - Add the followings to your Podfile: ```ruby