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

First draft of Contact Page #16

Merged
merged 1 commit into from
Apr 15, 2019
Merged
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
6 changes: 4 additions & 2 deletions CodingCoach/CodingCoach.Android/CodingCoach.Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
<TargetFrameworkVersion>v8.1</TargetFrameworkVersion>
<AndroidHttpClientHandlerType>Xamarin.Android.Net.AndroidClientHandler</AndroidHttpClientHandlerType>
<NuGetPackageImportStamp>
Expand Down Expand Up @@ -68,6 +67,9 @@
<PackageReference Include="Xamarin.Android.Support.v4" Version="28.0.0.1" />
<PackageReference Include="Xamarin.Android.Support.v7.CardView" Version="28.0.0.1" />
<PackageReference Include="Xamarin.Android.Support.v7.MediaRouter" Version="28.0.0.1" />
<PackageReference Include="Xamarin.Essentials">
<Version>1.1.0</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Compile Include="FontAwesomeBrandIconRenderer.cs" />
Expand Down Expand Up @@ -114,7 +116,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CodingCoach\CodingCoach.csproj">
<Project>{629F997C-32F2-490C-AAA4-4A7A90FFC498}</Project>
<Project>{6E5D64F0-404D-4831-B324-F5A6D2171988}</Project>
<Name>CodingCoach</Name>
</ProjectReference>
</ItemGroup>
Expand Down
15 changes: 9 additions & 6 deletions CodingCoach/CodingCoach.Android/MainActivity.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
using System;

using Android.App;
using Android.Content.PM;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Android.Runtime;
using ImageCircle.Forms.Plugin.Droid;

namespace CodingCoach.Droid
Expand All @@ -19,9 +15,16 @@ protected override void OnCreate(Bundle savedInstanceState)
ToolbarResource = Resource.Layout.Toolbar;

base.OnCreate(savedInstanceState);
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
ImageCircleRenderer.Init();
LoadApplication(new App());
LoadApplication(new App());
}

public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
{
Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.CodingCoach">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="27" />
<application android:label="CodingCoach.Android"></application>
</manifest>
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="27" />
<application android:label="CodingCoach.Android"></application>
</manifest>
5 changes: 4 additions & 1 deletion CodingCoach/CodingCoach.iOS/CodingCoach.iOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,14 @@
<Version>3.0.0.5</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms" Version="3.6.0.293080" />
<PackageReference Include="Xamarin.Essentials">
<Version>1.1.0</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
<ItemGroup>
<ProjectReference Include="..\CodingCoach\CodingCoach.csproj">
<Project>{629F997C-32F2-490C-AAA4-4A7A90FFC498}</Project>
<Project>{6E5D64F0-404D-4831-B324-F5A6D2171988}</Project>
<Name>CodingCoach</Name>
</ProjectReference>
</ItemGroup>
Expand Down
4 changes: 1 addition & 3 deletions CodingCoach/CodingCoach/CodingCoach.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="Xam.Plugins.Forms.ImageCircle" Version="3.0.0.5" />
<PackageReference Include="Xamarin.Forms" Version="3.6.0.293080" />
<PackageReference Include="Xamarin.Essentials" Version="1.1.0" />
</ItemGroup>

<ItemGroup>
Expand All @@ -41,9 +42,6 @@
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="Assets\styles.css">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Update="CustomControls\TagsView.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
Expand Down
14 changes: 14 additions & 0 deletions CodingCoach/CodingCoach/Models/Constants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;

namespace CodingCoach.Models.Constants
{
public class Urls
{
public const string Slack = "https://join.slack.com/t/coding-coach/shared_invite/enQtNDYxNTcwMjk4MDcwLThiZjY1MTM2YTU1YzM2MGI1N2Y1NDI3ZGM1MGRhNjdiZjU0MzE1YjMxZjdlZmVlNDdhNmFhN2RhNGIxZmE1YTI";
}

public class Emails
{
public const string Contact = "[email protected]";
}
}
30 changes: 14 additions & 16 deletions CodingCoach/CodingCoach/Models/HomeMenuItem.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace CodingCoach.Models
namespace CodingCoach.Models
{
public enum MenuItemType
{
Browse,
About
}
public class HomeMenuItem
{
public MenuItemType Id { get; set; }
public enum MenuItemType
{
Browse,
About,
Contact
}

public class HomeMenuItem
{
public MenuItemType Id { get; set; }

public string Title { get; set; }
}
}
public string Title { get; set; }
}
}
36 changes: 36 additions & 0 deletions CodingCoach/CodingCoach/ViewModels/ContactViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Windows.Input;
using Xamarin.Essentials;
using Xamarin.Forms;

