dotnet-architecture / eshop-mobile-client Goto Github PK
View Code? Open in Web Editor NEWeShop mobile & desktop client built with .NET MAUI
Home Page: https://dotnet.microsoft.com/learn/maui/architecture
License: MIT License
eShop mobile & desktop client built with .NET MAUI
Home Page: https://dotnet.microsoft.com/learn/maui/architecture
License: MIT License
In NavigationService's InternalNavigateToAsync method, I see that InitializeAsync is called after the Page instance is created. This can result in a NullReferenceException if the Page's ViewModel, which is created by AutoWire, is not initialized by InitializeAsync and Page starts binding to ViewModel's properties.
For example, this would crash:
public int OrderPrice => Order.Price;
because Order
can be initialized only when InitializeAsync is called using navigationData
Should every ViewModel be responsible for handling the possibility of uninitialized data?
For example:
public int OrderPrice => Order?.Price ?? 0;
The conditional logic could be avoided if we InitializeAsync first, before assigning BindingContext to the Page.
if you use filter and select just brand and not 2nd line then apply you get system.nullReferenceException : object reference not set to instance of object
Web authenticator samples are necessary, this is a big trend, it seems that Microsoft doesn't care at all…………
All project templates starting with .NET 6 (C# 10) enable the nullable context for the project. Projects created with earlier templates don't include this element, and these features are off unless you enable them in the project file or use pragmas.
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/nullable-reference-types
It would be nice if the reference applications showed how to use nullable reference types as it is the default setting in the latest project templates.
eShopOnContainers.UnitTests/eShopOnContainers.UnitTests.csproj
has nullable set to enable, but eShopOnContainers/eShopOnContainers.csproj
does not.
Basically same issue as: dotnet-architecture/eShopOnContainers#1681
When we provide the actual mobile aggregator endpoint (http://<HOST_DNS>/mobileshoppingagg/swagger/index.html) in the settings
and login to the App, we see the following exception.
Also, when we go to the catalog page, none of the product items get listed. That's because the catalog service endpoint mentioned in the below code snippet expects the catalog-api
endpoint through the mobile aggregator, which is not present.
Users will also see the similar problem when they visit their profile pages where the Ordering
service is getting referred.
Please see dotnet-architecture/News#38 for more information.
as per title: code duplication exists, while there are minor differences. Which one is moved forward? (I assume eShop repo):
https://github.com/dotnet/eShop/tree/main/src/ClientApp
Thanks!
It's not possible to remove an item from Cart (tested on Windows)?
It seems there's still a dependency of the view models on the views: When the view models call INavigationService.NavigateToAsync()
, they pass the route key. However these route keys are defined in the AppShell
which I would consider to be part of the view layer.
After placing an order, the Cart badge still shows x number of products, although the Cart is empty.
(Tested in mock mode)
I'm trying to do TDD but I'm finding it hard to deal with Preferences and Shell.Current objects that can't be injected and are created by Maui at running time.
I reviewed your brilliant application and found that you access all of them through services, freeing the View Models of references.
But, isn't it just passing the buck? At the end, the services aren't tested. I can test MVVM fine, but not Services.
Is that the case? You don't have a way to test your services in your code?
To illustrate:
This comes from the Settings Service:
public string AuthAccessToken
{
get => Preferences.Get(AccessToken, AccessTokenDefault);
set => Preferences.Set(AccessToken, value);
}
Now, I don't know a way to mock or stub the Preferences static class in the last two lines. If I want to test the service, I can't, because the Preferences static object is not injected but created behind the scenes.
<Entry IsPassword="True" Text="{Binding Password.Value, Mode=TwoWay}">
<Entry.Style>
<OnPlatform x:TypeArguments="Style">
<On Platform="iOS, Android" Value="{StaticResource EntryStyle}" />
<On Platform="WinUI" Value="{StaticResource WinUIEntryStyle}" />
</OnPlatform>
</Entry.Style>
<Entry.Behaviors>
<mct:EventToCommandBehavior EventName="TextChanged" Command="{Binding ValidatePasswordCommand}" />
</Entry.Behaviors>
<Entry.Triggers>
<DataTrigger TargetType="Entry" Binding="{Binding Password.IsValid}" Value="True">
<Setter Property="BackgroundColor" Value="{StaticResource ErrorColor}" />
</DataTrigger>
</Entry.Triggers>
</Entry>
File: LoginView.cs, lines 202-224
I'm trying very hard to learn the method taught in the book (and in this accompanying code) for performing validations in .NET MAUI and MVVM. Now I've studied this quite a bit, and I think I understand everything (or at least most of it). But there appears to be a problem with the DataTriggers not firing in the Entry controls for UserName and Password in the login View.
For example, in the code above, we see that the DataTrigger in the Entry control for Password is bound to Password.IsValid in the login ViewModel, and we know that Password is a ValidatableObject in the ViewModel. Okay, so Password is a ValidatableObject and will therefore notify any bound controls in the View when the value for Password changes. But does Password.IsValid work in the same way? I mean, will Password.IsValid (not Password) also notify any bound controls in the View when the value for Password.IsValid (not Password) changes? I really don't think so. In my tests, I'm seeing that when the value for Password.IsValid changes from True to False, the DataTrigger in the View doesn't fire--presumably because it doesn't get notified about the change to Password.IsValid.
Is this a bug? Or what's another way to handle this, so that the intended effect occurs (i.e. the background color of the Entry control gets changed in the View) when Password.IsValid changes in the ViewModel?
On Windows 11, Settings page is crushed with System.ArgumentNullException
. Because _settingsService.Latitude
that is null value on Windows is passed to double.Parse
method on following line:
With the new tech in town, .Net MAUI, are we going to get an update for this?
Could you please explain why ConfigureAwait(False)
is used with most of the HTTP requests and JSON serialization. This is the first sample MAUI app I've seen that uses it so much. Thank you in advance for any answers.
Severity Code Description Project File Line Suppression State
Warning CS0618 'MessagingCenter' is obsolete: 'We recommend migrating to CommunityToolkit.MVVM.WeakReferenceMessenger
: https://www.nuget.org/packages/CommunityToolkit.Mvvm' eShopOnContainers (net7.0-android) ~Source\Repos\eshop-mobile-client\eShopOnContainers\ViewModels\CatalogViewModel.cs 148 Active
the associated text also has chapter on messaging centre what changes are quired to make it work
In SignInAsync() @ LoginViewModel.cs, didn't we miss a call something like AuthorizeAsync()?
SignInAsync() creates a "request", but does not send the request anywhere.
Original issue : dotnet-architecture/eShopOnContainers#1366
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.