From af4101b1d8461331bc3163b738fc75d4bf67c85c Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期二, 28 七月 2020 17:47:44 +0800
Subject: [PATCH] 2020-07-28-1
---
Shared.IOS/UI/Loading.cs | 273 +++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 196 insertions(+), 77 deletions(-)
diff --git a/Shared.IOS/UI/Loading.cs b/Shared.IOS/UI/Loading.cs
index a4f8f2e..379f32b 100644
--- a/Shared.IOS/UI/Loading.cs
+++ b/Shared.IOS/UI/Loading.cs
@@ -4,76 +4,94 @@
namespace Shared
{
- /// <summary>
- /// Loading UI
- /// </summary>
- public class Loading : View
- {
+ /// <summary>
+ /// Loading UI
+ /// </summary>
+ public class Loading : View
+ {
public bool CurStatus = false;
- internal IosLoading iosLoading
- {
- get
- {
- return uiView as IosLoading;
- }
- set
- {
- uiView = value;
- }
- }
+ internal IosLoading iosLoading
+ {
+ get
+ {
+ return uiView as IosLoading;
+ }
+ set
+ {
+ uiView = value;
+ }
+ }
- /// <summary>
- /// Loading UI
- /// </summary>
- public Loading()
- {
- var bounds = UIScreen.MainScreen.Bounds;
- iosLoading = new IosLoading(bounds);
- }
+ /// <summary>
+ /// Loading UI
+ /// </summary>
+ public Loading()
+ {
+ var bounds = UIScreen.MainScreen.Bounds;
+ iosLoading = new IosLoading(bounds);
+ }
- /// <summary>
- /// 寮�濮嬪綋鍓嶈鍥�
- /// </summary>
- public void Start()
- {
- iosLoading.uiLabel.Text = "Loading......";
- iosLoading.Start();
+ /// <summary>
+ /// 寮�濮嬪綋鍓嶈鍥�
+ /// </summary>
+ public void Start()
+ {
+ Text = "Loading......";
+ iosLoading.Start();
CurStatus = true;
}
- /// <summary>
- /// 寮�濮嬪綋鍓嶈鍥�
- /// </summary>
- public void Start(string s)
- {
- iosLoading.uiLabel.Text = s;
- iosLoading.Start();
+ /// <summary>
+ /// 寮�濮嬪綋鍓嶈鍥�
+ /// </summary>
+ public void Start(string s)
+ {
+ Text = s;
+ iosLoading.Start();
}
- /// <summary>
- /// 闅愯棌褰撳墠瑙嗗浘
- /// </summary>
- public void Hide()
- {
- iosLoading.uiLabel.Text = "Loading......";
+ /// <summary>
+ /// 闅愯棌褰撳墠瑙嗗浘
+ /// </summary>
+ public void Hide()
+ {
+ Text = "Loading......";
iosLoading.Hide();
CurStatus = false;
}
- public string Text
- {
- get
- {
- return iosLoading.uiLabel.Text;
- }
- set
- {
- iosLoading.uiLabel.Text = value;
- }
- }
+ public string Text
+ {
+ get
+ {
+ return iosLoading.uiLabel.Text;
+ }
+ set
+ {
+ iosLoading.uiLabel.Text = value;
+ iosLoading.RefreshWidth();
+
+ }
+ }
+
+ uint mTextColor;
+ public uint TextColor
+ {
+ get
+ {
+ return mTextColor;
+ }
+ set
+ {
+ mTextColor = value;
+ iosLoading.uiLabel.TextColor = HDLUtils.GetUIColorWithUint(mTextColor);
+ }
+ }
+
+
public virtual uint LodingBackgroundColor
{
@@ -86,16 +104,47 @@
(iosLoading as IosLoading).LodingBackgroundColor = value;
}
}
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="mViewStyle">1 涓虹伆鑹�</param>
+ public void SetUIActivityIndicatorViewStyle(int mViewStyle)
+ {
+ (iosLoading as IosLoading).SetUIActivityIndicatorViewStyle(mViewStyle);
+
+ }
+
+ /// <summary>
+ /// 鏂囧瓧澶у皬
+ /// </summary>
+ /// <value>The size of the text.</value>
+ public float TextSize
+ {
+ get
+ {
+ return (float)iosLoading.uiLabel.Font.PointSize;
+ }
+ set
+ {
+ iosLoading.uiLabel.Font = UIFont.FromName(iosLoading.uiLabel.Font.Name, value);
+ }
+ }
+
+
}
- internal class IosLoading : UIView {
-
- UIActivityIndicatorView activitySpinner= new UIActivityIndicatorView(UIActivityIndicatorViewStyle.WhiteLarge);
- public UILabel uiLabel=new UILabel();
- UIView backUIView = new UIView(new CGRect(0, 0, 160, 100));
+ internal class IosLoading : UIView
+ {
+
+ UIActivityIndicatorView activitySpinner = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.WhiteLarge);
+ public UILabel uiLabel = new UILabel();
+ UIView backUIView = new UIView(new CGRect(0, 0, 160, 120));
public IosLoading(CGRect frame)
{
+ BackgroundColor = UIKit.UIColor.FromRGBA(0x32, 0x32, 0x32, 50);
+
Frame = frame;
Hidden = true;
@@ -103,31 +152,34 @@
var f = backUIView.Frame;
f.Width = frame.Width;
- f.Height = frame.Height;
+ //f.Height = frame.Height;
backUIView.Frame = f;
var center = backUIView.Center;
- center.X = Frame.Width / 2;
- center.Y = Frame.Height / 2;
+ center.X = Frame.Width / 2;
+ center.Y = Frame.Height / 2;
backUIView.Center = center;
AddSubview(backUIView);
// create the activity spinner, center it horizontall and put it 5 points above center x
var center1 = activitySpinner.Center;
center1.X = backUIView.Frame.Width / 2;
- center1.Y = (backUIView.Frame.Height - 22) / 2;
+ center1.Y = (backUIView.Frame.Height - 62) / 2 + 20;
activitySpinner.Center = center1;
backUIView.AddSubview(activitySpinner);
activitySpinner.BackgroundColor = UIColor.Clear;
+ activitySpinner.Color = UIColor.Gray;
var frame2 = uiLabel.Frame;
- frame2.Y = activitySpinner.Frame.Bottom+22;
+ frame2.Y = backUIView.Frame.Height - 42;
frame2.Width = backUIView.Frame.Width;
frame2.Height = 22;
uiLabel.Frame = frame2;
uiLabel.BackgroundColor = UIColor.Clear;
- uiLabel.TextColor = UIColor.White;
+ uiLabel.TextColor = UIColor.Gray;
uiLabel.TextAlignment = UITextAlignment.Center;
+ //uiLabel.F
backUIView.AddSubview(uiLabel);
+
}
public void Start()
@@ -136,24 +188,25 @@
{
return;
}
- BackgroundColor = UIKit.UIColor.FromRGBA(0x32, 0x32, 0x32, 0xF0);
+
Hidden = false;
activitySpinner.StartAnimating();
Superview.BringSubviewToFront(this);
}
- /// <summary>
- /// Fades out the control and then removes it from the super view
- /// </summary>
- public void Hide ()
- {
- if(Superview==null){
+ /// <summary>
+ /// Fades out the control and then removes it from the super view
+ /// </summary>
+ public void Hide()
+ {
+ if (Superview == null)
+ {
return;
}
- Hidden = true;
- activitySpinner.StopAnimating ();
- Superview.SendSubviewToBack(this);
- }
+ Hidden = true;
+ activitySpinner.StopAnimating();
+ Superview.SendSubviewToBack(this);
+ }
uint loadingBackgroundColor;
/// <summary>
@@ -186,6 +239,72 @@
}
}
}
+
+ public void SetUIActivityIndicatorViewStyle(int mViewStyle)
+ {
+ if (mViewStyle == 1)
+ {
+ activitySpinner.ActivityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray;
+ }
+ else
+ {
+ activitySpinner.ActivityIndicatorViewStyle = UIActivityIndicatorViewStyle.WhiteLarge;
+ }
+
+ }
+
+ public void RefreshWidth()
+ {
+ int maxTextWidth = GetTextWidth() + 40;
+ if (maxTextWidth > this.Frame.Width - 20)
+ {
+ maxTextWidth = (int)this.Frame.Width - 20;
+ }
+ else if (maxTextWidth < 120)
+ {
+ maxTextWidth = 120;
+ }
+
+ var mFrame = backUIView.Frame;
+ if ((int)mFrame.Width == maxTextWidth)
+ {
+ return;
+ }
+
+ mFrame.Width = maxTextWidth;
+ //f.Height = frame.Height;
+ backUIView.Frame = mFrame;
+ var center = backUIView.Center;
+ center.X = Frame.Width / 2;
+ center.Y = Frame.Height / 2;
+
+ backUIView.Center = center;
+
+ var center1 = activitySpinner.Center;
+ center1.X = backUIView.Frame.Width / 2;
+ activitySpinner.Center = center1;
+
+ var frame2 = uiLabel.Frame;
+ frame2.Width = backUIView.Frame.Width;
+ uiLabel.Frame = frame2;
+ }
+
+ /// <summary>
+ /// 鑾峰彇瀛椾綋闀垮害
+ /// </summary>
+ int GetTextWidth()
+ {
+ try
+ {
+ CGSize fontSize = uiLabel.Text.StringSize(uiLabel.Font);
+ return (int)fontSize.Width;
+ }
+ catch
+ {
+ return 0;
+ }
+ }
+
}
}
--
Gitblit v1.8.0