namespace CodingCoach.ViewModels
{
public class ContactViewModel : BaseViewModel
{
private ICommand _slackCommand;
public ICommand SlackCommand => _slackCommand ?? (_slackCommand = new Command(OpenSlack));

private ICommand _emailCommand;
public ICommand EmailCommand => _emailCommand ?? (_emailCommand = new Command(async () => await ComposeEmail()));

public ContactViewModel()
{
Title = "Contact";
}

private void OpenSlack()
{
Device.OpenUri(new Uri(Models.Constants.Urls.Slack));
}

private Task ComposeEmail()
{
//Remark: This will only work on a real iOS device and not on iOS simulator
//https://github.com/xamarin/Essentials/issues/370

return Email.ComposeAsync(new EmailMessage() { To = new List<string>() { Models.Constants.Emails.Contact } });
}
}
}
34 changes: 34 additions & 0 deletions CodingCoach/CodingCoach/Views/ContactPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CodingCoach.Views.ContactPage"
xmlns:vm="clr-namespace:CodingCoach.ViewModels"
Title="{Binding Title}"
class="page">
<ContentPage.BindingContext>
<vm:ContactViewModel />
</ContentPage.BindingContext>

<ContentPage.Content>
<StackLayout Margin="20">
<Label>
<Label.FormattedText>
<FormattedString>
<Span Text="We want to hear your thoughts! Feel free to join our " />
<Span Text="Slack Organization" TextDecorations="Underline">
<Span.GestureRecognizers>
<TapGestureRecognizer Command="{Binding SlackCommand}" />
</Span.GestureRecognizers>
</Span>
<Span Text=" or send us an email at " />
<Span Text="[email protected]" TextColor="#69d5b1">
<Span.GestureRecognizers>
<TapGestureRecognizer Command="{Binding EmailCommand}" />
</Span.GestureRecognizers>
</Span>
</FormattedString>
</Label.FormattedText>
</Label>
</StackLayout>
</ContentPage.Content>
</ContentPage>
12 changes: 12 additions & 0 deletions CodingCoach/CodingCoach/Views/ContactPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Xamarin.Forms;

namespace CodingCoach.Views
{
public partial class ContactPage : ContentPage
{
public ContactPage()
{
InitializeComponent();
}
}
}
7 changes: 1 addition & 6 deletions CodingCoach/CodingCoach/Views/ItemsPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

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

using CodingCoach.Models;
using CodingCoach.Views;
using CodingCoach.ViewModels;

namespace CodingCoach.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class ItemsPage : ContentPage
{
ItemsViewModel viewModel;
Expand Down
74 changes: 38 additions & 36 deletions CodingCoach/CodingCoach/Views/MainPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,51 +1,53 @@
using CodingCoach.Models;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace CodingCoach.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class MainPage : MasterDetailPage
{
Dictionary<int, NavigationPage> MenuPages = new Dictionary<int, NavigationPage>();
public MainPage()
{
InitializeComponent();

MasterBehavior = MasterBehavior.Popover;

MenuPages.Add((int)MenuItemType.Browse, (NavigationPage)Detail);
}

public async Task NavigateFromMenu(int id)
{
if (!MenuPages.ContainsKey(id))
{
switch (id)
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class MainPage : MasterDetailPage
{
Dictionary<int, NavigationPage> MenuPages = new Dictionary<int, NavigationPage>();
public MainPage()
{
InitializeComponent();

MasterBehavior = MasterBehavior.Popover;

MenuPages.Add((int)MenuItemType.Browse, (NavigationPage)Detail);
}

public async Task NavigateFromMenu(int id)
{
if (!MenuPages.ContainsKey(id))
{
case (int)MenuItemType.Browse:
MenuPages.Add(id, new NavigationPage(new ItemsPage()));
break;
case (int)MenuItemType.About:
MenuPages.Add(id, new NavigationPage(new AboutPage()));
break;
switch (id)
{
case (int)MenuItemType.Browse:
MenuPages.Add(id, new NavigationPage(new ItemsPage()));
break;
case (int)MenuItemType.About:
MenuPages.Add(id, new NavigationPage(new AboutPage()));
break;
case (int)MenuItemType.Contact:
MenuPages.Add(id, new NavigationPage(new ContactPage()));
break;
}
}
}

var newPage = MenuPages[id];
var newPage = MenuPages[id];

if (newPage != null && Detail != newPage)
{
Detail = newPage;
if (newPage != null && Detail != newPage)
{
Detail = newPage;

if (Device.RuntimePlatform == Device.Android)
await Task.Delay(100);
if (Device.RuntimePlatform == Device.Android)
await Task.Delay(100);

IsPresented = false;
}
}
}
IsPresented = false;
}
}
}
}
3 changes: 2 additions & 1 deletion CodingCoach/CodingCoach/Views/MenuPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public MenuPage()
menuItems = new List<HomeMenuItem>
{
new HomeMenuItem {Id = MenuItemType.Browse, Title="Mentors" },
new HomeMenuItem {Id = MenuItemType.About, Title="About" }
new HomeMenuItem {Id = MenuItemType.About, Title="About" },
new HomeMenuItem {Id = MenuItemType.Contact, Title="Contact" }
};

ListViewMenu.ItemsSource = menuItems;
Expand Down