Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visual Challenge Feedback #57

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 14 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,21 @@

To take a single page design from a previous project that should look the same on iOS and Android, and attempt to recreate it using the latest Visual feature of Xamarin.Forms.

## Challenge Quick Start
# Results

This is testing **Visual**, not your prowess as a mobile developer. I want to learn how successful you are when using this new feature. Or not.
## Before
![](media/visual_before.png)

1. Fork this repository
2. Choose a single page design from a previous or current project to recreate from scratch. The more real world the better. Plus, you can reuse assets.
3. Open `VisualChallengePage.xaml`. Take an hour (or more if you really want to) and build that screen. Making it super functional doesn't matter, just how it looks and feels.
4. Submit a pull request of your progress back to this repository. Include:
- a screenshot of iOS and Android
- your feedback on what went well, and what didn't
- what you would like to see us doing differently in support of this goal: same design on iOS and Android
## After
![](media/visual_after.png)

## VISUAL Feedback
* Look nice. Will save a ton of custom control and custom styles out of the box.
* Interested in how we can roll out our own `VisualMarker` to handle app-wide theme/styles.
* It will be nice to have a way to set `Visual` app-wide.
* If introducing `Visual` to existing app, steps to the required package are not clear. Maybe a warning/error can be thrown if we set `Visual` but the Visual NuGet package is not installed or referenced.

# What is Visual?

Visual is a new way to declare the "visual" design system you want rendering your native controls. By default, controls are renderered the way Apple and Google created them. With Visual, you can choose Material as the design system that will then render the same on iOS and Android.

For example, this sample app sets the Visual preference on the application `Shell` and it is propogated to all controls in the application.

```
<Shell xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:VisualChallenge"
RouteHost="companyname.com"
RouteScheme="app"
Route="VisualChallenge"
FlyoutBehavior="Disabled"
Title="VisualChallenge"
x:Class="VisualChallenge.AppShell"
Visual="Material">
```

Any control may override this propogation by declaring its own Visual preference:

```
<Button Visual="Default" ... />
```

> **More than Styles:** Visual goes beyond styling the controls, to also unifying behavior and layout. This is work you may often do yourself when achieving the same look and feel between iOS and Android.


Read more about this at [https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/visual](https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/visual).

## What is Material?

Material is Google's modern design system that is popular not only on Android, but has lately found its way to iOS and the Web also. Google publishes a package of Material controls for iOS, and that's the starting point for the Xamarin.Forms native control renderers when you selected `Visual="Material"`.

For more information, visit [material.io](https://material.io/).

## Instructions on Updating your own project
- Install https://www.nuget.org/packages/Xamarin.Forms.Visual.Material/4.0.0.169046-pre5 into your ios project
- Add FormsMaterial.Init() after the Forms.Init() call in your AppDelegate on ios

### Issues !?
* `Frame` does not honor `CornerRadius` in Material.
* `Picker` does not show `Title` in Material.
* `Switch` does not change apperance in Material on iOS.
60 changes: 45 additions & 15 deletions VisualChallenge/VisualChallenge/VisualChallengePage.xaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,53 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
x:Class="VisualChallenge.VisualChallengePage"
Shell.NavBarIsVisible="True"
BackgroundColor="White"
Title="Visual Challenge"
>

<!-- If you decide to change out the flexlayout leave the scroll view here
Currently there's a bug in shell that will set margins wrong if the content is not in a scrollview
-->
<ScrollView>
<FlexLayout Margin="20" Direction="Column" AlignContent="Center" JustifyContent="SpaceAround">

<Label Text="Start Here" FontSize="24" HorizontalTextAlignment="Center"/>

<Button Text="Read More About Visual" Clicked="Button_Clicked" />

</FlexLayout>
</ScrollView>
Visual="Material">

<Grid Padding="20">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ScrollView>
<Frame VerticalOptions="Center" Margin="8">
<StackLayout Spacing="12">
<StackLayout Orientation="Horizontal">
<Entry Placeholder="First Name" HorizontalOptions="FillAndExpand"/>
<Entry Placeholder="Last Name" HorizontalOptions="FillAndExpand"/>
</StackLayout>
<Entry Placeholder="Username"/>
<Entry Placeholder="Password" IsPassword="true"/>

<Picker Title="Account Picker">
<Picker.Items>
<sys:String>Personal</sys:String>
<sys:String>Business</sys:String>
</Picker.Items>
</Picker>

<StackLayout Orientation="Horizontal">
<DatePicker HorizontalOptions="FillAndExpand" />
<TimePicker HorizontalOptions="FillAndExpand" />
</StackLayout>

<Label Text="Progress bar"/>
<ProgressBar x:Name="progressBar"/>

<Label Text="Slider"/>
<Slider ValueChanged="Handle_ValueChanged" VerticalOptions="End"/>

<StackLayout Orientation="Horizontal">
<Label Text="Button Enabled" VerticalTextAlignment="Center" HorizontalOptions="FillAndExpand"/>
<Switch Toggled="Handle_Toggled" IsToggled="true"/>
</StackLayout>
</StackLayout>
</Frame>
</ScrollView>
<Button x:Name="LonelyButton" Grid.Row="1" Text="Visual" Clicked="Button_Clicked" VerticalOptions="End" />
</Grid>
</ContentPage>
14 changes: 11 additions & 3 deletions VisualChallenge/VisualChallenge/VisualChallengePage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;

using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace VisualChallenge
{
Expand All @@ -14,7 +12,17 @@ public VisualChallengePage()

private void Button_Clicked(object sender, EventArgs e)
{
Device.OpenUri(new Uri("https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/visual"));
//Device.OpenUri(new Uri("https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/visual"));
}

void Handle_ValueChanged(object sender, Xamarin.Forms.ValueChangedEventArgs e)
{
progressBar.Progress = e.NewValue;
}

void Handle_Toggled(object sender, Xamarin.Forms.ToggledEventArgs e)
{
LonelyButton.IsEnabled = e.Value;
}
}
}
Binary file added media/visual_after.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/visual_before.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.