* Removed SAs

* Fixed SA1119

* Fixed SA1515

* Fixed SA1005

* Removed SA1117

* Fixed SA1515

* Fixed IDE0040

* Fixed SA1128

* Fixed SA1516

* Fixed SA1009

* Fixed SA1028

* Changed Space to Tabs

* Removed SA1132

* Fixed SA1313

* Fixed 1408

* Fixed 1107

* Fixed SA1517

* Fixed SA1500

* Fixed indentation

* Fixed 1407

* Removed SA1209

* Fixed SA1212

* Fixed SA1312

* Fixed SA1505

* Fixed SA1510

* Fixed SA1519

* Fixed CS8632

Co-authored-by: Andrei <andrei.misiukevich@gmail.com>
This commit is contained in:
Pedro Jesus 2020-09-17 06:02:12 -03:00 коммит произвёл GitHub
Родитель 004c161a3c
Коммит 0e93d82cc8
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
36 изменённых файлов: 161 добавлений и 121 удалений

Просмотреть файл

@ -49,23 +49,23 @@
<Rule Id="SA1113" Action="Warning" />
<Rule Id="SA1114" Action="Warning" />
<Rule Id="SA1115" Action="Warning" />
<Rule Id="SA1116" Action="Warning" />
<Rule Id="SA1117" Action="Warning" />
<Rule Id="SA1118" Action="Warning" />
<Rule Id="SA1116" Action="None" />
<Rule Id="SA1117" Action="None" />
<Rule Id="SA1118" Action="None" />
<Rule Id="SA1119" Action="Warning" />
<Rule Id="SA1120" Action="Warning" />
<Rule Id="SA1121" Action="Warning" />
<Rule Id="SA1122" Action="Warning" />
<Rule Id="SA1123" Action="Warning" />
<Rule Id="SA1124" Action="Warning" />
<Rule Id="SA1124" Action="None" />
<Rule Id="SA1125" Action="Warning" />
<Rule Id="SA1126" Action="Warning" />
<Rule Id="SA1127" Action="Warning" />
<Rule Id="SA1127" Action="None" />
<Rule Id="SA1128" Action="Warning" />
<Rule Id="SA1129" Action="Warning" />
<Rule Id="SA1130" Action="Warning" />
<Rule Id="SA1131" Action="Warning" />
<Rule Id="SA1132" Action="Warning" />
<Rule Id="SA1132" Action="None" />
<Rule Id="SA1133" Action="Warning" />
<Rule Id="SA1134" Action="Warning" />
<Rule Id="SA1135" Action="Warning" />
@ -76,17 +76,17 @@
<Rule Id="SA1201" Action="None" />
<Rule Id="SA1202" Action="None" />
<Rule Id="SA1203" Action="Warning" />
<Rule Id="SA1204" Action="Warning" />
<Rule Id="SA1204" Action="None" />
<Rule Id="SA1205" Action="Warning" />
<Rule Id="SA1206" Action="Warning" />
<Rule Id="SA1207" Action="Warning" />
<Rule Id="SA1208" Action="Warning" />
<Rule Id="SA1209" Action="Warning" />
<Rule Id="SA1210" Action="Warning" />
<Rule Id="SA1211" Action="Warning" />
<Rule Id="SA1208" Action="None" />
<Rule Id="SA1209" Action="None" />
<Rule Id="SA1210" Action="None" />
<Rule Id="SA1211" Action="None" />
<Rule Id="SA1212" Action="Warning" />
<Rule Id="SA1213" Action="Warning" />
<Rule Id="SA1214" Action="Warning" />
<Rule Id="SA1214" Action="None" />
<Rule Id="SA1215" Action="Warning" />
<Rule Id="SA1216" Action="Warning" />
<Rule Id="SA1217" Action="Warning" />
@ -136,9 +136,9 @@
<Rule Id="SA1515" Action="Warning" />
<Rule Id="SA1516" Action="Warning" />
<Rule Id="SA1517" Action="Warning" />
<Rule Id="SA1518" Action="Warning" />
<Rule Id="SA1518" Action="None" />
<Rule Id="SA1519" Action="Warning" />
<Rule Id="SA1520" Action="Warning" />
<Rule Id="SA1520" Action="None" />
<Rule Id="SA1600" Action="None" />
<Rule Id="SA1601" Action="None" />
<Rule Id="SA1602" Action="None" />

Просмотреть файл

