From 64a0698e7f2186ccd18e1cafa287d3f641c5e9f0 Mon Sep 17 00:00:00 2001 From: Adam-Langley Date: Sat, 8 May 2021 16:34:04 +1200 Subject: [PATCH 1/4] Added button labels --- .../ViewController.cs | 9 ++--- .../LiquidFloatingCell.cs | 34 +++++++++++++++++++ 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/iOS/LiquidFloatingActionButton/samples/LiquidFloatingActionButtonSample/ViewController.cs b/iOS/LiquidFloatingActionButton/samples/LiquidFloatingActionButtonSample/ViewController.cs index 1e361ee314..c5e2ee6f2d 100644 --- a/iOS/LiquidFloatingActionButton/samples/LiquidFloatingActionButtonSample/ViewController.cs +++ b/iOS/LiquidFloatingActionButton/samples/LiquidFloatingActionButtonSample/ViewController.cs @@ -21,12 +21,13 @@ public ViewController(IntPtr handle) public override void ViewDidLoad() { base.ViewDidLoad(); - + + var font = UIFont.SystemFontOfSize(10); var cells = new List { - new LiquidFloatingCell(UIImage.FromBundle("ic_cloud")), - new LiquidFloatingCell(UIImage.FromBundle("ic_system")), - new LiquidFloatingCell(UIImage.FromBundle("ic_place")), + new LiquidFloatingCell(UIImage.FromBundle("ic_cloud"), "cloud").TitleFont(font).TitleColor(UIColor.White), + new LiquidFloatingCell(UIImage.FromBundle("ic_system"), "system").TitleFont(font).TitleColor(UIColor.White), + new LiquidFloatingCell(UIImage.FromBundle("ic_place"), "place").TitleFont(font).TitleColor(UIColor.White), }; topLeftButton.Image = UIImage.FromBundle("ic_art"); diff --git a/iOS/LiquidFloatingActionButton/source/LiquidFloatingActionButton/LiquidFloatingCell.cs b/iOS/LiquidFloatingActionButton/source/LiquidFloatingActionButton/LiquidFloatingCell.cs index c63ceefaa0..ea8e0f9c79 100644 --- a/iOS/LiquidFloatingActionButton/source/LiquidFloatingActionButton/LiquidFloatingCell.cs +++ b/iOS/LiquidFloatingActionButton/source/LiquidFloatingActionButton/LiquidFloatingCell.cs @@ -31,6 +31,8 @@ public class LiquidFloatingCell : LiquittableCircle public UIView View { get; private set; } + public UILabel Label { get; private set; } + public LiquidFloatingActionButton ActionButton { get @@ -54,6 +56,14 @@ public override void LayoutSubviews() var offset = (Frame.Width - radius) / 2f; imageView.Frame = new CGRect(offset, offset, radius, radius); } + + if (Label != null) + { + var radius = Frame.Width * imageRatio; + var offset = (Frame.Width - radius) / 2f; + var size = (Label.Text + " ").StringSize(Label.Font); + Label.Frame = new CGRect(-size.Width, (Frame.Height - size.Height) / 2, size.Width, size.Height); + } } public LiquidFloatingCell(UIImage icon) @@ -61,6 +71,12 @@ public LiquidFloatingCell(UIImage icon) Setup(icon); } + public LiquidFloatingCell(UIImage icon, string title) + { + Setup(icon); + SetupLabel(title); + } + public LiquidFloatingCell(UIImage icon, nfloat imageRatio) { this.imageRatio = imageRatio; @@ -72,6 +88,12 @@ public LiquidFloatingCell(UIView view) SetupView(view); } + private void SetupLabel(string title) + { + Label = new UILabel() { Text = title, Alpha = 0 }; + AddSubview(Label); + } + private void Setup(UIImage image, UIColor tintColor = null) { imageView = new UIImageView(); @@ -129,5 +151,17 @@ public override void TouchesEnded(NSSet touches, UIEvent evt) button.OnCellSelected(this); } } + + public LiquidFloatingCell TitleFont(UIFont font) + { + Label.Font = font; + return this; + } + + public LiquidFloatingCell TitleColor(UIColor color) + { + Label.TextColor = color; + return this; + } } } From 2b3dd8c5ff3686aab57dda251deb3872068a9e15 Mon Sep 17 00:00:00 2001 From: Adam-Langley Date: Sat, 8 May 2021 17:00:10 +1200 Subject: [PATCH 2/4] Ability position label left or right of button --- .../ViewController.cs | 17 +++++--- .../LiquidFloatingActionButton.cs | 2 + .../LiquidFloatingActionButton.csproj | 1 + .../LiquidFloatingCell.cs | 40 +++++++++++++++---- .../TitlePositions.cs | 10 +++++ 5 files changed, 57 insertions(+), 13 deletions(-) create mode 100644 iOS/LiquidFloatingActionButton/source/LiquidFloatingActionButton/TitlePositions.cs diff --git a/iOS/LiquidFloatingActionButton/samples/LiquidFloatingActionButtonSample/ViewController.cs b/iOS/LiquidFloatingActionButton/samples/LiquidFloatingActionButtonSample/ViewController.cs index c5e2ee6f2d..22f9df44cf 100644 --- a/iOS/LiquidFloatingActionButton/samples/LiquidFloatingActionButtonSample/ViewController.cs +++ b/iOS/LiquidFloatingActionButton/samples/LiquidFloatingActionButtonSample/ViewController.cs @@ -22,12 +22,17 @@ public override void ViewDidLoad() { base.ViewDidLoad(); - var font = UIFont.SystemFontOfSize(10); + var font = UIFont.SystemFontOfSize(12); + + LiquidFloatingCell.DefaultTitleColor = UIColor.White; + var cells = new List { - new LiquidFloatingCell(UIImage.FromBundle("ic_cloud"), "cloud").TitleFont(font).TitleColor(UIColor.White), - new LiquidFloatingCell(UIImage.FromBundle("ic_system"), "system").TitleFont(font).TitleColor(UIColor.White), - new LiquidFloatingCell(UIImage.FromBundle("ic_place"), "place").TitleFont(font).TitleColor(UIColor.White), + new LiquidFloatingCell(UIImage.FromBundle("ic_cloud"), "cloud") + .WithTitleFont(font) + .WithTitleColor(UIColor.Green), + new LiquidFloatingCell(UIImage.FromBundle("ic_system"), "system"), + new LiquidFloatingCell(UIImage.FromBundle("ic_place"), "place") }; topLeftButton.Image = UIImage.FromBundle("ic_art"); @@ -37,12 +42,14 @@ public override void ViewDidLoad() { topLeftButton.Close(); }; - + topLeftButton.TitlePosition = TitlePositions.Right; + bottomRightButton.Cells = cells; bottomRightButton.CellSelected += delegate { bottomRightButton.Close(); }; + bottomRightButton.TitlePosition = TitlePositions.Left; } } } diff --git a/iOS/LiquidFloatingActionButton/source/LiquidFloatingActionButton/LiquidFloatingActionButton.cs b/iOS/LiquidFloatingActionButton/source/LiquidFloatingActionButton/LiquidFloatingActionButton.cs index b102800460..a892be6e2e 100644 --- a/iOS/LiquidFloatingActionButton/source/LiquidFloatingActionButton/LiquidFloatingActionButton.cs +++ b/iOS/LiquidFloatingActionButton/source/LiquidFloatingActionButton/LiquidFloatingActionButton.cs @@ -41,6 +41,8 @@ public class LiquidFloatingActionButton : UIControl private CircleLiquidBaseView baseView = new CircleLiquidBaseView(); private UIView liquidView = new UIView(); + public TitlePositions TitlePosition { get; set; } + public LiquidFloatingActionButton() { Setup(); diff --git a/iOS/LiquidFloatingActionButton/source/LiquidFloatingActionButton/LiquidFloatingActionButton.csproj b/iOS/LiquidFloatingActionButton/source/LiquidFloatingActionButton/LiquidFloatingActionButton.csproj index 7959059d2e..f4bd55dfd5 100644 --- a/iOS/LiquidFloatingActionButton/source/LiquidFloatingActionButton/LiquidFloatingActionButton.csproj +++ b/iOS/LiquidFloatingActionButton/source/LiquidFloatingActionButton/LiquidFloatingActionButton.csproj @@ -43,6 +43,7 @@ + diff --git a/iOS/LiquidFloatingActionButton/source/LiquidFloatingActionButton/LiquidFloatingCell.cs b/iOS/LiquidFloatingActionButton/source/LiquidFloatingActionButton/LiquidFloatingCell.cs index ea8e0f9c79..496959eff3 100644 --- a/iOS/LiquidFloatingActionButton/source/LiquidFloatingActionButton/LiquidFloatingCell.cs +++ b/iOS/LiquidFloatingActionButton/source/LiquidFloatingActionButton/LiquidFloatingCell.cs @@ -28,6 +28,16 @@ public class LiquidFloatingCell : LiquittableCircle private UIImageView imageView; private UIColor originalColor = UIColor.Clear; + private UIFont _titleFont; + private UIColor _titleColor; + + public static UIColor DefaultTitleColor { get; set; } = UIColor.LabelColor; + + public static UIFont DefaultTitleFont { get; set; } = UIFont.SystemFontOfSize(UIFont.SystemFontSize); + + public UIFont TitleFont { get => _titleFont; } + + public UIColor TitleColor { get => _titleColor; } public UIView View { get; private set; } @@ -44,7 +54,7 @@ public LiquidFloatingActionButton ActionButton internal set { actionButton.SetTarget(value); } } - public bool Responsible { get; set; } + public bool Responsible { get; set; } public override void LayoutSubviews() { @@ -56,13 +66,26 @@ public override void LayoutSubviews() var offset = (Frame.Width - radius) / 2f; imageView.Frame = new CGRect(offset, offset, radius, radius); } + } + + public override void WillMoveToSuperview(UIView newsuper) + { + base.WillMoveToSuperview(newsuper); + + Label.Font = _titleFont ?? DefaultTitleFont; + Label.TextColor = _titleColor ?? DefaultTitleColor; if (Label != null) { - var radius = Frame.Width * imageRatio; - var offset = (Frame.Width - radius) / 2f; var size = (Label.Text + " ").StringSize(Label.Font); - Label.Frame = new CGRect(-size.Width, (Frame.Height - size.Height) / 2, size.Width, size.Height); + var actionButton = ActionButton; + if (actionButton != null) + { + if (actionButton.TitlePosition == TitlePositions.Left) + Label.Frame = new CGRect(-size.Width, (Frame.Height - size.Height) / 2, size.Width, size.Height); + else + Label.Frame = new CGRect(Frame.Width + (" ").StringSize(Label.Font).Width, (Frame.Height - size.Height) / 2, size.Width, size.Height); + } } } @@ -152,15 +175,16 @@ public override void TouchesEnded(NSSet touches, UIEvent evt) } } - public LiquidFloatingCell TitleFont(UIFont font) + public LiquidFloatingCell WithTitleFont(UIFont font) { - Label.Font = font; + _titleFont = font; return this; } - public LiquidFloatingCell TitleColor(UIColor color) + public LiquidFloatingCell WithTitleColor(UIColor color) { - Label.TextColor = color; + _titleColor = color; + return this; } } diff --git a/iOS/LiquidFloatingActionButton/source/LiquidFloatingActionButton/TitlePositions.cs b/iOS/LiquidFloatingActionButton/source/LiquidFloatingActionButton/TitlePositions.cs new file mode 100644 index 0000000000..00afdfde35 --- /dev/null +++ b/iOS/LiquidFloatingActionButton/source/LiquidFloatingActionButton/TitlePositions.cs @@ -0,0 +1,10 @@ +using System; + +namespace AnimatedButtons +{ + public enum TitlePositions + { + Left, + Right + } +} From d8aaf951d8c4bcf4231cd4527c23c05d82972d3e Mon Sep 17 00:00:00 2001 From: Adam Langley Date: Sat, 8 May 2021 17:07:47 +1200 Subject: [PATCH 3/4] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 86 ++++++++++++++++----------------------------- 1 file changed, 31 insertions(+), 55 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index b5256b7687..d68b1303d0 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,58 +1,34 @@ +# Starter pipeline +# Start with a minimal pipeline that you can customize to build and deploy your code. +# Add steps that build, run tests, deploy, and more: +# https://aka.ms/yaml + trigger: - - master - - refs/tags/* - -pr: - - master +- main + +pool: + vmImage: 'windows-latest' + +steps: +- task: DotNetCoreCLI@2 + inputs: + command: 'build' + projects: 'iOS/LiquidFloatingActionButton/Source/LiquidFloatingActionButton.csproj' -resources: - repositories: - - repository: internal-templates - type: github - name: xamarin/yaml-templates - endpoint: xamarin - ref: refs/heads/main - - repository: components - type: github - name: xamarin/XamarinComponents - endpoint: xamarin - ref: refs/heads/master +# The second task is dotnet pack command again pointing to the csproj file +# The nobuild means the project will not be compiled before running pack, because its already built in above step +- task: DotNetCoreCLI@2 + displayName: "dotnet pack" + inputs: + command: 'pack' + arguments: '--configuration $(buildConfiguration)' + packagesToPack: 'iOS/LiquidFloatingActionButton/Source/LiquidFloatingActionButton.csproj' + nobuild: true + versioningScheme: 'off' -jobs: - - template: .ci/build.yml@components - parameters: - timeoutInMinutes: 360 - areaPath: 'DevDiv\Xamarin SDK\Android' - buildType: 'manifest' - linuxImage: 'ubuntu-latest' - validPackagePrefixes: - # Preferred prefixes - - Xamarin - - Mono - # Other product prefixes - - SkiaSharp - - HarfBuzzSharp - - mdoc - # Historical prefixes - - Masonry - - GoogleGson - - AndroidEasingFunctions - - Square - - JakeWharton.Picasso2OkHttp3Downloader - preBuildSteps: - - pwsh: | - dotnet tool install --global boots - boots https://aka.ms/xamarin-android-commercial-d16-8-macos - condition: eq(variables['System.JobName'], 'macos') - - pwsh: | - dotnet tool install --global boots - boots https://aka.ms/xamarin-android-commercial-d16-8-windows - condition: eq(variables['System.JobName'], 'windows') - tools: - - 'xamarin.androidbinderator.tool': '0.4.2' - - 'xamarin.androidx.migration.tool': '1.0.7.1' - - ${{ if eq(variables['System.TeamProject'], 'devdiv') }}: - - template: sign-artifacts/jobs/v2.yml@internal-templates - parameters: - dependsOn: [ 'build' ] - condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/') +- task: NuGetCommand@2 + inputs: + command: 'push' + packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg' + nuGetFeedType: 'internal' + publishVstsFeed: 'eadbc838-d0d1-499f-a394-2da54247da92/3299ab6d-2681-47da-a731-a19e4e5d123d' \ No newline at end of file From 8c425e2bb2de0187cd8fb2acd2cad99ecc8f20d8 Mon Sep 17 00:00:00 2001 From: Adam Langley Date: Sat, 8 May 2021 17:27:48 +1200 Subject: [PATCH 4/4] Reverted pipelines change - was unintentional --- azure-pipelines.yml | 86 +++++++++++++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 31 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index d68b1303d0..b5256b7687 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,34 +1,58 @@ -# Starter pipeline -# Start with a minimal pipeline that you can customize to build and deploy your code. -# Add steps that build, run tests, deploy, and more: -# https://aka.ms/yaml - trigger: -- main - -pool: - vmImage: 'windows-latest' - -steps: -- task: DotNetCoreCLI@2 - inputs: - command: 'build' - projects: 'iOS/LiquidFloatingActionButton/Source/LiquidFloatingActionButton.csproj' + - master + - refs/tags/* + +pr: + - master -# The second task is dotnet pack command again pointing to the csproj file -# The nobuild means the project will not be compiled before running pack, because its already built in above step -- task: DotNetCoreCLI@2 - displayName: "dotnet pack" - inputs: - command: 'pack' - arguments: '--configuration $(buildConfiguration)' - packagesToPack: 'iOS/LiquidFloatingActionButton/Source/LiquidFloatingActionButton.csproj' - nobuild: true - versioningScheme: 'off' +resources: + repositories: + - repository: internal-templates + type: github + name: xamarin/yaml-templates + endpoint: xamarin + ref: refs/heads/main + - repository: components + type: github + name: xamarin/XamarinComponents + endpoint: xamarin + ref: refs/heads/master -- task: NuGetCommand@2 - inputs: - command: 'push' - packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg' - nuGetFeedType: 'internal' - publishVstsFeed: 'eadbc838-d0d1-499f-a394-2da54247da92/3299ab6d-2681-47da-a731-a19e4e5d123d' \ No newline at end of file +jobs: + - template: .ci/build.yml@components + parameters: + timeoutInMinutes: 360 + areaPath: 'DevDiv\Xamarin SDK\Android' + buildType: 'manifest' + linuxImage: 'ubuntu-latest' + validPackagePrefixes: + # Preferred prefixes + - Xamarin + - Mono + # Other product prefixes + - SkiaSharp + - HarfBuzzSharp + - mdoc + # Historical prefixes + - Masonry + - GoogleGson + - AndroidEasingFunctions + - Square + - JakeWharton.Picasso2OkHttp3Downloader + preBuildSteps: + - pwsh: | + dotnet tool install --global boots + boots https://aka.ms/xamarin-android-commercial-d16-8-macos + condition: eq(variables['System.JobName'], 'macos') + - pwsh: | + dotnet tool install --global boots + boots https://aka.ms/xamarin-android-commercial-d16-8-windows + condition: eq(variables['System.JobName'], 'windows') + tools: + - 'xamarin.androidbinderator.tool': '0.4.2' + - 'xamarin.androidx.migration.tool': '1.0.7.1' + - ${{ if eq(variables['System.TeamProject'], 'devdiv') }}: + - template: sign-artifacts/jobs/v2.yml@internal-templates + parameters: + dependsOn: [ 'build' ] + condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/')