unit Unit1;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.Ani, FMX.Layouts, FMX.Gestures, FMX.Styles,
FMX.StdCtrls, FMX.Controls.Presentation, FMX.ListBox;
type
TForm1 =
class(TForm)
StyleBook1: TStyleBook;
ToolbarHolder: TLayout;
ToolbarPopup: TPopup;
ToolbarPopupAnimation: TFloatAnimation;
ToolBar1: TToolBar;
ToolbarApplyButton: TButton;
ToolbarCloseButton: TButton;
ToolbarAddButton: TButton;
ComboBoxStyle: TComboBox;
procedure ToolbarCloseButtonClick(Sender: TObject);
procedure FormGesture(Sender: TObject;
const EventInfo: TGestureEventInfo;
var Handled: Boolean);
procedure FormKeyDown(Sender: TObject;
var Key: Word;
var KeyChar: Char;
Shift: TShiftState);
procedure FormCreate(Sender: TObject);
procedure ComboBoxStyleChange(Sender: TObject);
private
FGestureOrigin: TPointF;
FGestureInProgress: Boolean;
{ Private declarations }
procedure ShowToolbar(AShow: Boolean);
public
{ Public declarations }
procedure AddComboItem(AText:
string);
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
procedure TForm1.FormKeyDown(Sender: TObject;
var Key: Word;
var KeyChar: Char; Shift: TShiftState);
begin
if Key = vkEscape
then
ShowToolbar(
not ToolbarPopup.IsOpen);
end;
procedure TForm1.ToolbarCloseButtonClick(Sender: TObject);
begin
Application.Terminate;
end;
procedure TForm1.FormGesture(Sender: TObject;
const EventInfo: TGestureEventInfo;
var Handled: Boolean);
var
DX, DY : Single;
begin
if EventInfo.GestureID = igiPan
then
begin
if (TInteractiveGestureFlag.gfBegin
in EventInfo.Flags)
and ((Sender = ToolbarPopup)
or (EventInfo.Location.Y > (ClientHeight - 70)))
then
begin
FGestureOrigin := EventInfo.Location;
FGestureInProgress := True;
end;
if FGestureInProgress
and (TInteractiveGestureFlag.gfEnd
in EventInfo.Flags)
then
begin
FGestureInProgress := False;
DX := EventInfo.Location.X - FGestureOrigin.X;
DY := EventInfo.Location.Y - FGestureOrigin.Y;
if (Abs(DY) > Abs(DX))
then
ShowToolbar(DY < 0);
end;
end
end;
procedure TForm1.ShowToolbar(AShow: Boolean);
begin
ToolbarPopup.Width := ClientWidth;
ToolbarPopup.PlacementRectangle.Rect := TRectF.Create(0, ClientHeight-ToolbarPopup.Height, ClientWidth-1, ClientHeight-1);
ToolbarPopupAnimation.StartValue := ToolbarPopup.Height;
ToolbarPopupAnimation.StopValue := 0;
ToolbarPopup.IsOpen := AShow;
end;
procedure TForm1.AddComboItem(AText:
string);
var lbi: TListBoxItem;
begin
lbi := TListBoxItem.Create(ComboBoxStyle);
lbi.Parent := ComboBoxStyle;
lbi.Text := AText;
ComboBoxStyle.AddObject(lbi);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
AddComboItem('
Default');
if TOSVersion.
Platform = pfAndroid
then
begin
AddComboItem('
Dark');
AddComboItem('
Dark2');
AddComboItem('
DarkBlue');
AddComboItem('
Light');
AddComboItem('
Light2');
AddComboItem('
Wear');
AddComboItem('
WearDarkBlue');
AddComboItem('
GoogleGlass');
end
else if TOSVersion.
Platform = pfiOS
then
begin
AddComboItem('
Black');
AddComboItem('
Transparent');
end;
ComboBoxStyle.ItemIndex := 0;
end;
procedure TForm1.ComboBoxStyleChange(Sender: TObject);
var resname:
string; style: TFMXObject;
begin
if ComboBoxStyle.ItemIndex > 0
then
begin
if TOSVersion.
Platform = pfAndroid
then
resname := '
Android'
else if TOSVersion.
Platform = pfiOS
then
resname := '
iOS';
resname := resname + ComboBoxStyle.Selected.Text;
// style := TStyleManager.GetStyleResource(resname);
style := TStyleStreaming.LoadFromResource(HInstance, resname, RT_RCDATA);
// ich glaube das ist richtig
if style <>
nil then
TStyleManager.SetStyle(style);
end
else
TStyleManager.SetStyle(
nil);
end;
end.