@ -6,6 +6,7 @@ namespace Xamarin.CommunityToolkit.Behaviors
public class FlipHorizontalAnimation : RotateAnimation
{
protected override double DefaultRotation { get; set; } = 90;
protected override uint DefaultDuration { get; set; } = 300;
public override async Task Animate(View view)

Просмотреть файл

@ -18,6 +18,7 @@ namespace Xamarin.CommunityToolkit.Behaviors
=> ((RotateAnimation)bindable).DefaultRotation;
protected override uint DefaultDuration { get; set; } = 200;
protected virtual double DefaultRotation { get; set; } = 180.0;
public override async Task Animate(View view)

Просмотреть файл

@ -63,8 +63,10 @@ namespace Xamarin.CommunityToolkit.Behaviors
var list = new Dictionary<int, char>();
for (var i = 0; i < Mask.Length; i++)
{
if (Mask[i] != UnMaskedCharacter)
list.Add(i, Mask[i]);
}
positions = list;
}
@ -99,7 +101,6 @@ namespace Xamarin.CommunityToolkit.Behaviors
{
if (!string.IsNullOrWhiteSpace(text) && positions != null)
{
if (text.Length > Mask.Length)
text = text.Remove(text.Length - 1);
@ -111,7 +112,7 @@ namespace Xamarin.CommunityToolkit.Behaviors
var value = position.Value.ToString();
//!important - If user types in masked value, don't add masked value
// !important - If user types in masked value, don't add masked value
if (text.Substring(position.Key, 1) != value)
text = text.Insert(position.Key, value);
}

Просмотреть файл

@ -33,6 +33,7 @@ namespace Xamarin.CommunityToolkit.Behaviors
{
// Use IdnMapping class to convert Unicode domain names.
var idn = new IdnMapping();
// Pull out and process domain name (throws ArgumentException on invalid)
var domainName = idn.GetAscii(match.Groups[2].Value);
return match.Groups[1].Value + domainName;

Просмотреть файл

@ -60,16 +60,22 @@ namespace Xamarin.CommunityToolkit.Behaviors
void OnChildrenCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
if (e.NewItems != null)
{
foreach (var child in e.NewItems.OfType<ValidationBehavior>())
{
child.SetBinding(BindingContextProperty, new Binding
{
Path = BindingContextProperty.PropertyName,
Source = this
});
}
}
if (e.OldItems != null)
{
foreach (var child in e.OldItems.OfType<ValidationBehavior>())
child.RemoveBinding(BindingContextProperty);
}
}
}
}

Просмотреть файл

@ -168,7 +168,7 @@ namespace Xamarin.CommunityToolkit.Behaviors
{
if ((View?.IsFocused ?? false) && Flags.HasFlag(ValidationFlags.ForceMakeValidWhenFocused))
IsValid = true;
else if (isForced || currentStatus != ValidationFlags.None && Flags.HasFlag(currentStatus))
else if (isForced || (currentStatus != ValidationFlags.None && Flags.HasFlag(currentStatus)))
IsValid = Validate(DecorateValue());
UpdateStyle();

Просмотреть файл

@ -20,12 +20,12 @@ namespace Xamarin.CommunityToolkit.Converters
/// <summary>
/// The object that corresponds to True value.
/// </summary>
public TObject TrueObject { set; get; }
public TObject TrueObject { get; set; }
/// <summary>
/// The object that corresponds to False value.
/// </summary>
public TObject FalseObject { set; get; }
public TObject FalseObject { get; set; }
/// <summary>
/// Converts boolean to object.

Просмотреть файл

@ -48,7 +48,7 @@ namespace Xamarin.CommunityToolkit.Converters
for (var i = 0; i < array.Length; i++)
{
var item = array.GetValue(i);
if (item != null && item.Equals(value) || item == null && value == null)
if ((item != null && item.Equals(value)) || (item == null && value == null))
return i;
}

Просмотреть файл

@ -1,5 +1,4 @@

namespace Xamarin.CommunityToolkit.Converters
namespace Xamarin.CommunityToolkit.Converters
{
/// <summary>
/// The text case that the TextCaseConverter should convert a value.

Просмотреть файл

@ -7,6 +7,7 @@ using Effects = Xamarin.CommunityToolkit.iOS.Effects;
[assembly: ResolutionGroupName(nameof(Xamarin.CommunityToolkit))]
[assembly: ExportEffect(typeof(Effects.SafeAreaEffectRouter), nameof(SafeAreaEffectRouter))]
namespace Xamarin.CommunityToolkit.iOS.Effects
{
public class SafeAreaEffectRouter : PlatformEffect
@ -34,8 +35,7 @@ namespace Xamarin.CommunityToolkit.iOS.Effects
initialMargin.Left + (safeArea.Left ? insets.Left : 0),
initialMargin.Top + (safeArea.Top ? insets.Top : 0),
initialMargin.Right + (safeArea.Right ? insets.Right : 0),
initialMargin.Bottom + (safeArea.Bottom ? insets.Bottom : 0)
);
initialMargin.Bottom + (safeArea.Bottom ? insets.Bottom : 0));
}
protected override void OnDetached()

