fix(android): the folder panel closes when you tap beside it

It stayed open until something was chosen, and there was no way to change your mind. A full-screen scrim now dims the background and takes the outside tap; the hardware back button closes the panel before anything else, which is what it is expected to do while something is open.

The list also scrolls: eight folders fit, twenty would have run off the screen. Rows are placed by coordinate inside the scroll box, with no alignment at all - the only arrangement FMX has not surprised me with today.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
r-zakarya
2026-08-15 17:37:43 +01:00
parent 09f108aa8d
commit 5a2774974a
+46 -12
View File
@@ -741,6 +741,14 @@ procedure TForm8.OnHardwareBack(Sender: TObject; var Key: Word;
var KeyChar: WideChar; Shift: TShiftState);
begin
if Key <> vkHardwareBack then Exit;
// Le panneau des dossiers se ferme avant tout le reste : c'est ce que le
// bouton retour est cense faire d'abord quand quelque chose est ouvert.
if FFolderPanel <> nil then
begin
FreeAndNil(FFolderPanel);
Key := 0;
Exit;
end;
if FLayDetail.Visible then
begin
ShowList;
@@ -1181,33 +1189,59 @@ procedure TForm8.OnFolderTap(Sender: TObject);
var
I: Integer;
LRow: TRectangle;
LH: Single;
LCard: TRectangle;
LBody: TVertScrollBox;
LH, LWanted, LMax: Single;
begin
Touch;
FreeAndNil(FFolderPanel);
if Length(FFolderNames) < 2 then Exit; // rien a choisir
LH := 54;
// PLACEMENT EXPLICITE, aucune convention d'alignement : l'ordre d'empilement
// de FMX s'est revele instable des qu'on detruit et recree des enfants.
FFolderPanel := Surface(FLayList);
FFolderPanel.Align := TAlignLayout.None;
FFolderPanel.SetBounds(16, 66, FLayList.Width - 32,
Length(FFolderNames) * LH + 12);
FFolderPanel.Fill.Color := COL_SURFACE;
LH := 52;
// Voile plein ecran : il assombrit le fond ET recoit le clic exterieur.
// Sans lui le panneau restait ouvert tant qu'on n'avait pas choisi - il
// faut toujours pouvoir renoncer.
FFolderPanel := TRectangle.Create(FLayList);
FFolderPanel.Parent := FLayList;
FFolderPanel.Align := TAlignLayout.Contents;
FFolderPanel.Fill.Color := TAlphaColor($99000000);
FFolderPanel.Stroke.Kind := TBrushKind.None;
FFolderPanel.OnClick := OnFolderPick;
FFolderPanel.Tag := -1; // -1 : renoncer, garder le choix courant
LWanted := Length(FFolderNames) * LH + 12;
LMax := FLayList.Height - 140;
if LWanted > LMax then LWanted := LMax;
LCard := Surface(FFolderPanel);
LCard.Align := TAlignLayout.None;
LCard.SetBounds(16, 66, FLayList.Width - 32, LWanted);
// Defilant, car une longue liste de dossiers sortirait de l'ecran. Les
// lignes y sont POSEES A LA COORDONNEE, sans alignement : c'est ce qui rend
// l'ordre independant des conventions de FMX, instables des qu'on detruit
// et recree des enfants.
LBody := TVertScrollBox.Create(LCard);
LBody.Parent := LCard;
LBody.Align := TAlignLayout.Client;
LBody.Margins.Rect := RectF(6, 6, 6, 6);
LBody.ShowScrollBars := False;
for I := 0 to High(FFolderNames) do
begin
LRow := FlatButton(FFolderPanel, FFolderNames[I], OnFolderPick, I = FFolderSel);
LRow := FlatButton(LBody, FFolderNames[I], OnFolderPick, I = FFolderSel);
LRow.Align := TAlignLayout.None;
LRow.SetBounds(6, 6 + I * LH, FFolderPanel.Width - 12, LH - 6);
LRow.SetBounds(0, I * LH, LCard.Width - 24, LH - 6);
LRow.Tag := I;
end;
end;
procedure TForm8.OnFolderPick(Sender: TObject);
begin
if Sender is TRectangle then FFolderSel := TRectangle(Sender).Tag;
// Tag -1 : le voile, donc un clic a cote. On ferme sans rien changer.
if (Sender is TRectangle) and (TRectangle(Sender).Tag >= 0) then
FFolderSel := TRectangle(Sender).Tag;
SetButtonText(FBtnFolder, FFolderNames[FFolderSel]);
FreeAndNil(FFolderPanel);
OnSearchChanged(nil);