mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-27 19:56:57 +02:00
Improve the status of send messages (sending, sent, received, failed)
- First implementation
This commit is contained in:
+12
-39
@@ -1,12 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12121" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
|
||||
<device id="retina4_7" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
|
||||
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
@@ -16,7 +13,7 @@
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="120"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="WmY-Jw-mqv" id="ef1-Tq-U3Z">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="119.5"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="120"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="SFg-55-RF4" userLabel="Pagination Title View">
|
||||
@@ -70,7 +67,7 @@
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<view contentMode="scaleAspectFit" translatesAutoresizingMaskIntoConstraints="NO" id="5IE-JS-uf3" userLabel="Attachment View" customClass="MXKImageView">
|
||||
<rect key="frame" x="56" y="75" width="192" height="34"/>
|
||||
<rect key="frame" x="56" y="75" width="192" height="35"/>
|
||||
<color key="backgroundColor" red="0.93725490196078431" green="0.93725490196078431" blue="0.95686274509803926" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<accessibility key="accessibilityConfiguration" identifier="AttachmentView"/>
|
||||
<constraints>
|
||||
@@ -87,7 +84,7 @@
|
||||
</constraints>
|
||||
</imageView>
|
||||
<imageView hidden="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Cot-3X-2cU" userLabel="Play Icon Image View">
|
||||
<rect key="frame" x="136" y="76" width="32" height="32"/>
|
||||
<rect key="frame" x="136" y="76.5" width="32" height="32"/>
|
||||
<accessibility key="accessibilityConfiguration" identifier="PlayIconImageView"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="32" id="8io-Wk-GzF"/>
|
||||
@@ -95,13 +92,13 @@
|
||||
</constraints>
|
||||
</imageView>
|
||||
<activityIndicatorView hidden="YES" opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" hidesWhenStopped="YES" style="gray" translatesAutoresizingMaskIntoConstraints="NO" id="jmK-pe-WZd">
|
||||
<rect key="frame" x="142" y="82" width="20" height="20"/>
|
||||
<rect key="frame" x="142" y="82.5" width="20" height="20"/>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="accessibilityIdentifier" value="ActivityIndicator"/>
|
||||
</userDefinedRuntimeAttributes>
|
||||
</activityIndicatorView>
|
||||
<view hidden="YES" userInteractionEnabled="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="IOg-Kt-8vW">
|
||||
<rect key="frame" x="515" y="54" width="70" height="65"/>
|
||||
<rect key="frame" x="515" y="54" width="70" height="66"/>
|
||||
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<accessibility key="accessibilityConfiguration" identifier="BubbleInfoContainer"/>
|
||||
<constraints>
|
||||
@@ -109,38 +106,15 @@
|
||||
</constraints>
|
||||
</view>
|
||||
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="fdx-qs-8en" userLabel="ProgressView">
|
||||
<rect key="frame" x="487" y="57" width="100" height="70"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="rate" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" minimumFontSize="4" preferredMaxLayoutWidth="100" translatesAutoresizingMaskIntoConstraints="NO" id="eU5-iK-u8i" userLabel="Progress stats">
|
||||
<rect key="frame" x="0.0" y="60" width="100" height="10"/>
|
||||
<accessibility key="accessibilityConfiguration" identifier="ProgressStats"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="8"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<view userInteractionEnabled="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="hJj-TC-pxK" customClass="MXKPieChartView">
|
||||
<rect key="frame" x="30" y="0.0" width="40" height="40"/>
|
||||
<accessibility key="accessibilityConfiguration" identifier="ProgressChartView"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="40" id="Cpt-s4-tlK"/>
|
||||
<constraint firstAttribute="height" constant="40" id="Jb4-9E-tG0"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</subviews>
|
||||
<rect key="frame" x="487" y="50" width="100" height="70"/>
|
||||
<gestureRecognizers/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="70" id="5w2-Hm-hZx"/>
|
||||
<constraint firstAttribute="centerX" secondItem="eU5-iK-u8i" secondAttribute="centerX" id="APi-aE-mLc"/>
|
||||
<constraint firstItem="eU5-iK-u8i" firstAttribute="leading" secondItem="fdx-qs-8en" secondAttribute="leading" id="Njw-3a-E9Y"/>
|
||||
<constraint firstAttribute="bottom" secondItem="eU5-iK-u8i" secondAttribute="bottom" id="QMO-g9-QVE"/>
|
||||
<constraint firstAttribute="centerX" secondItem="hJj-TC-pxK" secondAttribute="centerX" id="laR-Vg-ol3"/>
|
||||
<constraint firstItem="hJj-TC-pxK" firstAttribute="top" secondItem="fdx-qs-8en" secondAttribute="top" id="ovD-8p-4dP"/>
|
||||
<constraint firstAttribute="width" constant="100" id="ryE-fW-SgG"/>
|
||||
<constraint firstAttribute="trailing" secondItem="eU5-iK-u8i" secondAttribute="trailing" id="teG-8q-BOX"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="3b7-4a-YL0">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="119"/>
|
||||
<rect key="frame" x="8" y="3" width="584" height="114"/>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</view>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="y8m-dS-1Df">
|
||||
@@ -155,6 +129,7 @@
|
||||
<constraint firstItem="y8m-dS-1Df" firstAttribute="trailing" secondItem="q9c-0p-QyP" secondAttribute="trailing" id="6XL-SF-Mbj"/>
|
||||
<constraint firstItem="5IE-JS-uf3" firstAttribute="leading" secondItem="hgp-Z5-rAj" secondAttribute="trailing" constant="13" id="6mM-Ag-m0K"/>
|
||||
<constraint firstItem="5IE-JS-uf3" firstAttribute="top" secondItem="ef1-Tq-U3Z" secondAttribute="top" constant="75" id="96U-67-5TP"/>
|
||||
<constraint firstAttribute="bottom" secondItem="fdx-qs-8en" secondAttribute="bottom" id="AeT-4F-mKp"/>
|
||||
<constraint firstAttribute="trailing" secondItem="q9c-0p-QyP" secondAttribute="trailing" constant="85" id="Bkh-h2-JOQ"/>
|
||||
<constraint firstItem="5IE-JS-uf3" firstAttribute="centerY" secondItem="Cot-3X-2cU" secondAttribute="centerY" id="H5t-l6-fL1"/>
|
||||
<constraint firstItem="SFg-55-RF4" firstAttribute="leading" secondItem="ef1-Tq-U3Z" secondAttribute="leading" constant="56" id="I4N-5Q-LFe"/>
|
||||
@@ -175,7 +150,6 @@
|
||||
<constraint firstItem="hgp-Z5-rAj" firstAttribute="leading" secondItem="ef1-Tq-U3Z" secondAttribute="leading" constant="13" id="tuw-aU-ncu"/>
|
||||
<constraint firstItem="y8m-dS-1Df" firstAttribute="bottom" secondItem="q9c-0p-QyP" secondAttribute="bottom" constant="6" id="tvi-jE-y62"/>
|
||||
<constraint firstItem="y8m-dS-1Df" firstAttribute="leading" secondItem="q9c-0p-QyP" secondAttribute="leading" constant="-10" id="ucU-Df-AZJ"/>
|
||||
<constraint firstItem="5IE-JS-uf3" firstAttribute="centerY" secondItem="fdx-qs-8en" secondAttribute="centerY" id="v0F-Ts-14P"/>
|
||||
<constraint firstItem="SFg-55-RF4" firstAttribute="top" secondItem="ef1-Tq-U3Z" secondAttribute="top" constant="10" id="wJX-7V-bJB"/>
|
||||
<constraint firstItem="5IE-JS-uf3" firstAttribute="top" secondItem="K9X-gn-noF" secondAttribute="top" id="wkX-zQ-iQS"/>
|
||||
<constraint firstAttribute="bottomMargin" secondItem="3b7-4a-YL0" secondAttribute="bottom" constant="-8" id="wpa-8Z-Gy3"/>
|
||||
@@ -200,12 +174,11 @@
|
||||
<outlet property="paginationTitleView" destination="SFg-55-RF4" id="mbP-6I-gOn"/>
|
||||
<outlet property="pictureView" destination="hgp-Z5-rAj" id="rKM-QG-RJN"/>
|
||||
<outlet property="playIconView" destination="Cot-3X-2cU" id="KEF-KK-Og1"/>
|
||||
<outlet property="progressChartView" destination="hJj-TC-pxK" id="Zz3-s5-Qqr"/>
|
||||
<outlet property="progressView" destination="fdx-qs-8en" id="V7E-pn-Xze"/>
|
||||
<outlet property="statsLabel" destination="eU5-iK-u8i" id="MSm-kU-RSY"/>
|
||||
<outlet property="userNameLabel" destination="q9c-0p-QyP" id="JId-R7-LoM"/>
|
||||
<outlet property="userNameTapGestureMaskView" destination="y8m-dS-1Df" id="0Nv-To-W4c"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="-26" y="113"/>
|
||||
</tableViewCell>
|
||||
</objects>
|
||||
</document>
|
||||
|
||||
+11
-38
@@ -1,12 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="15G1108" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
|
||||
<device id="retina4_7" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
|
||||
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
@@ -16,11 +13,11 @@
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="40"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="WmY-Jw-mqv" id="ef1-Tq-U3Z">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="39"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="40"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<view contentMode="scaleAspectFit" translatesAutoresizingMaskIntoConstraints="NO" id="5IE-JS-uf3" userLabel="Attachment View" customClass="MXKImageView">
|
||||
<rect key="frame" x="56" y="3" width="192" height="33"/>
|
||||
<rect key="frame" x="56" y="3" width="192" height="34"/>
|
||||
<color key="backgroundColor" red="0.93725490196078431" green="0.93725490196078431" blue="0.95686274509803926" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<accessibility key="accessibilityConfiguration" identifier="AttachmentView"/>
|
||||
<constraints>
|
||||
@@ -51,7 +48,7 @@
|
||||
</userDefinedRuntimeAttributes>
|
||||
</activityIndicatorView>
|
||||
<view hidden="YES" userInteractionEnabled="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="IOg-Kt-8vW">
|
||||
<rect key="frame" x="515" y="3" width="70" height="36"/>
|
||||
<rect key="frame" x="515" y="3" width="70" height="37"/>
|
||||
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<accessibility key="accessibilityConfiguration" identifier="BubbleInfoContainer"/>
|
||||
<constraints>
|
||||
@@ -59,43 +56,21 @@
|
||||
</constraints>
|
||||
</view>
|
||||
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="fdx-qs-8en" userLabel="ProgressView">
|
||||
<rect key="frame" x="487" y="-15.5" width="100" height="70"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="rate" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" minimumFontSize="4" preferredMaxLayoutWidth="100" translatesAutoresizingMaskIntoConstraints="NO" id="eU5-iK-u8i" userLabel="Progress stats">
|
||||
<rect key="frame" x="0.0" y="60" width="100" height="10"/>
|
||||
<accessibility key="accessibilityConfiguration" identifier="ProgressStats"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="8"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<view userInteractionEnabled="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="hJj-TC-pxK" customClass="MXKPieChartView">
|
||||
<rect key="frame" x="30" y="0.0" width="40" height="40"/>
|
||||
<accessibility key="accessibilityConfiguration" identifier="ProgressChartView"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="40" id="Cpt-s4-tlK"/>
|
||||
<constraint firstAttribute="height" constant="40" id="Jb4-9E-tG0"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</subviews>
|
||||
<rect key="frame" x="487" y="-33" width="100" height="70"/>
|
||||
<gestureRecognizers/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="70" id="5w2-Hm-hZx"/>
|
||||
<constraint firstAttribute="centerX" secondItem="eU5-iK-u8i" secondAttribute="centerX" id="APi-aE-mLc"/>
|
||||
<constraint firstItem="eU5-iK-u8i" firstAttribute="leading" secondItem="fdx-qs-8en" secondAttribute="leading" id="Njw-3a-E9Y"/>
|
||||
<constraint firstAttribute="bottom" secondItem="eU5-iK-u8i" secondAttribute="bottom" id="QMO-g9-QVE"/>
|
||||
<constraint firstAttribute="centerX" secondItem="hJj-TC-pxK" secondAttribute="centerX" id="laR-Vg-ol3"/>
|
||||
<constraint firstItem="hJj-TC-pxK" firstAttribute="top" secondItem="fdx-qs-8en" secondAttribute="top" id="ovD-8p-4dP"/>
|
||||
<constraint firstAttribute="width" constant="100" id="ryE-fW-SgG"/>
|
||||
<constraint firstAttribute="trailing" secondItem="eU5-iK-u8i" secondAttribute="trailing" id="teG-8q-BOX"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="WiZ-KM-lSH">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="39"/>
|
||||
<rect key="frame" x="8" y="3" width="584" height="34"/>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</view>
|
||||
</subviews>
|
||||
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstItem="fdx-qs-8en" firstAttribute="bottom" secondItem="5IE-JS-uf3" secondAttribute="bottom" id="5k7-pL-bQ4"/>
|
||||
<constraint firstItem="8Bq-Mk-bN8" firstAttribute="centerY" secondItem="5IE-JS-uf3" secondAttribute="centerY" id="5xu-oS-Iyd"/>
|
||||
<constraint firstItem="5IE-JS-uf3" firstAttribute="top" secondItem="ef1-Tq-U3Z" secondAttribute="top" constant="3" id="96U-67-5TP"/>
|
||||
<constraint firstItem="5IE-JS-uf3" firstAttribute="centerY" secondItem="Cot-3X-2cU" secondAttribute="centerY" id="H5t-l6-fL1"/>
|
||||
@@ -111,7 +86,6 @@
|
||||
<constraint firstItem="WiZ-KM-lSH" firstAttribute="leading" secondItem="ef1-Tq-U3Z" secondAttribute="leadingMargin" constant="-8" id="qKa-jp-T43"/>
|
||||
<constraint firstItem="5IE-JS-uf3" firstAttribute="centerX" secondItem="Cot-3X-2cU" secondAttribute="centerX" id="sF7-QL-vdj"/>
|
||||
<constraint firstItem="8Bq-Mk-bN8" firstAttribute="centerX" secondItem="5IE-JS-uf3" secondAttribute="centerX" id="tYB-P5-rWe"/>
|
||||
<constraint firstItem="5IE-JS-uf3" firstAttribute="centerY" secondItem="fdx-qs-8en" secondAttribute="centerY" id="v0F-Ts-14P"/>
|
||||
<constraint firstItem="5IE-JS-uf3" firstAttribute="top" secondItem="K9X-gn-noF" secondAttribute="top" id="wkX-zQ-iQS"/>
|
||||
<constraint firstAttribute="trailing" secondItem="fdx-qs-8en" secondAttribute="trailing" constant="13" id="xKk-Gz-moE"/>
|
||||
</constraints>
|
||||
@@ -130,10 +104,9 @@
|
||||
<outlet property="bubbleOverlayContainer" destination="WiZ-KM-lSH" id="07W-1f-K5G"/>
|
||||
<outlet property="fileTypeIconView" destination="K9X-gn-noF" id="4Pj-bc-3gk"/>
|
||||
<outlet property="playIconView" destination="Cot-3X-2cU" id="KEF-KK-Og1"/>
|
||||
<outlet property="progressChartView" destination="hJj-TC-pxK" id="Zz3-s5-Qqr"/>
|
||||
<outlet property="progressView" destination="fdx-qs-8en" id="V7E-pn-Xze"/>
|
||||
<outlet property="statsLabel" destination="eU5-iK-u8i" id="MSm-kU-RSY"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="-26" y="113"/>
|
||||
</tableViewCell>
|
||||
</objects>
|
||||
</document>
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
@IBDesignable
|
||||
@objcMembers
|
||||
class CircleProgressView: UIView {
|
||||
// MARK: - Constants
|
||||
|
||||
private static let minStrokeEnd: CGFloat = 0.000000000001
|
||||
private static let maxStrokeEnd: CGFloat = 1
|
||||
|
||||
// MARK: - Public properties
|
||||
|
||||
@IBInspectable var lineColor: UIColor = .lightGray {
|
||||
didSet {
|
||||
shapeLayer?.strokeColor = lineColor.cgColor
|
||||
}
|
||||
}
|
||||
@IBInspectable var lineWidth: CGFloat = 2 {
|
||||
didSet {
|
||||
shapeLayer?.lineWidth = lineWidth
|
||||
}
|
||||
}
|
||||
var value: CGFloat = 0 {
|
||||
didSet {
|
||||
stopAnimating()
|
||||
strokeEnd = max(min(value, CircleProgressView.maxStrokeEnd), CircleProgressView.minStrokeEnd)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Private members
|
||||
|
||||
private weak var shapeLayer: CAShapeLayer?
|
||||
private var strokeEnd: CGFloat = minStrokeEnd {
|
||||
didSet {
|
||||
shapeLayer?.strokeEnd = strokeEnd
|
||||
}
|
||||
}
|
||||
private var startAngle: CGFloat = -.pi/2
|
||||
private(set) var isAnimating = false
|
||||
|
||||
// MARK: - Lifecycle
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
super.init(coder: coder)
|
||||
initLayer()
|
||||
initPath()
|
||||
}
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
initLayer()
|
||||
initPath()
|
||||
}
|
||||
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
|
||||
shapeLayer?.frame = self.layer.bounds
|
||||
initPath()
|
||||
}
|
||||
|
||||
// MARK: - Interface Builder
|
||||
|
||||
override func prepareForInterfaceBuilder() {
|
||||
value = 0.8
|
||||
}
|
||||
|
||||
// MARK: - Animation management
|
||||
|
||||
func startAnimating() {
|
||||
guard !isAnimating else {
|
||||
return
|
||||
}
|
||||
|
||||
isAnimating = true
|
||||
|
||||
let rotationAnimation = CABasicAnimation(keyPath: "transform.rotation.z")
|
||||
rotationAnimation.fromValue = CGFloat.pi / 2
|
||||
rotationAnimation.toValue = CGFloat.pi * 2.5
|
||||
rotationAnimation.repeatCount = .infinity
|
||||
rotationAnimation.duration = 2
|
||||
shapeLayer?.add(rotationAnimation, forKey: "rotationAnimation")
|
||||
|
||||
let strokeAnimation = CABasicAnimation(keyPath: "strokeEnd")
|
||||
strokeAnimation.fromValue = 0
|
||||
strokeAnimation.toValue = 0.9
|
||||
strokeAnimation.repeatCount = .infinity
|
||||
strokeAnimation.duration = 0.9
|
||||
strokeAnimation.autoreverses = true
|
||||
strokeAnimation.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut)
|
||||
shapeLayer?.add(strokeAnimation, forKey: "path")
|
||||
}
|
||||
|
||||
func stopAnimating() {
|
||||
guard isAnimating else {
|
||||
return
|
||||
}
|
||||
|
||||
shapeLayer?.removeAllAnimations()
|
||||
isAnimating = false
|
||||
}
|
||||
|
||||
// MARK: - Private methods
|
||||
|
||||
private func initLayer() {
|
||||
let layer = CAShapeLayer()
|
||||
layer.fillColor = UIColor.clear.cgColor
|
||||
layer.strokeColor = lineColor.cgColor
|
||||
layer.lineCap = .round
|
||||
layer.lineWidth = lineWidth
|
||||
layer.allowsEdgeAntialiasing = true
|
||||
layer.strokeEnd = strokeEnd
|
||||
|
||||
self.layer.insertSublayer(layer, at: 0)
|
||||
shapeLayer = layer
|
||||
}
|
||||
|
||||
private func initPath() {
|
||||
let endAngle: CGFloat = startAngle + .pi * 2
|
||||
let path = UIBezierPath(arcCenter: CGPoint(x: self.bounds.midX, y: self.bounds.midY), radius: (self.bounds.width - lineWidth) / 2, startAngle: startAngle, endAngle: endAngle, clockwise: true)
|
||||
shapeLayer?.path = path.cgPath
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user