Skip to content

Commit

Permalink
Updated to version 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Minitour committed Jul 9, 2017
1 parent bea714b commit b4da64a
Show file tree
Hide file tree
Showing 10 changed files with 654 additions and 253 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion AZDialogView.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "AZDialogView"
s.version = "1.0.2"
s.version = "1.1.0"
s.summary = "A highly customizable alert dialog controller that mimics Snapchat's alert dialog."
s.homepage = "https://github.com/Minitour/AZDialogViewController"
s.license = "MIT"
Expand Down
Binary file modified AZDialogViewControllerExample/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@
PRODUCT_BUNDLE_IDENTIFIER = mobi.newsound.AZDialogViewControllerExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
Expand All @@ -290,6 +291,7 @@
PRODUCT_BUNDLE_IDENTIFIER = mobi.newsound.AZDialogViewControllerExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16C67" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand Down Expand Up @@ -79,5 +82,75 @@
</objects>
<point key="canvasLocation" x="136.80000000000001" y="138.98050974512745"/>
</scene>
<!--View Controller-->
<scene sceneID="wVI-Lz-wSZ">
<objects>
<viewController id="1ei-eO-ehl" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="E3Y-0l-FC1"/>
<viewControllerLayoutGuide type="bottom" id="bi6-Og-J0p"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="wsp-1B-04c">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="hLx-cl-ARl">
<rect key="frame" x="32" y="237" width="311" height="192"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ort-1Y-R1l">
<rect key="frame" x="109" y="-50" width="93.5" height="93"/>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="width" secondItem="ort-1Y-R1l" secondAttribute="height" multiplier="1:1" id="NgU-c3-j7M"/>
</constraints>
</view>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="Uun-It-7X9">
<rect key="frame" x="8" y="51" width="295" height="133"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Lbn-uy-y5e">
<rect key="frame" x="27.5" y="0.0" width="240" height="132"/>
<color key="backgroundColor" red="0.0" green="0.69491332769393921" blue="0.40852432227078822" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="s1V-GE-Q43">
<rect key="frame" x="27.5" y="132" width="240" height="1"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="xcg-ba-Gyl"/>
</constraints>
</view>
</subviews>
<constraints>
<constraint firstItem="s1V-GE-Q43" firstAttribute="width" secondItem="Lbn-uy-y5e" secondAttribute="width" id="c5z-jE-8bj"/>
</constraints>
</stackView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="ort-1Y-R1l" firstAttribute="width" secondItem="hLx-cl-ARl" secondAttribute="width" multiplier="0.3" id="9t1-mk-Jr6"/>
<constraint firstAttribute="height" constant="192" id="A5i-lR-Bv2"/>
<constraint firstAttribute="bottom" secondItem="Uun-It-7X9" secondAttribute="bottom" constant="8" id="DAP-tW-MLN"/>
<constraint firstItem="ort-1Y-R1l" firstAttribute="top" secondItem="hLx-cl-ARl" secondAttribute="top" constant="-50" id="Fz8-oP-B4L"/>
<constraint firstItem="ort-1Y-R1l" firstAttribute="centerX" secondItem="hLx-cl-ARl" secondAttribute="centerX" id="K64-V4-Kmn"/>
<constraint firstAttribute="trailing" secondItem="Uun-It-7X9" secondAttribute="trailing" constant="8" id="Lu4-bj-hMQ"/>
<constraint firstItem="Uun-It-7X9" firstAttribute="leading" secondItem="hLx-cl-ARl" secondAttribute="leading" constant="8" id="hkL-rH-6sk"/>
<constraint firstItem="Uun-It-7X9" firstAttribute="top" secondItem="ort-1Y-R1l" secondAttribute="bottom" constant="8" id="iwQ-Md-AXX"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="trailingMargin" secondItem="hLx-cl-ARl" secondAttribute="trailing" constant="16" id="DZe-vz-WGq"/>
<constraint firstItem="hLx-cl-ARl" firstAttribute="centerY" secondItem="wsp-1B-04c" secondAttribute="centerY" id="l0j-9S-4xf"/>
<constraint firstItem="hLx-cl-ARl" firstAttribute="leading" secondItem="wsp-1B-04c" secondAttribute="leadingMargin" constant="16" id="yb3-wa-LQd"/>
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="siW-fB-THV" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="981.60000000000002" y="138.98050974512745"/>
</scene>
</scenes>
</document>
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ class ViewController: UIViewController {
@IBAction func click(_ sender: UIButton) {
switch sender.tag{
case 0:
ignDialog()
//ignDialog()
loadingIndicator()
case 1:
editUserDialog()
case 2:
Expand All @@ -41,22 +42,85 @@ class ViewController: UIViewController {
}
}

func loadingIndicator(){
let dialog = AZDialogViewController(title: "Loading...", message: "Logging you in, please wait")

let container = dialog.container
let indicator = UIActivityIndicatorView(activityIndicatorStyle: .gray)
dialog.container.addSubview(indicator)
indicator.translatesAutoresizingMaskIntoConstraints = false
indicator.centerXAnchor.constraint(equalTo: container.centerXAnchor).isActive = true
indicator.centerYAnchor.constraint(equalTo: container.centerYAnchor).isActive = true
indicator.startAnimating()


dialog.buttonStyle = { (button,height,position) in
button.setBackgroundImage(UIImage.imageWithColor(self.primaryColorDark), for: .highlighted)
button.setTitleColor(UIColor.white, for: .highlighted)
button.setTitleColor(self.primaryColor, for: .normal)
button.layer.masksToBounds = true
button.layer.borderColor = self.primaryColor.cgColor
}

dialog.customViewSizeRatio = 0.2
dialog.dismissDirection = .none
dialog.allowDragGesture = false
dialog.dismissWithOutsideTouch = true
dialog.show(in: self)

let when = DispatchTime.now() + 3 // change 2 to desired number of seconds
DispatchQueue.main.asyncAfter(deadline: when) {
dialog.message = "Preparing..."
}

DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 4) {
dialog.message = "Syncing accounts..."
}

DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 5) {
dialog.title = "Ready"
dialog.message = "Let's get started"
dialog.image = #imageLiteral(resourceName: "image")
dialog.customViewSizeRatio = 0
dialog.addAction(AZDialogAction(title: "Go", handler: { (dialog) -> (Void) in
dialog.dismiss()
}))
}


}

