unit MainFrm;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.MultiView, FMX.Objects, FMX.TabControl,
  FMX.StdCtrls, FMX.Layouts, FMX.ListView.Types, FMX.ListView, FMX.ExtCtrls, FMX.Ani, FMX.Gestures, FMX.ListBox,
  FMX.DateTimeCtrls, FMX.Edit, FMX.MultiView.Types, FMX.Colors,  FMX.MultiView.CustomPresentation,
  FMX.EditBox, FMX.NumberBox, FMX.Controls.Presentation,
  FMX.ListView.Appearances, FMX.ListView.Adapters.Base, Fmx.Bind.GenData,
  Data.Bind.GenData, Data.Bind.EngExt, Fmx.Bind.DBEngExt, System.Rtti,
  System.Bindings.Outputs, Fmx.Bind.Editors, Data.Bind.Components,
  Data.Bind.ObjectScope;

type
  TMainForm = class(TForm)
    MultiView1: TMultiView;
    ToolBar1: TToolBar;
    MasterButton: TSpeedButton;
    ToolBar2: TToolBar;
    Label1: TLabel;
    Label2: TLabel;
    ListBox1: TListBox;
    ListBoxItemGrupo: TListBoxItem;
    ListBoxItem2: TListBoxItem;
    ListBoxItem3: TListBoxItem;
    ListBoxItem4: TListBoxItem;
    ListBoxItem5: TListBoxItem;
    DetailPanel: TPanel;
    TabControl1: TTabControl;
    TabItem3: TTabItem;
    VaporStyleBook: TStyleBook;
    PrototypeBindSource1: TPrototypeBindSource;
    BindingsList1: TBindingsList;
    LinkFillControlToField1: TLinkFillControlToField;
    ListBoxItem17: TListBoxItem;
    ListBoxGroupHeader1: TListBoxGroupHeader;
    ListBoxGroupHeader2: TListBoxGroupHeader;
    ListBoxItem18: TListBoxItem;
    ListBoxItem19: TListBoxItem;
    ListBoxGroupHeader3: TListBoxGroupHeader;
    ListBoxItem20: TListBoxItem;
    ListBoxItem21: TListBoxItem;
    ListBoxItem22: TListBoxItem;
    ListBoxItem23: TListBoxItem;
    ListBoxItem24: TListBoxItem;
    ListBoxItem25: TListBoxItem;
    Panel1: TPanel;
    procedure ListBox1ItemClick(const Sender: TCustomListBox; const Item: TListBoxItem);
    procedure FormCreate(Sender: TObject);
    procedure ListBoxItem22Click(Sender: TObject);
    procedure ListBoxItem21Click(Sender: TObject);
    procedure ListBoxItemGrupoClick(Sender: TObject);
    procedure ListBoxItem5Click(Sender: TObject);
    procedure ListBoxItem2Click(Sender: TObject);
  public
    { Public declarations }
  end;

var
  MainForm: TMainForm;
  FrameAtual: TFrame;

implementation

uses
  FMX.MultiView.Presentations, UBanco, UContador, UProdutoGrupo, UProduto,
  UProdutoSubGrupo;

{$R *.fmx}

procedure TMainForm.FormCreate(Sender: TObject);
begin
  MultiView1.CustomPresentationClass := TMultiViewAlertPresentation;
end;

procedure TMainForm.ListBox1ItemClick(const Sender: TCustomListBox; const Item: TListBoxItem);
begin
  Item.IsSelected := False;
  MultiView1.HideMaster;
end;

procedure TMainForm.ListBoxItem21Click(Sender: TObject);
begin
  if Assigned(FrameAtual) then
    FreeAndNil(FrameAtual);
  FrameAtual := TFContador.Create(Panel1);

  with FrameAtual do
  begin
    Parent := Panel1;
    Align := FMX.Types.TAlignLayout.Client;
  end;
  TabItem3.Text := ListBoxItem21.Text;
end;

procedure TMainForm.ListBoxItem22Click(Sender: TObject);
begin
  if Assigned(FrameAtual) then
    FreeAndNil(FrameAtual);
  FrameAtual := TFBanco.Create(Panel1);

  with FrameAtual do
  begin
    Parent := Panel1;
    Align := FMX.Types.TAlignLayout.Client;
  end;
  TabItem3.Text := ListBoxItem22.Text;
end;

procedure TMainForm.ListBoxItem2Click(Sender: TObject);
begin
  if Assigned(FrameAtual) then
    FreeAndNil(FrameAtual);
  FrameAtual := TFProdutoSubGrupo.Create(Panel1);

  with FrameAtual do
  begin
    Parent := Panel1;
    Align := FMX.Types.TAlignLayout.Client;
  end;
  TabItem3.Text := ListBoxItem2.Text;
end;

procedure TMainForm.ListBoxItem5Click(Sender: TObject);
begin
  if Assigned(FrameAtual) then
    FreeAndNil(FrameAtual);
  FrameAtual := TFProduto.Create(Panel1);

  with FrameAtual do
  begin
    Parent := Panel1;
    Align := FMX.Types.TAlignLayout.Client;
  end;
  TabItem3.Text := ListBoxItem5.Text;
end;

procedure TMainForm.ListBoxItemGrupoClick(Sender: TObject);
begin
  if Assigned(FrameAtual) then
    FreeAndNil(FrameAtual);
  FrameAtual := TFProdutoGrupo.Create(Panel1);

  with FrameAtual do
  begin
    Parent := Panel1;
    Align := FMX.Types.TAlignLayout.Client;
  end;
  TabItem3.Text := ListBoxItemGrupo.Text;
end;

end.
