unit uMain;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, DPF.iOS.BaseControl,
  DPF.iOS.Common, DPF.iOS.UITableView, DPF.iOS.UIView, DPF.iOS.UISearchBar,
  DPF.iOS.UIButton, DPF.iOS.UIViewController, DPF.iOS.UINavigationController,
  DPF.iOS.CheckBox;

type
  TFTableView1 = class( TForm )
    DPFUITableView1: TDPFUITableView;
    DPFUIView1: TDPFUIView;
    DPFSearchBar1: TDPFSearchBar;
    DPFNavigationController1: TDPFNavigationController;
    DPFNavigationControllerPage1: TDPFNavigationControllerPage;
    DPFCheckBox1: TDPFCheckBox;
    procedure DPFCheckBox1Click( Sender: TObject );
    procedure FormShow( Sender: TObject );
    procedure DPFSearchBar1ScopebarClicked( Sender: TObject; SelectedIndex: Integer );
    procedure DPFSearchBar1Changed( Sender: TObject );
  private
    { Private declarations }
  protected
    procedure PaintRects( const UpdateRects: array of TRectF ); override;
  public
    { Public declarations }
  end;

var
  FTableView1: TFTableView1;

implementation

{$R *.fmx}
{ TFTableView1 }

procedure TFTableView1.DPFCheckBox1Click( Sender: TObject );
begin
  if DPFCheckBox1.Checked then
    DPFUITableView1.Options.SearchBar.SearchKind := TDPFTableViewSearchKind.skContains
  else
    DPFUITableView1.Options.SearchBar.SearchKind := TDPFTableViewSearchKind.skStartsWith;
end;

procedure TFTableView1.DPFSearchBar1Changed( Sender: TObject );
begin
  DPFNavigationControllerPage1.PageViewTitle := 'Table Search: ' + DPFUITableView1.SearchItemCount.ToString;
end;

procedure TFTableView1.DPFSearchBar1ScopebarClicked( Sender: TObject; SelectedIndex: Integer );
begin
  DPFNavigationControllerPage1.PageViewTitle := DPFSearchBar1.ScopeButtonTitles[SelectedIndex];
  if SelectedIndex = 0 then
    DPFUITableView1.SearchCategory := ''
  else
    DPFUITableView1.SearchCategory := DPFSearchBar1.ScopeButtonTitles[SelectedIndex];
end;

procedure TFTableView1.FormShow( Sender: TObject );
begin
  DPFCheckBox1.Checked                       := DPFUITableView1.Options.SearchBar.SearchKind = TDPFTableViewSearchKind.skContains;
  DPFNavigationControllerPage1.PageViewTitle := DPFSearchBar1.ScopeButtonTitles[DPFSearchBar1.SelectedScopeButtonIndex];
end;

procedure TFTableView1.PaintRects( const UpdateRects: array of TRectF );
begin
  { }

end;

end.