Просмотреть файл

@ -9,7 +9,9 @@ namespace Xamarin.CommunityToolkit.Extensions
public class TranslateExtension : IMarkupExtension<BindingBase>
{
public string Text { get; set; }
public string StringFormat { get; set; }
object IMarkupExtension.ProvideValue(IServiceProvider serviceProvider) => ProvideValue(serviceProvider);
public BindingBase ProvideValue(IServiceProvider serviceProvider)

Просмотреть файл

@ -6,35 +6,35 @@ using System.Threading;
namespace Xamarin.CommunityToolkit.Helpers
{
#if !NETSTANDARD1_0
public class LocalizationResourceManager : INotifyPropertyChanged
{
public static LocalizationResourceManager Current { get; } = new LocalizationResourceManager();
public class LocalizationResourceManager : INotifyPropertyChanged
{
public static LocalizationResourceManager Current { get; } = new LocalizationResourceManager();
ResourceManager resourceManager;
ResourceManager resourceManager;
public void Init(ResourceManager resource)
public void Init(ResourceManager resource)
{
resourceManager = resource;
}
resourceManager = resource;
}
public string this[string text] => resourceManager.GetString(text, CurrentCulture);
public string this[string text] => resourceManager.GetString(text, CurrentCulture);
public void SetCulture(CultureInfo language)
{
Thread.CurrentThread.CurrentUICulture = language;
Invalidate();
}
public void SetCulture(CultureInfo language)
{
Thread.CurrentThread.CurrentUICulture = language;
Invalidate();
}
public string GetValue(string text)=> resourceManager.GetString(text, CultureInfo.CurrentCulture);
public CultureInfo CurrentCulture => Thread.CurrentThread.CurrentUICulture;
public string GetValue(string text) => resourceManager.GetString(text, CultureInfo.CurrentCulture);
public event PropertyChangedEventHandler PropertyChanged;
public CultureInfo CurrentCulture => Thread.CurrentThread.CurrentUICulture;
public void Invalidate()
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(null));
}
}
public event PropertyChangedEventHandler PropertyChanged;
public void Invalidate()
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(null));
}
}
#endif
}

Просмотреть файл

@ -9,18 +9,23 @@ namespace Xamarin.CommunityToolkit.Helpers
readonly bool isParameterized;
public bool Left { get; }
public bool Top { get; }
public bool Right { get; }
public bool Bottom { get; }
public bool IsEmpty
=> !Left && !Top && !Right && !Bottom;
public SafeArea(bool uniformSafeArea) : this(uniformSafeArea, uniformSafeArea, uniformSafeArea, uniformSafeArea)
public SafeArea(bool uniformSafeArea)
: this(uniformSafeArea, uniformSafeArea, uniformSafeArea, uniformSafeArea)
{
}
public SafeArea(bool horizontal, bool vertical) : this(horizontal, vertical, horizontal, vertical)
public SafeArea(bool horizontal, bool vertical)
: this(horizontal, vertical, horizontal, vertical)
{
}

Просмотреть файл

