Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
freever committed Mar 4, 2024
1 parent 524f1e3 commit 3aa7558
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/Blauhaus.MVVM.Abstractions/Dialogs/IDialogService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public interface IDialogService
Task DisplayAlertAsync(string title, string message, string cancelButtonText = "OK");
Task<bool> DisplayConfirmationAsync(string title, string message, string cancelButtonText = "Cancel", string acceptButtonText = "OK");
Task<string> DisplayActionSheetAsync(string title, string cancel, string destruction, params string[] buttons);
Task<string?> DisplayPromptAsync(string title, string message, string cancelButtonText = "Cancel", string acceptButtonText = "OK");

}
}
8 changes: 8 additions & 0 deletions src/Blauhaus.MVVM.Maui/Services/MauiDialogService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,12 @@ public async Task<string> DisplayActionSheetAsync(string title, string cancel, s

return await Application.Current.MainPage.DisplayActionSheet(title, cancel, destruction, FlowDirection.MatchParent, buttons);
}

public async Task<string?> DisplayPromptAsync(string title, string message, string cancelButtonText = "Cancel", string acceptButtonText = "OK")
{
if (Application.Current is null) throw new InvalidOperationException("Current application is null");
if (Application.Current.MainPage is null) throw new InvalidOperationException("Current main application page is null");

return await Application.Current.MainPage.DisplayPromptAsync(title, message, acceptButtonText, cancelButtonText);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ public DialogServiceMockBuilder Where_DisplayConfirmationAsync_returns(bool resu
.ReturnsAsync(result);
return this;
}
public DialogServiceMockBuilder Where_DisplayPromptAsync_returns(string? result)
{
Mock.Setup(x => x.DisplayPromptAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>()))
.ReturnsAsync(result);
return this;
}

public void Verify_DisplayAlert_called(string title, string message, string accept)
{
Expand Down
6 changes: 6 additions & 0 deletions src/Blauhaus.MVVM.Xamarin/Dialogs/FormsDialogService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,11 @@ public Task<string> DisplayActionSheetAsync(string title, string cancel, string
return _threadService.InvokeOnMainThreadAsync(async () => await _application
.DisplayActionSheetAsync(title, cancel, destruction, buttons));
}

public Task<string?> DisplayPromptAsync(string title, string message, string cancelButtonText = "Cancel", string acceptButtonText = "OK")
{
return _threadService.InvokeOnMainThreadAsync(async () => await _application
.DisplayPromptAsync(title, message, cancelButtonText, acceptButtonText));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ public Task<string> DisplayActionSheetAsync(string title, string cancel, string
return Application.Current.MainPage.DisplayActionSheet(title, cancel, destruction, buttons);
}

public Task GoToAsync(string route, bool animate)
public Task<string?> DisplayPromptAsync(string title, string message, string cancelButtonText = "Cancel", string acceptButtonText = "OK")
{
return Shell.Current.GoToAsync(route, animate);
return Application.Current.MainPage.DisplayPromptAsync(title, message, acceptButtonText, cancelButtonText);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ public interface IFormsApplicationProxy
Task<bool> DisplayAlertAsync(string title, string message, string cancel, string accept);
Task DisplayAlertAsync(string title, string message, string cancel);
Task<string> DisplayActionSheetAsync(string title, string cancel, string destruction, params string[] buttons);
Task<string?> DisplayPromptAsync(string title, string message, string cancelButtonText = "Cancel", string acceptButtonText = "OK");

}
}

0 comments on commit 3aa7558

Please sign in to comment.