Skip to content

Commit 76c729a

Browse files
Vetle444Vetle Finstad
andauthored
[CameraPreview] Removed manual safe-area padding on iOS and set SafeAreaEdges.None on internal containers so the top toolbar renders correctly on both modal and regular shell pages. (#874)
Co-authored-by: Vetle Finstad <finstad@Vetles-MacBook-Pro-2.local>
1 parent 7523c04 commit 76c729a

8 files changed

Lines changed: 227 additions & 46 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
## [60.0.1]
2+
- [CameraPreview] Removed manual safe-area padding on iOS and set `SafeAreaEdges.None` on internal containers so the top toolbar renders correctly on both modal and regular shell pages.
3+
14
## [60.0.0]
25
- [BarcodeScanner] Fixed the scanner not resuming barcode detection after pause/resume.
3-
- [BarcodeScanner] **BREAKING**: Replaced `BarcodeScannerStartOptions.ScanRectangle` (`BarcodeScanRectangleOptions`) and `BarcodeDetectionTime` with `BarcodeScannerStartOptions.Strategy` of type `BarcodeScanStrategy`. Use `TimerBarcodeScanStrategy { DetectionTime }` for timer-based confirmation without an overlay, or `ScanRectangleBarcodeScanStrategy { WidthFraction, HeightFraction, BracketsTravelDuration, FormingDuration }` for the animated scan rectangle overlay. The default strategy is `TimerBarcodeScanStrategy` (500 ms).
4-
- [CameraPreview] **BREAKING**: Removed `IsInFullscreen`. The preview always applies safe-area padding on iOS.
6+
- [BarcodeScanner] **BREAKING**: Replaced `BarcodeScannerStartOptions.ScanRectangle` (`BarcodeScanRectangleOptions`) and `BarcodeDetectionTime` with `BarcodeScannerStartOptions.Strategy` of type `BarcodeScanStrategy`. Use `TimerBarcodeScanStrategy { DetectionTime }` for timer-based confirmation without an overlay, or `ScanRectangleBarcodeScanStrategy { WidthFraction, HeightFraction, BracketsTravelDuration, FormingDuration }` for the animated scan rectangle overlay. The default strategy is `TimerBarcodeScanStrategy` (500 ms).- [CameraPreview] **BREAKING**: Removed `IsInFullscreen`. The preview always applies safe-area padding on iOS.
57

68
## [59.2.2]
79
- [ContentPage] Made `ModalNavigationRenderer` public to allow consumer customization.

src/app/Playground/EirikSamples/BarcodeScanResumeRepro.xaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
55
xmlns:dui="http://dips.com/mobile.ui"
66
x:Class="Playground.EirikSamples.BarcodeScanResumeRepro"
7-
Title="Barcode Resume Repro (#1415)">
7+
NavigationPage.BarBackgroundColor="Black"
8+
NavigationPage.BarTextColor="White"
9+
Title="Barcode Resume Repro (#1415)"
10+
SafeAreaEdges="None">
811

9-
<dui:CameraPreview x:Name="CameraPreview" />
12+
<dui:CameraPreview x:Name="CameraPreview"/>
1013
</dui:ContentPage>

src/app/Playground/EirikSamples/BarcodeScanResumeRepro.xaml.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using DIPS.Mobile.UI.API.Camera;
22
using DIPS.Mobile.UI.API.Camera.BarcodeScanning;
33
using DIPS.Mobile.UI.Components.BottomSheets;
4+
using DIPS.Mobile.UI.Resources.Sizes;
45

56
namespace Playground.EirikSamples;
67

@@ -52,6 +53,23 @@ await m_barcodeScanner.Start(new BarcodeScannerStartOptions
5253
HeightFraction = 0.3f
5354
}
5455
});
56+
57+
// Add top content — simulates a patient banner like SamplingPatientScanRepro
58+
var patientBanner = new Frame
59+
{
60+
BackgroundColor = Color.FromArgb("#333333"),
61+
CornerRadius = 8,
62+
Padding = new Thickness(12, 8),
63+
Margin = new Thickness(Sizes.GetSize(SizeName.size_3), 0),
64+
VerticalOptions = LayoutOptions.Start,
65+
Content = new Label
66+
{
67+
Text = "Ola Nordmann \u2014 01019012345",
68+
TextColor = Microsoft.Maui.Graphics.Colors.White,
69+
FontSize = 14,
70+
}
71+
};
72+
CameraPreview.AddTopToolbarView(patientBanner);
5573
}
5674
catch (Exception ex)
5775
{

src/app/Playground/MainPage.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
Tapped="GoToBarcodeScanResumeRepro" />
3030
<dui:NavigationListItem Title="Barcode Resume Repro (Modal)"
3131
Tapped="GoToBarcodeScanResumeReproModal" />
32+
<dui:NavigationListItem Title="Sampling Patient Scan Repro (Modal)"
33+
Tapped="GoToSamplingPatientScanRepro" />
3234
<dui:Button Text="Tap me"
3335
Clicked="TapMe" />
3436
</VerticalStackLayout>

src/app/Playground/MainPage.xaml.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,11 @@ private void GoToBarcodeScanResumeReproModal(object sender, EventArgs e)
109109
});
110110
Shell.Current.Navigation.PushModalAsync(navigationPage);
111111
}
112+
113+
private void GoToSamplingPatientScanRepro(object sender, EventArgs e)
114+
{
115+
var scannerPage = new SamplingPatientScanRepro();
116+
var navigationPage = new NavigationPage(scannerPage);
117+
Shell.Current.Navigation.PushModalAsync(navigationPage);
118+
}
112119
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<dui:ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
5+
xmlns:dui="http://dips.com/mobile.ui"
6+
x:Class="Playground.VetleSamples.SamplingPatientScanRepro"
7+
NavigationPage.BarBackgroundColor="Black"
8+
NavigationPage.BarTextColor="White"
9+
Title="Bekreft pasient-ID"
10+
SafeAreaEdges="None">
11+
<dui:CameraPreview x:Name="CameraPreview" />
12+
</dui:ContentPage>
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
using DIPS.Mobile.UI.API.Camera.BarcodeScanning;
2+
using DIPS.Mobile.UI.Components.BottomSheets;
3+
using DIPS.Mobile.UI.Resources.Colors;
4+
using DIPS.Mobile.UI.Resources.Sizes;
5+
using DIPS.Mobile.UI.Resources.Styles;
6+
using DIPS.Mobile.UI.Resources.Styles.Button;
7+
using DIPS.Mobile.UI.Resources.Styles.Label;
8+
9+
namespace Playground.VetleSamples;
10+
11+
/// <summary>
12+
/// Reproduces the Arena Mobile SamplingPatientBarcodeResultStrategy scanner layout.
13+
/// Opens as a modal NavigationPage with:
14+
/// - Top toolbar: patient banner placeholder
15+
/// - Tooltip: instruction label
16+
/// - Bottom toolbar: "or" label + button
17+
/// - ScanRectangleBarcodeScanStrategy
18+
///
19+
/// Use this to verify that top/bottom toolbar sizing works correctly.
20+
/// </summary>
21+
public partial class SamplingPatientScanRepro
22+
{
23+
private readonly BarcodeScanner m_barcodeScanner;
24+
25+
public SamplingPatientScanRepro()
26+
{
27+
InitializeComponent();
28+
m_barcodeScanner = new BarcodeScanner();
29+
30+
ToolbarItems.Add(new ToolbarItem
31+
{
32+
Text = "Avbryt",
33+
Command = new Command(() => Shell.Current.Navigation.PopModalAsync())
34+
});
35+
}
36+
37+
protected override void OnAppearing()
38+
{
39+
base.OnAppearing();
40+
_ = StartScanning();
41+
}
42+
43+
protected override void OnDisappearing()
44+
{
45+
m_barcodeScanner.StopAndDispose();
46+
base.OnDisappearing();
47+
}
48+
49+
private async Task StartScanning()
50+
{
51+
try
52+
{
53+
await m_barcodeScanner.Start(new BarcodeScannerStartOptions
54+
{
55+
Preview = CameraPreview,
56+
OnCameraFailed = e => DisplayAlert("Kamera feilet", e.Message, "OK"),
57+
OnBarcodeAcceptedAsync = OnBarcodeAccepted,
58+
Strategy = new ScanRectangleBarcodeScanStrategy(),
59+
});
60+
61+
// Add top content — simulates the minimized patient banner
62+
var patientBanner = new Frame
63+
{
64+
BackgroundColor = Color.FromArgb("#333333"),
65+
CornerRadius = 8,
66+
Padding = new Thickness(12, 8),
67+
Margin = new Thickness(Sizes.GetSize(SizeName.size_3), 0),
68+
VerticalOptions = LayoutOptions.Start,
69+
Content = new Label
70+
{
71+
Text = "Ola Nordmann — 01019012345",
72+
TextColor = Microsoft.Maui.Graphics.Colors.White,
73+
FontSize = 14,
74+
}
75+
};
76+
CameraPreview.AddTopToolbarView(patientBanner);
77+
78+
// Add tooltip — simulates the scan instruction
79+
m_barcodeScanner.SetTooltipView(new DIPS.Mobile.UI.Components.Labels.Label
80+
{
81+
Text = "Skann armbåndet til pasienten",
82+
Style = Styles.GetLabelStyle(LabelStyle.Body300),
83+
TextColor = Microsoft.Maui.Graphics.Colors.White,
84+
HorizontalTextAlignment = TextAlignment.Center,
85+
});
86+
87+
// Add bottom content — simulates the "or enter birth number" section
88+
var bottomContent = new VerticalStackLayout
89+
{
90+
Children =
91+
{
92+
new DIPS.Mobile.UI.Components.Labels.Label
93+
{
94+
Text = "eller",
95+
Style = Styles.GetLabelStyle(LabelStyle.Body300),
96+
TextColor = Microsoft.Maui.Graphics.Colors.White,
97+
HorizontalTextAlignment = TextAlignment.Center,
98+
Margin = new Thickness(0, Sizes.GetSize(SizeName.size_4)),
99+
},
100+
new DIPS.Mobile.UI.Components.Buttons.Button
101+
{
102+
Text = "Tast inn fødselsnummer",
103+
TextColor = Microsoft.Maui.Graphics.Colors.White,
104+
Style = Styles.GetButtonStyle(ButtonStyle.DefaultLarge),
105+
HorizontalOptions = LayoutOptions.Fill,
106+
Margin = new Thickness(Sizes.GetSize(SizeName.size_3), 0),
107+
}
108+
}
109+
};
110+
CameraPreview.AddBottomToolbarView(bottomContent);
111+
}
112+
catch (Exception ex)
113+
{
114+
Console.WriteLine($"[SamplingPatientScanRepro] Start failed: {ex}");
115+
}
116+
}
117+
118+
private Task OnBarcodeAccepted(BarcodeScanResult result)
119+
{
120+
m_barcodeScanner.PauseScanning(resetOverlay: false);
121+
122+
var sheet = new BottomSheet { Title = "Skanneresultat" };
123+
sheet.Content = new VerticalStackLayout
124+
{
125+
Padding = 16,
126+
Children =
127+
{
128+
new Label { Text = $"Strekkode: {result.Barcode.RawValue}", Margin = new Thickness(0, 0, 0, 8) },
129+
new Label { Text = $"Format: {result.Barcode.Format}" },
130+
}
131+
};
132+
133+
sheet.Closed += (_, _) =>
134+
{
135+
m_barcodeScanner.ResumeScanning();
136+
};
137+
138+
sheet.Open();
139+
return Task.CompletedTask;
140+
}
141+
}

0 commit comments

Comments
 (0)