@ -4,6 +4,8 @@ using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
#nullable enable
namespace Xamarin.CommunityToolkit.ObjectModel
{
/// <summary>
@ -97,7 +99,7 @@ namespace Xamarin.CommunityToolkit.ObjectModel
{
if (!Items.Remove(changedItems[i]))
{
changedItems.RemoveAt(i); //Can't use a foreach because changedItems is intended to be (carefully) modified
changedItems.RemoveAt(i); // Can't use a foreach because changedItems is intended to be (carefully) modified
i--;
}
}

Просмотреть файл

@ -7,7 +7,8 @@ namespace Xamarin.CommunityToolkit.UI.Views
{
const string emptyText = "X";
static readonly Color[] colors = {
static readonly Color[] colors =
{
RGB(69, 43, 103),
RGB(119, 78, 133),
RGB(211, 153, 184),
@ -18,7 +19,8 @@ namespace Xamarin.CommunityToolkit.UI.Views
RGB(143, 52, 87)
};
static readonly Color[] textColors = {
static readonly Color[] textColors =
{
RGB(255, 255, 255),
RGB(255, 255, 255),
RGB(255, 255, 255),

Просмотреть файл

@ -23,6 +23,7 @@ namespace Xamarin.CommunityToolkit.UI.Views
: this(context, attrs, 0)
{
}
public AutoFitTextureView(Context context, IAttributeSet attrs, int defStyle)
: base(context, attrs, defStyle)
{
@ -73,7 +74,7 @@ namespace Xamarin.CommunityToolkit.UI.Views
UnlockCanvasAndPost(canvas);
}
Invalidate();
};
}
}
}
}

Просмотреть файл

@ -66,7 +66,9 @@ namespace Xamarin.CommunityToolkit.UI.Views
Handler backgroundHandler = null;
float zoom = 1;
bool ZoomSupported => maxDigitalZoom != 0;
float maxDigitalZoom;
Rect activeRect;
@ -75,9 +77,11 @@ namespace Xamarin.CommunityToolkit.UI.Views
bool UseSystemSound { get; set; }
CameraManager manager;
CameraManager Manager => manager ??= (CameraManager)Context.GetSystemService(Context.CameraService);
MediaActionSound mediaSound;
MediaActionSound MediaSound => mediaSound ??= new MediaActionSound();
TaskCompletionSource<CameraDevice> initTaskSource;
@ -87,7 +91,8 @@ namespace Xamarin.CommunityToolkit.UI.Views
{
}
public CameraFragment(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer)
public CameraFragment(IntPtr javaReference, JniHandleOwnership transfer)
: base(javaReference, transfer)
{
}
@ -190,7 +195,8 @@ namespace Xamarin.CommunityToolkit.UI.Views
{
IsBusy = false;
captureSessionOpenCloseLock.Release();
//_texture.ClearCanvas(Element.BackgroundColor.ToAndroid()); // HANG after select valid camera...
// _texture.ClearCanvas(Element.BackgroundColor.ToAndroid()); // HANG after select valid camera...
Element.RaiseMediaCaptureFailed($"No {Element.CameraOptions} camera found");
}
else
@ -396,7 +402,6 @@ namespace Xamarin.CommunityToolkit.UI.Views
{
if (IsBusy)
return;
else if (IsRecordingVideo)
{
Element?.RaiseMediaCaptureFailed("Video already recording.");
@ -479,10 +484,11 @@ namespace Xamarin.CommunityToolkit.UI.Views
if (cameraTemplate == CameraTemplate.Record)
{
SetupMediaRecorder(previewSurface);
var _mediaSurface = mediaRecorder.Surface;
surfaces.Add(_mediaSurface);
sessionBuilder.AddTarget(_mediaSurface);
var mediaSurface = mediaRecorder.Surface;
surfaces.Add(mediaSurface);
sessionBuilder.AddTarget(mediaSurface);
}
// photo mode
else
{
@ -839,7 +845,7 @@ namespace Xamarin.CommunityToolkit.UI.Views
};
int GetPreviewOrientation() =>
(GetDisplayRotation()) switch
GetDisplayRotation() switch
{
SurfaceOrientation.Rotation90 => 270,
SurfaceOrientation.Rotation180 => 180,
@ -882,16 +888,16 @@ namespace Xamarin.CommunityToolkit.UI.Views
mediaSound.Play(soundType);
}
ASize GetMaxSize(ASize[] ImageSizes)
ASize GetMaxSize(ASize[] imageSizes)
{
ASize maxSize = null;
long maxPixels = 0;
for (var i = 0; i < ImageSizes.Length; i++)
for (var i = 0; i < imageSizes.Length; i++)
{
long currentPixels = ImageSizes[i].Width * ImageSizes[i].Height;
long currentPixels = imageSizes[i].Width * imageSizes[i].Height;
if (currentPixels > maxPixels)
{
maxSize = ImageSizes[i];
maxSize = imageSizes[i];
maxPixels = currentPixels;
}
}
@ -912,6 +918,7 @@ namespace Xamarin.CommunityToolkit.UI.Views
bigEnough.Add(option);
}
}
// Pick the smallest of those, assuming we found any
if (bigEnough.Count > 0)
{

Просмотреть файл

@ -36,7 +36,8 @@ namespace Xamarin.CommunityToolkit.UI.Views
CameraFragment camerafragment;
public CameraViewRenderer(Context context) : base(context)
public CameraViewRenderer(Context context)
: base(context)
{
motionEventHelper = new MotionEventHelper();
visualElementRenderer = new VisualElementRenderer(this);
@ -73,14 +74,15 @@ namespace Xamarin.CommunityToolkit.UI.Views
if (Element.CaptureOptions == CameraCaptureOptions.Video)
camerafragment.UpdateRepeatingRequest();
break;
//case nameof(CameraView.PreviewAspect):
//case "MirrorFrontPreview":
// camerafragment?.ConfigureTransform();
// break;
//case nameof(CameraView.KeepScreenOn):
// if (camerafragment != null)
// camerafragment.KeepScreenOn = Element.KeepScreenOn;
// break;
// case nameof(CameraView.PreviewAspect):
// case "MirrorFrontPreview":
// camerafragment?.ConfigureTransform();
// break;
// case nameof(CameraView.KeepScreenOn):
// if (camerafragment != null)
// camerafragment.KeepScreenOn = Element.KeepScreenOn;
// break;
}
}
@ -128,7 +130,7 @@ namespace Xamarin.CommunityToolkit.UI.Views
// this is just used to set ID's to the NativeViews along time ago for UITest with Test Cloud
// https://discordapp.com/channels/732297728826277939/738043671575920700/747629874709266449
//element?.SendViewInitialized(this); // this is internal
// element?.SendViewInitialized(this); // this is internal
}
}
@ -239,7 +241,7 @@ namespace Xamarin.CommunityToolkit.UI.Views
if (!(element is CameraView camera))
throw new ArgumentException($"{nameof(element)} must be of type {nameof(CameraView)}");
//Performance.Start(out var reference);
// Performance.Start(out var reference);
motionEventHelper.UpdateElement(element);
@ -248,7 +250,7 @@ namespace Xamarin.CommunityToolkit.UI.Views
Element = camera;
//Performance.Stop(reference);
// Performance.Stop(reference);
}
void IVisualElementRenderer.SetLabelFor(int? id)

