Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the Execute method declaration on IgoView interface and impleme… #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Grijjy.Mvvm.Controls.Fmx.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1222,6 +1222,7 @@ procedure TListBoxCollectionView.UpdateListBoxItem(
AListBoxItem.ItemData.Detail := Template.GetDetail(AItem);
AListBoxItem.ImageIndex := Template.GetImageIndex(AItem);
AListBoxItem.Data := AItem;
AListBoxItem.StyleLookup := Template.GetStyle(AItem);
end;

{ TListView }
Expand Down
9 changes: 9 additions & 0 deletions Grijjy.Mvvm.Types.pas
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ TgoDataTemplate = class abstract

Returns -1 by default. }
class function GetImageIndex(const AItem: TObject): Integer; virtual;
class function GetStyle(const AItem: TObject): string; virtual;
end;
TgoDataTemplateClass = class of TgoDataTemplate;

Expand Down Expand Up @@ -461,6 +462,9 @@ TgoMultiCastEvent<T> = class(TInterfacedObject, IgoMultiCastEvent<T>)
{ Base interface for the generic IgoView<TVM> version }
IgoView = interface
['{5EF31C67-EB85-48EB-A390-8097DB0EFED2}']
{ Executes the view }
procedure Execute;

{ Executes the view in a modal way.

Parameters:
Expand Down Expand Up @@ -648,6 +652,11 @@ class function TgoDataTemplate.GetImageIndex(const AItem: TObject): Integer;
Result := -1;
end;

class function TgoDataTemplate.GetStyle(const AItem: TObject): string;
begin
Result := '';
end;

{ TgoValueConverter }

class function TgoValueConverter.ConvertTargetToSource(
Expand Down
7 changes: 7 additions & 0 deletions Grijjy.Mvvm.ViewFactory.pas
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ TViewFreeListener = class(TComponent)
FViewFreeListener: TViewFreeListener;
protected
{ IgoView }
procedure Execute;
procedure ExecuteModal(const AResultProc: TProc<TModalResult>);
protected
{ IgoView<TVM> }
Expand Down Expand Up @@ -126,6 +127,12 @@ destructor TgoViewProxy<TVM>.Destroy;
inherited;
end;

procedure TgoViewProxy<TVM>.Execute;
begin
if Assigned(FViewFreeListener.ActualView) then
FViewFreeListener.ActualView.Execute;
end;

procedure TgoViewProxy<TVM>.ExecuteModal(const AResultProc: TProc<TModalResult>);
begin
if Assigned(FViewFreeListener.ActualView) then
Expand Down
8 changes: 8 additions & 0 deletions Grijjy.Mvvm.Views.Fmx.pas
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ TgoFormView<TVM: class> = class(TForm, IgoView, IgoView<TVM>)
any data bindings. }
procedure InitView(const AViewModel: TVM; const AOwnsViewModel: Boolean);

{ Executes the view }
procedure Execute;

{ Executes the view in a modal way.

Parameters:
Expand Down Expand Up @@ -146,6 +149,11 @@ procedure TgoFormView<TVM>.DoClose(var CloseAction: TCloseAction);
{$ENDIF}
end;

procedure TgoFormView<TVM>.Execute;
begin
Show;
end;

procedure TgoFormView<TVM>.ExecuteModal(const AResultProc: TProc<TModalResult>);
{$IFNDEF ANDROID}
var
Expand Down
8 changes: 8 additions & 0 deletions Grijjy.Mvvm.Views.Vcl.pas
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ TgoFormView<TVM: class> = class(TForm, IgoView, IgoView<TVM>)
Should usually be overridden to set up the data bindings. }
procedure InitView(const AViewModel: TVM; const AOwnsViewModel: Boolean);

{ Executes the view }
procedure Execute;

{ Executes the view in a modal way.

Parameters:
Expand Down Expand Up @@ -98,6 +101,11 @@ procedure TgoFormView<TVM>.DoClose(var Action: TCloseAction);
inherited;
end;

procedure TgoFormView<TVM>.Execute;
begin
Show;
end;

procedure TgoFormView<TVM>.ExecuteModal(const AResultProc: TProc<TModalResult>);
var
Result: TModalResult;
Expand Down