feat(android): the last two styled controls give way

The search field and the folder combo were the only things still wearing the style, and they clashed with everything painted around them.

The edit stays native - a keyboard has to come from somewhere - but its background is ours now, with the styled one made transparent. The combo becomes a painted button opening a panel of choices, placed by explicit coordinates: FMX's stacking order proved unstable as soon as children are destroyed and rebuilt, so nothing here relies on it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
r-zakarya
2026-08-15 17:26:02 +01:00
parent e5eb91cd3f
commit 09f108aa8d
+77 -23
View File
@@ -99,7 +99,12 @@ type
FLayList: TLayout; FLayList: TLayout;
FSearch: TEdit; FSearch: TEdit;
FSearchHint: TLabel; FSearchHint: TLabel;
FFolderBox: TComboBox; /// Choix du dossier : un bouton peint, et un panneau de selection montre
/// a la demande. FFolders[0] est toujours « tous les dossiers ».
FBtnFolder: TRectangle;
FFolderPanel: TRectangle;
FFolderNames: TArray<string>;
FFolderSel: Integer;
FList: TListBox; FList: TListBox;
FCount: TLabel; FCount: TLabel;
/// Icones decodees une fois par coffre, pas a chaque frappe : la liste est /// Icones decodees une fois par coffre, pas a chaque frappe : la liste est
@@ -162,6 +167,8 @@ type
procedure LockVault; procedure LockVault;
procedure OnSearchChanged(Sender: TObject); procedure OnSearchChanged(Sender: TObject);
procedure OnFolderTap(Sender: TObject);
procedure OnFolderPick(Sender: TObject);
procedure PopulateFolders; procedure PopulateFolders;
procedure RebuildIcons; procedure RebuildIcons;
procedure OnItemTap(const Sender: TCustomListBox; const AItem: TListBoxItem); procedure OnItemTap(const Sender: TCustomListBox; const AItem: TListBoxItem);
@@ -349,7 +356,7 @@ end;
procedure TForm8.BuildList; procedure TForm8.BuildList;
var var
LBar, LTop: TLayout; LBar, LTop: TLayout;
LBtnLock: TRectangle; LBtnLock, LSearchBox: TRectangle;
begin begin
FLayList := TLayout.Create(Self); FLayList := TLayout.Create(Self);
FLayList.Parent := Self; FLayList.Parent := Self;
@@ -394,17 +401,28 @@ begin
// Pas de filtre d'etiquette : la recherche texte couvre deja les etiquettes, // Pas de filtre d'etiquette : la recherche texte couvre deja les etiquettes,
// en taper le nom suffit. Les dossiers, eux, ne se devinent pas. // en taper le nom suffit. Les dossiers, eux, ne se devinent pas.
FFolderBox := TComboBox.Create(Self); //
FFolderBox.Parent := LTop; // Bouton peint et non TComboBox : le combo etait l'un des deux derniers
FFolderBox.Align := TAlignLayout.Right; // controles a porter encore le style, et il jurait avec le reste.
FFolderBox.Width := 140; FBtnFolder := FlatButton(LTop, 'Tous les dossiers', OnFolderTap);
FFolderBox.Margins.Left := 8; FBtnFolder.Align := TAlignLayout.Right;
FFolderBox.OnChange := OnSearchChanged; FBtnFolder.Width := 170;
FBtnFolder.Margins.Left := 8;
// Le champ de saisie reste natif - il faut un clavier - mais son fond vient
// de nous : LSearchBox le porte, l'editeur par-dessus est transparent.
LSearchBox := Surface(LTop);
LSearchBox.Align := TAlignLayout.Client;
LSearchBox.Fill.Color := COL_SURFACE;
FSearch := TEdit.Create(Self); FSearch := TEdit.Create(Self);
FSearch.Parent := LTop; FSearch.Parent := LSearchBox;
FSearch.Align := TAlignLayout.Client; FSearch.Align := TAlignLayout.Client;
FSearch.Margins.Rect := RectF(6, 0, 6, 0);
FSearch.OnChangeTracking := OnSearchChanged; FSearch.OnChangeTracking := OnSearchChanged;
// Gabarit transparent : present dans les styles livres. S'il manquait, on
// retomberait sur le fond du style, sans casse.
FSearch.StyleLookup := 'transparentedit';
// Invite dessinee par nous, pas par TextPrompt : Dark.style ne comporte pas // Invite dessinee par nous, pas par TextPrompt : Dark.style ne comporte pas
// l'objet que le style est cense fournir pour l'afficher, et le champ // l'objet que le style est cense fournir pour l'afficher, et le champ
@@ -1142,21 +1160,57 @@ begin
// Le choix courant survit a un rafraichissement de fond : le voir retomber // Le choix courant survit a un rafraichissement de fond : le voir retomber
// sur "tous" tout seul, sans avoir rien touche, serait deroutant. // sur "tous" tout seul, sans avoir rien touche, serait deroutant.
LPrev := ''; LPrev := '';
if FFolderBox.ItemIndex > 0 then if (FFolderSel > 0) and (FFolderSel <= High(FFolderNames)) then
LPrev := FFolderBox.Items[FFolderBox.ItemIndex]; LPrev := FFolderNames[FFolderSel];
FFolderBox.Items.BeginUpdate; SetLength(FFolderNames, 1);
try FFolderNames[0] := 'Tous les dossiers';
FFolderBox.Items.Clear; for LF in FVault.Folders do
FFolderBox.Items.Add('Tous les dossiers'); begin
for LF in FVault.Folders do FFolderBox.Items.Add(LF); SetLength(FFolderNames, Length(FFolderNames) + 1);
finally FFolderNames[High(FFolderNames)] := LF;
FFolderBox.Items.EndUpdate;
end; end;
I := FFolderBox.Items.IndexOf(LPrev); FFolderSel := 0;
if I < 0 then I := 0; for I := 1 to High(FFolderNames) do
FFolderBox.ItemIndex := I; if FFolderNames[I] = LPrev then FFolderSel := I;
SetButtonText(FBtnFolder, FFolderNames[FFolderSel]);
end;
procedure TForm8.OnFolderTap(Sender: TObject);
var
I: Integer;
LRow: TRectangle;
LH: 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;
for I := 0 to High(FFolderNames) do
begin
LRow := FlatButton(FFolderPanel, FFolderNames[I], OnFolderPick, I = FFolderSel);
LRow.Align := TAlignLayout.None;
LRow.SetBounds(6, 6 + I * LH, FFolderPanel.Width - 12, LH - 6);
LRow.Tag := I;
end;
end;
procedure TForm8.OnFolderPick(Sender: TObject);
begin
if Sender is TRectangle then FFolderSel := TRectangle(Sender).Tag;
SetButtonText(FBtnFolder, FFolderNames[FFolderSel]);
FreeAndNil(FFolderPanel);
OnSearchChanged(nil);
end; end;
procedure TForm8.OnSearchChanged(Sender: TObject); procedure TForm8.OnSearchChanged(Sender: TObject);
@@ -1176,8 +1230,8 @@ begin
Touch; Touch;
FSearchHint.Visible := FSearch.Text = ''; FSearchHint.Visible := FSearch.Text = '';
LFolder := ''; LFolder := '';
if FFolderBox.ItemIndex > 0 then // 0 = tous les dossiers if (FFolderSel > 0) and (FFolderSel <= High(FFolderNames)) then
LFolder := FFolderBox.Items[FFolderBox.ItemIndex]; LFolder := FFolderNames[FFolderSel]; // 0 = tous les dossiers
FFiltered := FVault.Search(FSearch.Text, LFolder); FFiltered := FVault.Search(FSearch.Text, LFolder);
FList.BeginUpdate; FList.BeginUpdate;