Просмотреть файл

@ -24,7 +24,6 @@ namespace Xamarin.CommunityToolkit.UI.Views
}
catch (Exception)
{
}
finally
{

Просмотреть файл

@ -19,7 +19,7 @@ namespace Xamarin.CommunityToolkit.UI.Views
return false;
// Let the container know that we're "fake" handling this event
//renderer.NotifyFakeHandling();
// renderer.NotifyFakeHandling();
return true;
}
@ -34,7 +34,7 @@ namespace Xamarin.CommunityToolkit.UI.Views
// Determine whether this control is inside a ViewCell;
// we don't fake handle the events because ListView needs them for row selection
//isInViewCell = element.IsInViewCell();
// isInViewCell = element.IsInViewCell();
}
bool ShouldPassThroughElement()
@ -46,7 +46,7 @@ namespace Xamarin.CommunityToolkit.UI.Views
return false;
// This is a layout, and it's transparent, and all its children are transparent, then the event
// can just pass through
// can just pass through
if (layout.CascadeInputTransparent)
return true;
@ -54,7 +54,7 @@ namespace Xamarin.CommunityToolkit.UI.Views
return true;
}
// This is not a layout and it's transparent; the event can just pass through
// This is not a layout and it's transparent; the event can just pass through
if (element.InputTransparent)
return true;

Просмотреть файл

@ -72,13 +72,13 @@ namespace Xamarin.CommunityToolkit.UI.Views
}
// Only supported by Android, removed until we have platform specifics
//public static readonly BindableProperty PreviewAspectProperty = BindableProperty.Create(nameof(PreviewAspect), typeof(Aspect), typeof(CameraView), Aspect.AspectFit);
// public static readonly BindableProperty PreviewAspectProperty = BindableProperty.Create(nameof(PreviewAspect), typeof(Aspect), typeof(CameraView), Aspect.AspectFit);
//public Aspect PreviewAspect
//{
// get => (Aspect)GetValue(PreviewAspectProperty);
// set => SetValue(PreviewAspectProperty, value);
//}
// public Aspect PreviewAspect
// {
// get => (Aspect)GetValue(PreviewAspectProperty);
// set => SetValue(PreviewAspectProperty, value);
// }
public static readonly BindableProperty ZoomProperty = BindableProperty.Create(nameof(Zoom), typeof(double), typeof(CameraView), 1d);

