Skip to content

Commit

Permalink
Merge pull request #37 from wxinix/master
Browse files Browse the repository at this point in the history
Cleanup examples and improve TThreadMode documentation
  • Loading branch information
spinettaro authored Nov 22, 2020
2 parents d6262ac + 1faaa02 commit 78553a8
Show file tree
Hide file tree
Showing 28 changed files with 972 additions and 691 deletions.
1 change: 0 additions & 1 deletion samples/AccessRemoteData/AccessRemoteData.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ begin
Application.Initialize;
Application.CreateForm(THeaderFooterForm, HeaderFooterForm);
Application.Run;

end.
420 changes: 141 additions & 279 deletions samples/AccessRemoteData/AccessRemoteData.dproj

Large diffs are not rendered by default.

Binary file modified samples/AccessRemoteData/AccessRemoteData.res
Binary file not shown.
58 changes: 27 additions & 31 deletions samples/AccessRemoteData/BOsU.pas
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,50 @@
interface

uses

EventBus;

type

TLoginDTO = class(TObject)
private
FPassword: string;
FUsername: string;
procedure SetPassword(const Value: string);
procedure SetUsername(const Value: string);
procedure SetPassword(const AValue: string);
procedure SetUsername(const AValue: string);
public
constructor Create(AUsername: string; APwd: string);
property Username: string read FUsername write SetUsername;
property Password: string read FPassword write SetPassword;
end;

IOnLoginEvent = interface
['{E3C9633D-86CA-488F-A452-29DAB206C92A}']
procedure SetMsg(const Value: string);
procedure SetSuccess(const Value: boolean);
function GetMsg: String;
['{E3C9633D-86CA-488F-A452-29DAB206C92A}']
procedure SetMsg(const AValue: string);
procedure SetSuccess(const AValue: Boolean);
function GetMsg: string;
function GetSuccess: Boolean;
property Success: boolean read GetSuccess write SetSuccess;
property Success: Boolean read GetSuccess write SetSuccess;
property Msg: string read GetMsg write SetMsg;
end;

function CreateOnLoginEvent(ASuccess: boolean; AMsg: string): IOnLoginEvent;
function CreateOnLoginEvent(ASuccess: Boolean; AMsg: string): IOnLoginEvent;

implementation

uses
System.Classes;


type

TOnLoginEvent = class(TInterfacedObject, IOnLoginEvent)
TOnLoginEvent = class(TInterfacedObject, IOnLoginEvent)
private
FSuccess: boolean;
FSuccess: Boolean;
FMsg: string;
procedure SetMsg(const Value: string);
procedure SetSuccess(const Value: boolean);
function GetMsg: String;
procedure SetMsg(const AValue: string);
procedure SetSuccess(const AValue: Boolean);
function GetMsg: string;
function GetSuccess: Boolean;
public
constructor Create(ASuccess: boolean; AMsg: string);
property Success: boolean read GetSuccess write SetSuccess;
constructor Create(ASuccess: Boolean; AMsg: string);
property Success: Boolean read GetSuccess write SetSuccess;
property Msg: string read GetMsg write SetMsg;
end;

Expand All @@ -62,26 +58,26 @@ constructor TLoginDTO.Create(AUsername, APwd: string);
FUsername := AUsername;
end;

procedure TLoginDTO.SetPassword(const Value: string);
procedure TLoginDTO.SetPassword(const AValue: string);
begin
FPassword := Value;
FPassword := AValue;
end;

procedure TLoginDTO.SetUsername(const Value: string);
procedure TLoginDTO.SetUsername(const AValue: string);
begin
FUsername := Value;
FUsername := AValue;
end;

{ TOnLoginEvent }

constructor TOnLoginEvent.Create(ASuccess: boolean; AMsg: string);
constructor TOnLoginEvent.Create(ASuccess: Boolean; AMsg: string);
begin
inherited Create;
FSuccess := ASuccess;
FMsg := AMsg;
end;

function TOnLoginEvent.GetMsg: String;
function TOnLoginEvent.GetMsg: string;
begin
Result:= FMsg;
end;
Expand All @@ -91,19 +87,19 @@ function TOnLoginEvent.GetSuccess: Boolean;
Result:= FSuccess;
end;

procedure TOnLoginEvent.SetMsg(const Value: string);
procedure TOnLoginEvent.SetMsg(const AValue: string);
begin
FMsg := Value;
FMsg := AValue;
end;

procedure TOnLoginEvent.SetSuccess(const Value: boolean);
procedure TOnLoginEvent.SetSuccess(const AValue: Boolean);
begin
FSuccess := Value;
FSuccess := AValue;
end;

function CreateOnLoginEvent(ASuccess: boolean; AMsg: string): IOnLoginEvent;
function CreateOnLoginEvent(ASuccess: Boolean; AMsg: string): IOnLoginEvent;
begin
Result:= TOnLoginEvent.Create( ASuccess, AMsg);
Result:= TOnLoginEvent.Create(ASuccess, AMsg);
end;

