bind profile picture image between HomePage and Account
continuous-integration/drone/push Build is passing Details

pull/40/head
Maxime BATISTA 2 years ago
parent fcbbb28a34
commit 7a0eb8d0da

@ -22,7 +22,7 @@ public partial class App : Application, ConnectionObserver
public void OnAccountConnected(Account account)
{
Shell shell = new MainAppShell(account);
Shell shell = new MainAppShell(account, Notifier);
shell.GoToAsync("//MainPage");
MainPage = shell;
}

@ -1,9 +1,4 @@
using Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ShoopNCook
{

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ShoopNCook
namespace ShoopNCook
{
/// <summary>
/// A notice reporter implementation that prints in console the applications's user notices.
@ -14,17 +8,17 @@ namespace ShoopNCook
{
public void Error(string message)
{
Console.WriteLine("<Notice Reporter> Error: " + message);
Console.WriteLine("<User Notice> Error: " + message);
}
public void Notice(string message)
{
Console.WriteLine("<Notice Reporter> Notice: " + message);
Console.WriteLine("<User Notice> Notice: " + message);
}
public void Warn(string message)
{
Console.WriteLine("<Notice Reporter> Warn: " + message);
Console.WriteLine("<User Notice> Warn: " + message);
}
}
}

@ -14,28 +14,24 @@
<ShellContent
x:Name="HomeTab"
Title="Home"
ContentTemplate="{DataTemplate pages:HomePage}"
Route="HomePage"
Route="Home"
Icon="home.svg"/>
<ShellContent
x:Name="FavoritesTab"
Title="Favorites"
ContentTemplate="{DataTemplate pages:FavoritesPage}"
Route="Favorites"
Icon="hearth_on.svg"/>
<ShellContent
x:Name="MyListTab"
Title="MyList"
ContentTemplate="{DataTemplate pages:MyListPage}"
Route="MyList"
Icon="list.svg"/>
<ShellContent
x:Name="MoreTab"
Title="More"
ContentTemplate="{DataTemplate pages:MorePage}"
Route="More"
Icon="more.svg"/>
</TabBar>

@ -1,11 +1,16 @@
namespace ShoopNCook;
using Microsoft.Maui.Controls;
using Models;
using ShoopNCook.Pages;
public partial class MainAppShell : Shell
{
public MainAppShell(Account account)
public MainAppShell(Account account, UserNotifier notifier)
{
InitializeComponent();
HomeTab.ContentTemplate = new DataTemplate(() => new HomePage(account, notifier));
FavoritesTab.ContentTemplate = new DataTemplate(() => new FavoritesPage(account, notifier));
MyListTab.ContentTemplate = new DataTemplate(() => new MyListPage(account, notifier));
MoreTab.ContentTemplate = new DataTemplate(() => new MorePage(account, notifier));
}
}

@ -1,8 +1,10 @@
using Models;
namespace ShoopNCook.Pages;
public partial class FavoritesPage : ContentPage
{
public FavoritesPage()
public FavoritesPage(Account account, UserNotifier notifier)
{
InitializeComponent();
}

@ -13,16 +13,14 @@
JustifyContent="SpaceBetween"
AlignItems="Center"
AlignContent="Center"
Margin="20,35,20,20"
>
Margin="20,35,20,20">
<Border
Style="{StaticResource SecondaryBorder}"
BackgroundColor="{StaticResource BackgroundSecondary}"
StrokeShape="RoundRectangle 1500"
>
StrokeShape="RoundRectangle 1500">
<ImageButton
Source="default_profile_picture.png"
x:Name="ProfilePictureImage"
WidthRequest="65"
HeightRequest="65"/>
</Border>

@ -1,10 +1,13 @@
using Models;
namespace ShoopNCook.Pages;
public partial class HomePage : ContentPage
{
public HomePage()
public HomePage(Account account, UserNotifier notifier)
{
InitializeComponent();
ProfilePictureImage.Source = ImageSource.FromUri(account.User.ProfilePicture);
}
private async void OnSyncButtonClicked(object sender, EventArgs e)
{

@ -1,16 +1,15 @@
using Models;
namespace ShoopNCook.Pages;
public partial class MorePage : ContentPage
{
public MorePage(): this("Adom Shafi", ImageSource.FromFile("default_profile_picture.png"))
{
}
public MorePage(string userName, ImageSource userImage)
public MorePage(Account account, UserNotifier notifier)
{
InitializeComponent();
ProfileImage.Source = userImage;
ProfileName.Text = userName;
ProfileImage.Source = ImageSource.FromUri(account.User.ProfilePicture);
ProfileName.Text = account.User.Name;
}
private async void OnMyRecipesButtonTapped(object sender, EventArgs e)
{

@ -1,8 +1,10 @@
using Models;
namespace ShoopNCook.Pages;
public partial class MyListPage : ContentPage
{
public MyListPage()
public MyListPage(Account account, UserNotifier notifier)
{
InitializeComponent();
}

Loading…
Cancel
Save