Просмотреть файл

@ -6,8 +6,8 @@ namespace Xamarin.CommunityToolkit.UI.Views
{
public class MediaCapturedEventArgs : EventArgs
{
private readonly Lazy<ImageSource> imageSource;
private readonly Lazy<MediaSource> mediaSource;
readonly Lazy<ImageSource> imageSource;
readonly Lazy<MediaSource> mediaSource;
internal MediaCapturedEventArgs(
string path = null,
@ -23,6 +23,7 @@ namespace Xamarin.CommunityToolkit.UI.Views
/// Path of the saved file, only filled when taking a video or a picture and SavePhotoToFile is true
/// </summary>
public string Path { get; }
/// <summary>
/// Raw image data, only filled when taking a picture and SavePhotoToFile is false
/// </summary>
@ -32,13 +33,13 @@ namespace Xamarin.CommunityToolkit.UI.Views
public MediaSource Video => mediaSource.Value;
private ImageSource GetImageSource()
ImageSource GetImageSource()
{
if (ImageData != null)
return ImageSource.FromStream(() => new MemoryStream(ImageData));
return !string.IsNullOrEmpty(Path) ? Path : null;
}
private MediaSource GetMediaSource() => !string.IsNullOrEmpty(Path) ? Path : null;
MediaSource GetMediaSource() => !string.IsNullOrEmpty(Path) ? Path : null;
}
}

Просмотреть файл

@ -23,6 +23,7 @@ using Xamarin.Forms.Platform.UWP;
using MediaSource = Xamarin.Forms.MediaSource;
[assembly: ExportRenderer(typeof(CameraView), typeof(CameraViewRenderer))]
namespace Xamarin.CommunityToolkit.UI.Views
{
public class CameraViewRenderer : ViewRenderer<CameraView, CaptureElement>
@ -138,8 +139,8 @@ namespace Xamarin.CommunityToolkit.UI.Views
string filePath = null;
if (Element.SavePhotoToFile)
{
//TODO replace platform specifics
//var localFolder = Element.OnThisPlatform().GetPhotoFolder();
// TODO replace platform specifics
// var localFolder = Element.OnThisPlatform().GetPhotoFolder();
var localFolder = "PhotoFolder";
var destinationFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(localFolder, CreationCollisionOption.OpenIfExists);
var file = await destinationFolder.CreateFileAsync($"{DateTime.Now.ToString("yyyyddMM_HHmmss")}.jpg", CreationCollisionOption.GenerateUniqueName);
@ -171,8 +172,8 @@ namespace Xamarin.CommunityToolkit.UI.Views
async Task StartRecord()
{
//TODO replace platform specifics
//var localFolder = Element.On<PlatformConfiguration.Windows>().GetVideoFolder();
// TODO replace platform specifics
// var localFolder = Element.On<PlatformConfiguration.Windows>().GetVideoFolder();
var localFolder = "Video";
var destinationFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(localFolder, CreationCollisionOption.OpenIfExists);
var file = await destinationFolder.CreateFileAsync($"{DateTime.Now.ToString("yyyyddMM_HHmmss")}.mp4", CreationCollisionOption.GenerateUniqueName);
@ -244,10 +245,11 @@ namespace Xamarin.CommunityToolkit.UI.Views
if (flash != null)
flash.IsEnabled = Element.FlashMode == CameraFlashMode.Torch || Element.FlashMode == CameraFlashMode.On;
break;
// Only supported by Android, removed until we have platform specifics
//case nameof(CameraView.PreviewAspect):
// // TODO
// break;
// case nameof(CameraView.PreviewAspect):
// // TODO
// break;
case nameof(CameraView.Zoom):
UpdateZoom();
break;
@ -263,7 +265,7 @@ namespace Xamarin.CommunityToolkit.UI.Views
var settings = new ZoomSettings
{
//TODO replace clamp
// TODO replace clamp
Value = Clamp(Element.Zoom, zoomControl.Min, zoomControl.Max),
Mode = zoomControl.SupportedModes.Contains(ZoomTransitionMode.Smooth)
? ZoomTransitionMode.Smooth

Просмотреть файл

@ -9,6 +9,7 @@ using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(CameraView), typeof(CameraViewRenderer))]
namespace Xamarin.CommunityToolkit.UI.Views
{
public class CameraViewRenderer : ViewRenderer<CameraView, FormsCameraView>
@ -137,7 +138,7 @@ namespace Xamarin.CommunityToolkit.UI.Views
PHImageManager.DefaultManager.RequestAvAsset(asset, new PHVideoRequestOptions
{
Version = PHVideoRequestOptionsVersion.Original
}, ((avAsset, mix, info) =>
}, (avAsset, mix, info) =>
{
if (!(avAsset is AVUrlAsset urlAsset))
{
@ -148,7 +149,7 @@ namespace Xamarin.CommunityToolkit.UI.Views
{
Element.RaiseMediaCaptured(new MediaCapturedEventArgs(urlAsset.Url.Path));
});
}));
});
}
});
});