end.
38 changes: 19 additions & 19 deletions samples/AccessRemoteData/MainFMX.fmx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ object HeaderFooterForm: THeaderFooterForm
FormFactor.Height = 900
FormFactor.Devices = [Desktop]
OnCreate = FormCreate
DesignerMasterStyle = 3
DesignerMasterStyle = 0
object Header: TToolBar
Size.Width = 384.000000000000000000
Size.Height = 48.000000000000000000
Expand Down Expand Up @@ -98,36 +98,36 @@ object HeaderFooterForm: THeaderFooterForm
Value = 49.736522464674410000
end
item
Value = 6.282934691915697000
Value = 6.282934691915696000
end
item
Value = 6.282934691915697000
Value = 6.282934691915696000
end
item
Value = 6.282934691915697000
Value = 6.282934691915696000
end
item
Value = 6.282934691915697000
Value = 6.282934691915696000
end
item
Value = 6.282934691915697000
Value = 6.282934691915696000
end
item
Value = 6.282934691915697000
Value = 6.282934691915696000
end
item
Value = 6.282934691915697000
Value = 6.282934691915696000
end
item
Value = 6.282934691915697000
Value = 6.282934691915696000
end>
object Edit1: TEdit
Touch.InteractiveGestures = [LongTap, DoubleTap]
Align = Client
TabOrder = 0
Hint = 'Username'
Size.Width = 308.013977050781300000
Size.Height = 32.000000000000000000
Size.Height = 32.608428955078130000
Size.PlatformDefault = False
TextPrompt = 'Username...'
end
Expand All @@ -137,7 +137,7 @@ object HeaderFooterForm: THeaderFooterForm
TabOrder = 1
Password = True
Size.Width = 308.013977050781300000
Size.Height = 32.000000000000000000
Size.Height = 32.608428955078130000
Size.PlatformDefault = False
TextPrompt = 'Password...'
end
Expand Down Expand Up @@ -212,28 +212,28 @@ object HeaderFooterForm: THeaderFooterForm
Value = 49.736522464674410000
end
item
Value = 6.282934691915697000
Value = 6.282934691915696000
end
item
Value = 6.282934691915697000
Value = 6.282934691915696000
end
item
Value = 6.282934691915697000
Value = 6.282934691915696000
end
item
Value = 6.282934691915697000
Value = 6.282934691915696000
end
item
Value = 6.282934691915697000
Value = 6.282934691915696000
end
item
Value = 6.282934691915697000
Value = 6.282934691915696000
end
item
Value = 6.282934691915697000
Value = 6.282934691915696000
end
item
Value = 6.282934691915697000
Value = 6.282934691915696000
end>
object Button2: TButton
Align = Client
Expand Down
31 changes: 15 additions & 16 deletions samples/AccessRemoteData/MainFMX.pas
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ interface

type
THeaderFooterForm = class(TForm)
Header: TToolBar;
HeaderLabel: TLabel;
GridPanelLayout1: TGridPanelLayout;
AniIndicator1: TAniIndicator;
Button1: TButton;
Button2: TButton;
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
AniIndicator1: TAniIndicator;
GridPanelLayout1: TGridPanelLayout;
GridPanelLayout2: TGridPanelLayout;
Header: TToolBar;
HeaderLabel: TLabel;
TabControl1: TTabControl;
Text1: TText;
TabItem1: TTabItem;
TabItem2: TTabItem;
GridPanelLayout2: TGridPanelLayout;
Button2: TButton;
Text1: TText;
Text2: TText;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
fRemoteDataContext: IRemoteDataContext;
FRemoteDataContext: IRemoteDataContext;
public
{ Public declarations }
[Subscribe(TThreadMode.Main)]
Expand All @@ -45,12 +45,12 @@ implementation

procedure THeaderFooterForm.Button1Click(Sender: TObject);
var
lLoginDTO: TLoginDTO;
LLoginDTO: TLoginDTO;
begin
AniIndicator1.Enabled := true;
Button1.Enabled := false;
lLoginDTO := TLoginDTO.Create(Edit1.Text, Edit2.Text);
fRemoteDataContext.Login(lLoginDTO);
LLoginDTO := TLoginDTO.Create(Edit1.Text, Edit2.Text);
FRemoteDataContext.Login(LLoginDTO);
end;

procedure THeaderFooterForm.Button2Click(Sender: TObject);
Expand All @@ -61,7 +61,7 @@ procedure THeaderFooterForm.Button2Click(Sender: TObject);
procedure THeaderFooterForm.FormCreate(Sender: TObject);
begin
TabControl1.ActiveTab := TabItem1;
fRemoteDataContext:= CreateRemoteDataContext;
FRemoteDataContext:= CreateRemoteDataContext;
// register subscribers
GlobalEventBus.RegisterSubscriberForEvents(Self);
end;
Expand All @@ -74,5 +74,4 @@ procedure THeaderFooterForm.OnAfterLogin(AEvent: IOnLoginEvent);
TabControl1.SetActiveTabWithTransition(TabItem2, TTabTransition.Slide);
end;

end.

end.
Expand Down
Loading

0 comments on commit 78553a8

Please sign in to comment.