diff --git a/Grijjy.Mvvm.Controls.Fmx.pas b/Grijjy.Mvvm.Controls.Fmx.pas index c98c85d..a2dc05f 100644 --- a/Grijjy.Mvvm.Controls.Fmx.pas +++ b/Grijjy.Mvvm.Controls.Fmx.pas @@ -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 } diff --git a/Grijjy.Mvvm.Types.pas b/Grijjy.Mvvm.Types.pas index 6501859..77c1a1b 100644 --- a/Grijjy.Mvvm.Types.pas +++ b/Grijjy.Mvvm.Types.pas @@ -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; @@ -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: @@ -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( diff --git a/Grijjy.Mvvm.ViewFactory.pas b/Grijjy.Mvvm.ViewFactory.pas index 6476ea6..db40866 100644 --- a/Grijjy.Mvvm.ViewFactory.pas +++ b/Grijjy.Mvvm.ViewFactory.pas @@ -90,6 +90,7 @@ TViewFreeListener = class(TComponent) FViewFreeListener: TViewFreeListener; protected { IgoView } + procedure Execute; procedure ExecuteModal(const AResultProc: TProc<TModalResult>); protected { IgoView<TVM> } @@ -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 diff --git a/Grijjy.Mvvm.Views.Fmx.pas b/Grijjy.Mvvm.Views.Fmx.pas index 900411b..398348a 100644 --- a/Grijjy.Mvvm.Views.Fmx.pas +++ b/Grijjy.Mvvm.Views.Fmx.pas @@ -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: @@ -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 diff --git a/Grijjy.Mvvm.Views.Vcl.pas b/Grijjy.Mvvm.Views.Vcl.pas index 86565fc..68313f4 100644 --- a/Grijjy.Mvvm.Views.Vcl.pas +++ b/Grijjy.Mvvm.Views.Vcl.pas @@ -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: @@ -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;