Просмотреть файл

@ -27,7 +27,9 @@ namespace Xamarin.CommunityToolkit.UI.Views
readonly float imgScale = 1f;
public event EventHandler<bool> Busy;
public event EventHandler<bool> Available;
public event EventHandler<Tuple<NSObject, NSError>> FinishCapture;
public bool VideoRecorded => videoOutput?.Recording == true;
@ -189,6 +191,7 @@ namespace Xamarin.CommunityToolkit.UI.Views
return;
IsBusy = true;
// iOS >= 10
if (photoOutput != null)
{
@ -213,6 +216,7 @@ namespace Xamarin.CommunityToolkit.UI.Views
photoOutput.CapturePhoto(photoSettings, photoCaptureDelegate);
return;
}
// iOS < 10
try
{

Просмотреть файл

@ -1,5 +1,4 @@

namespace Xamarin.CommunityToolkit.UI.Views
namespace Xamarin.CommunityToolkit.UI.Views
{
public enum ExpandDirection
{

Просмотреть файл

@ -1,5 +1,4 @@

namespace Xamarin.CommunityToolkit.UI.Views
namespace Xamarin.CommunityToolkit.UI.Views
{
static class ExpandDirectionExtensions
{

Просмотреть файл

@ -1,5 +1,4 @@

namespace Xamarin.CommunityToolkit.UI.Views
namespace Xamarin.CommunityToolkit.UI.Views
{
public enum ExpandState
{

Просмотреть файл

@ -90,6 +90,7 @@ namespace Xamarin.CommunityToolkit.UI.Views
? layout.Padding.VerticalThickness
: layout.Padding.HorizontalThickness);
}
set
{
if (Direction.IsVertical())

Просмотреть файл

@ -397,7 +397,7 @@ namespace Xamarin.CommunityToolkit.UI.Views
var trackWidth = TrackWidth;
lowerTranslation = (LowerValue - MinimumValue) / rangeValue * trackWidth;
upperTranslation = (UpperValue - MinimumValue) / rangeValue * trackWidth + LowerThumb.Width;
upperTranslation = ((UpperValue - MinimumValue) / rangeValue * trackWidth) + LowerThumb.Width;
LowerThumb.TranslationX = lowerTranslation;
UpperThumb.TranslationX = upperTranslation;
@ -410,8 +410,8 @@ namespace Xamarin.CommunityToolkit.UI.Views
void OnValueLabelTranslationChanged()
{
var labelSpacing = 5;
var lowerLabelTranslation = lowerTranslation + (LowerThumb.Width - LowerValueLabel.Width) / 2;
var upperLabelTranslation = upperTranslation + (UpperThumb.Width - UpperValueLabel.Width) / 2;
var lowerLabelTranslation = lowerTranslation + ((LowerThumb.Width - LowerValueLabel.Width) / 2);
var upperLabelTranslation = upperTranslation + ((UpperThumb.Width - UpperValueLabel.Width) / 2);
LowerValueLabel.TranslationX = Min(Max(lowerLabelTranslation, 0), Width - LowerValueLabel.Width - UpperValueLabel.Width - labelSpacing);
UpperValueLabel.TranslationX = Min(Max(upperLabelTranslation, LowerValueLabel.TranslationX + LowerValueLabel.Width + labelSpacing), Width - UpperValueLabel.Width);
}
@ -456,9 +456,9 @@ namespace Xamarin.CommunityToolkit.UI.Views
labelWithSpacingHeight += ValueLabelSpacing;
var trackThumbHeight = Max(Max(lowerThumbSize, upperThumbSize), trackSize);
var trackVerticalPosition = labelWithSpacingHeight + (trackThumbHeight - trackSize) / 2;
var lowerThumbVerticalPosition = labelWithSpacingHeight + (trackThumbHeight - lowerThumbSize) / 2;
var upperThumbVerticalPosition = labelWithSpacingHeight + (trackThumbHeight - upperThumbSize) / 2;
var trackVerticalPosition = labelWithSpacingHeight + ((trackThumbHeight - trackSize) / 2);
var lowerThumbVerticalPosition = labelWithSpacingHeight + ((trackThumbHeight - lowerThumbSize) / 2);
var upperThumbVerticalPosition = labelWithSpacingHeight + ((trackThumbHeight - upperThumbSize) / 2);
if (Control != null)
Control.HeightRequest = labelWithSpacingHeight + trackThumbHeight;
@ -536,10 +536,10 @@ namespace Xamarin.CommunityToolkit.UI.Views
var rangeValue = MaximumValue - MinimumValue;
if (view == LowerThumb)
{
LowerValue = Min(Max(MinimumValue, value / TrackWidth * rangeValue + MinimumValue), UpperValue);
LowerValue = Min(Max(MinimumValue, (value / TrackWidth * rangeValue) + MinimumValue), UpperValue);
return;
}
UpperValue = Min(Max(LowerValue, (value - LowerThumb.Width) / TrackWidth * rangeValue + MinimumValue), MaximumValue);
UpperValue = Min(Max(LowerValue, ((value - LowerThumb.Width) / TrackWidth * rangeValue) + MinimumValue), MaximumValue);
}
double GetPanShiftValue(View view)

Просмотреть файл

@ -1,5 +1,4 @@

namespace Xamarin.CommunityToolkit.UI.Views
namespace Xamarin.CommunityToolkit.UI.Views
{
public enum SideMenuPosition
{

Просмотреть файл

@ -1,5 +1,4 @@

namespace Xamarin.CommunityToolkit.UI.Views
namespace Xamarin.CommunityToolkit.UI.Views
{
public enum SideMenuState
{

Просмотреть файл

@ -369,8 +369,8 @@ namespace Xamarin.CommunityToolkit.UI.Views
if (Sign(shift) != -(int)state)
state = SideMenuState.MainViewShown;
if (state == SideMenuState.MainViewShown && absShift <= moveThreshold ||
state != SideMenuState.MainViewShown && absShift < menuWidth - moveThreshold)
if ((state == SideMenuState.MainViewShown && absShift <= moveThreshold) ||
(state != SideMenuState.MainViewShown && absShift < menuWidth - moveThreshold))
{
CurrentGestureState = SideMenuState.MainViewShown;
return;
@ -478,8 +478,10 @@ namespace Xamarin.CommunityToolkit.UI.Views
{
var time = timeShiftItems.LastOrDefault().Time;
for (var i = timeShiftItems.Count - 1; i >= 0; --i)
{
if (time - timeShiftItems[i].Time > swipeThresholdTime)
timeShiftItems.RemoveAt(i);
}
}
void OnChildrenCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
@ -491,8 +493,10 @@ namespace Xamarin.CommunityToolkit.UI.Views
void HandleChildren(IList items, Action<View> action)
{
if (items != null)
{
foreach (var item in items)
action?.Invoke((View)item);
}
}
void AddChild(View view)

Просмотреть файл

@ -9,6 +9,7 @@ using Xamarin.Forms.Platform.Android;
using static System.Math;
[assembly: ExportRenderer(typeof(SideMenuView), typeof(SideMenuViewRenderer))]
namespace Xamarin.CommunityToolkit.Android.UI.Views
{
[Preserve(AllMembers = true)]
@ -26,7 +27,8 @@ namespace Xamarin.CommunityToolkit.Android.UI.Views
float? startY;
public SideMenuViewRenderer(Context context) : base(context)
public SideMenuViewRenderer(Context context)
: base(context)
=> density = context.Resources.DisplayMetrics.Density;
public override bool OnInterceptTouchEvent(MotionEvent ev)

Просмотреть файл

@ -7,6 +7,7 @@ using Xamarin.Forms.Platform.iOS;
using static System.Math;
[assembly: ExportRenderer(typeof(SideMenuView), typeof(SideMenuViewRenderer))]
namespace Xamarin.CommunityToolkit.iOS.UI.Views
{
[Preserve(AllMembers = true)]