func ignDialog(){
let dialogController = AZDialogViewController(title: "IGN",
message: "IGN is your destination for gaming, movies, comics and everything you're into. Find the latest reviews, news, videos, and more more.")
let dialogController = AZDialogViewController(title: "ign", message: "some message")

dialogController.showSeparator = true

dialogController.imageHandler = { (imageView) in
imageView.image = #imageLiteral(resourceName: "ign")
imageView.contentMode = .scaleAspectFill
return true
}
// dialogController.imageHandler = { (imageView) in
// imageView.image = UIImage(named: "ign")
// imageView.contentMode = .scaleAspectFill
// return true
// }

dialogController.addAction(AZDialogAction(title: "Subscribe", handler: { (dialog) -> (Void) in
dialog.dismiss()
//dialog.title = "title"
//dialog.message = "new message"
dialog.image = dialog.image == nil ? #imageLiteral(resourceName: "ign") : nil
//dialog.title = ""
//dialog.message = ""
//dialog.customViewSizeRatio = 0.2


}))

let container = dialogController.container
let button = UIButton(type: .system)
button.setTitle("MY BUTTON", for: [])
dialogController.container.addSubview(button)
button.translatesAutoresizingMaskIntoConstraints = false
button.centerXAnchor.constraint(equalTo: container.centerXAnchor).isActive = true
button.centerYAnchor.constraint(equalTo: container.centerYAnchor).isActive = true


dialogController.buttonStyle = { (button,height,position) in
button.setBackgroundImage(UIImage.imageWithColor(self.primaryColor) , for: .normal)
button.setBackgroundImage(UIImage.imageWithColor(self.primaryColorDark), for: .highlighted)
Expand Down
42 changes: 27 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ A highly customizable alert dialog controller that mimics Snapchat's alert dialo

## Screenshots

<img src="Screenshots/demo.gif" width="320" />
<img src="Screenshots/sc_1.png" width="320" />
<img src="Screenshots/sc_2.png" width="320" />
<img src="Screenshots/sc_3.png" width="320" />
Expand All @@ -27,37 +28,43 @@ Simply drag and drop the ```Sources``` folder to your project.

Create an instance of AZDialogViewController:
```swift
let dialogController = AZDialogViewController(title: "Antonio Zaitoun", message: "minitour")
let dialog = AZDialogViewController(title: "Antonio Zaitoun", message: "minitour")
```

#### Customize:
```swift
dialogController.dismissDirection = .bottom
dialogController.dismissWithOutsideTouch = true
dialogController.showSeparator = false
dialog.dismissDirection = .bottom

dialog.dismissWithOutsideTouch = true

dialog.showSeparator = false

dialog.separatorColor = UIColor.blue

dialog.allowDragGesture = false
```

#### Add Actions:
```swift
dialogController.addAction(AZDialogAction(title: "Edit Name", handler: { (dialog) -> (Void) in
dialog.addAction(AZDialogAction(title: "Edit Name", handler: { (dialog) -> (Void) in
//add your actions here.
dialog.dismiss()
}))

dialogController.addAction(AZDialogAction(title: "Remove Friend", handler: { (dialog) -> (Void) in
dialog.addAction(AZDialogAction(title: "Remove Friend", handler: { (dialog) -> (Void) in
//add your actions here.
dialog.dismiss()
}))

dialogController.addAction(AZDialogAction(title: "Block", handler: { (dialog) -> (Void) in
dialog.addAction(AZDialogAction(title: "Block", handler: { (dialog) -> (Void) in
//add your actions here.
dialog.dismiss()
}))
```

#### Add Image:
```swift
dialogController.imageHandler = { (imageView) in
dialog.imageHandler = { (imageView) in
imageView.image = UIImage(named: "your_image_here")
imageView.contentMode = .scaleAspectFill
return true //must return true, otherwise image won't show.
Expand All @@ -66,7 +73,7 @@ dialogController.imageHandler = { (imageView) in

#### Customize Action Buttons Style:
```swift
dialogController.buttonStyle = { (button,height,position) in
dialog.buttonStyle = { (button,height,position) in
button.setBackgroundImage(UIImage.imageWithColor(self.primaryColorDark), for: .highlighted)
button.setTitleColor(UIColor.white, for: .highlighted)
button.setTitleColor(self.primaryColor, for: .normal)
Expand All @@ -77,29 +84,29 @@ dialogController.buttonStyle = { (button,height,position) in

#### Customize Tool Buttons:
```swift
dialogController.rightToolStyle = { (button) in
dialog.rightToolStyle = { (button) in
button.setImage(UIImage(named: "ic_share"), for: [])
button.tintColor = .lightGray
return true
}
dialogController.rightToolAction = { (button) in
dialog.rightToolAction = { (button) in
print("Share function")
}

dialogController.leftToolStyle = { (button) in
dialog.leftToolStyle = { (button) in
button.setImage(UIImage(named: "ic_share"), for: [])
button.tintColor = .lightGray
return true
}
dialogController.leftToolAction = { (button) in
dialog.leftToolAction = { (button) in
print("Share function")
}

```

#### Customize Cancel Button Style:
```swift
dialogController.cancelButtonStyle = { (button,height) in
dialog.cancelButtonStyle = { (button,height) in
button.tintColor = self.primaryColor
button.setTitle("CANCEL", for: [])
return true //must return true, otherwise cancel button won't show.
Expand All @@ -108,5 +115,10 @@ dialogController.cancelButtonStyle = { (button,height) in

#### Present The dialog:
```swift
dialogController.show(in: self)
dialog.show(in: self)

//or

//Make sure to have animated set to false otherwise you'll see a delay.
self.present(dialog, animated: false, completion: nil)
```
Binary file added Screenshots/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit b4da64a

Please sign in to comment.