-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Flex layout extension overload (#49)
* flex layout basis overload * Tests added and passed * flex layout basis overload * Tests added and passed * Summary updated for all flexlayout extension methods. testing isRelative * Sample page added * working on flexlayout sample page * Fix Build Errors, Use `.Font()` and `.Text()` Extensions * changing story model and add properties to display * Update NewsDetailPage Co-authored-by: Daniel <[email protected]> Co-authored-by: Pedro Jesus <[email protected]> Co-authored-by: Brandon Minnick <[email protected]>
- Loading branch information
1 parent
0a9a823
commit 97cedec
Showing
9 changed files
with
131 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
samples/CommunityToolkit.Maui.Markup.Sample/Pages/NewsDetailPage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using Microsoft.Maui.Layouts; | ||
using CommunityToolkit.Maui.Markup; | ||
using Microsoft.Maui.Controls; | ||
using Microsoft.Maui.Graphics; | ||
using CommunityToolkit.Maui.Markup.Sample.Pages.Base; | ||
using CommunityToolkit.Maui.Markup.Sample.ViewModels; | ||
using CommunityToolkit.Maui.Markup.Sample.Constants; | ||
|
||
namespace CommunityToolkit.Maui.Markup.Sample.Pages; | ||
|
||
class NewsDetailPage : BaseContentPage<NewsDetailViewModel> | ||
{ | ||
public NewsDetailPage(NewsDetailViewModel newsDetailViewModel) : base(newsDetailViewModel, newsDetailViewModel.Title) | ||
{ | ||
Content = new FlexLayout | ||
{ | ||
Direction = FlexDirection.Column, | ||
AlignContent = FlexAlignContent.Center, | ||
|
||
Children = | ||
{ | ||
new WebView() | ||
.Grow(1).AlignSelf(FlexAlignSelf.Stretch) | ||
.Bind(WebView.SourceProperty, nameof(NewsDetailViewModel.Uri), BindingMode.OneTime), | ||
|
||
new Button { BackgroundColor = ColorConstants.NavigationBarBackgroundColor } | ||
.Text("Launch in Browser \uf35d", ColorConstants.PrimaryTextColor) | ||
.Font(size: 20, family: "FontAwesome") | ||
.Basis(50) | ||
.Bind(Button.CommandProperty, nameof(NewsDetailViewModel.OpenBrowserCommand)), | ||
|
||
new Label { BackgroundColor = ColorConstants.NavigationBarBackgroundColor } | ||
.TextColor(ColorConstants.PrimaryTextColor).TextCenter() | ||
.AlignSelf(FlexAlignSelf.Stretch) | ||
.Paddings(bottom: 20) | ||
.Bind(Label.TextProperty, nameof(NewsDetailViewModel.ScoreDescription), BindingMode.OneTime), | ||
} | ||
}; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+567 KB
samples/CommunityToolkit.Maui.Markup.Sample/Resources/Fonts/FontAwesome.otf
Binary file not shown.
47 changes: 47 additions & 0 deletions
47
samples/CommunityToolkit.Maui.Markup.Sample/ViewModels/NewsDetailViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Input; | ||
using CommunityToolkit.Maui.Markup.Sample.Constants; | ||
using CommunityToolkit.Maui.Markup.Sample.Models; | ||
using CommunityToolkit.Maui.Markup.Sample.ViewModels.Base; | ||
using CommunityToolkit.Mvvm.Input; | ||
using Microsoft.Maui.ApplicationModel; | ||
using Microsoft.Maui.Controls; | ||
|
||
namespace CommunityToolkit.Maui.Markup.Sample.ViewModels; | ||
|
||
class NewsDetailViewModel : BaseViewModel | ||
{ | ||
readonly IBrowser browser; | ||
|
||
public NewsDetailViewModel(StoryModel storyModel, IBrowser browser) | ||
{ | ||
this.browser = browser; | ||
|
||
Uri = new Uri(storyModel.Url); | ||
Title = storyModel.Title; | ||
ScoreDescription = storyModel.ToString(); | ||
|
||
OpenBrowserCommand = new AsyncRelayCommand(ExecuteOpenBrowserCommand); | ||
} | ||
|
||
public Uri Uri { get; } | ||
public string Title { get; } | ||
public string ScoreDescription { get; } | ||
|
||
public ICommand OpenBrowserCommand { get; } | ||
|
||
Task ExecuteOpenBrowserCommand() | ||
{ | ||
var browserOptions = new BrowserLaunchOptions | ||
{ | ||
PreferredControlColor = ColorConstants.BrowserNavigationBarTextColor, | ||
PreferredToolbarColor = ColorConstants.BrowserNavigationBarBackgroundColor | ||
}; | ||
|
||
return browser.OpenAsync(Uri, browserOptions); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters