├── _config.yml
├── TenDaysOfXamarin.iOS
├── Resources
│ ├── Default.png
│ ├── Default@2x.png
│ ├── Default-568h@2x.png
│ ├── Default-Portrait.png
│ ├── Default-Portrait@2x.png
│ └── LaunchScreen.storyboard
├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ ├── Icon120.png
│ │ ├── Icon152.png
│ │ ├── Icon167.png
│ │ ├── Icon180.png
│ │ ├── Icon20.png
│ │ ├── Icon29.png
│ │ ├── Icon40.png
│ │ ├── Icon58.png
│ │ ├── Icon60.png
│ │ ├── Icon76.png
│ │ ├── Icon80.png
│ │ ├── Icon87.png
│ │ ├── Icon1024.png
│ │ └── Contents.json
├── Entitlements.plist
├── Main.cs
├── AppDelegate.cs
├── Properties
│ └── AssemblyInfo.cs
├── Info.plist
└── TenDaysOfXamarin.iOS.csproj
├── TenDaysOfXamarin.Android
├── Resources
│ ├── mipmap-hdpi
│ │ ├── icon.png
│ │ └── launcher_foreground.png
│ ├── mipmap-mdpi
│ │ ├── icon.png
│ │ └── launcher_foreground.png
│ ├── mipmap-xhdpi
│ │ ├── icon.png
│ │ └── launcher_foreground.png
│ ├── mipmap-xxhdpi
│ │ ├── icon.png
│ │ └── launcher_foreground.png
│ ├── mipmap-xxxhdpi
│ │ ├── icon.png
│ │ └── launcher_foreground.png
│ ├── mipmap-anydpi-v26
│ │ ├── icon.xml
│ │ └── icon_round.xml
│ ├── values
│ │ ├── colors.xml
│ │ └── styles.xml
│ ├── layout
│ │ ├── Toolbar.axml
│ │ └── Tabbar.axml
│ └── AboutResources.txt
├── Properties
│ ├── AndroidManifest.xml
│ └── AssemblyInfo.cs
├── Assets
│ └── AboutAssets.txt
├── MainActivity.cs
└── TenDaysOfXamarin.Android.csproj
├── TenDaysOfXamarin
├── Helpers
│ └── Constants.cs
├── Views
│ ├── ExperiencesPage.xaml.cs
│ ├── ExperiencesPage.xaml
│ ├── MainPage.xaml.cs
│ └── MainPage.xaml
├── ViewModels
│ ├── Commands
│ │ └── NewExperienceCommand.cs
│ ├── Helpers
│ │ ├── PermissionsHelper.cs
│ │ └── LocationHelper.cs
│ ├── ExperiencesVM.cs
│ └── MainVM.cs
├── App.xaml.cs
├── TenDaysOfXamarin.csproj
├── Model
│ ├── Experience.cs
│ └── Search.cs
└── App.xaml
├── .gitignore
├── .github
└── ISSUE_TEMPLATE
│ └── bug_report.md
├── azure-pipelines.yml
├── README.md
└── TenDaysOfXamarin.sln
/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-slate
--------------------------------------------------------------------------------
/TenDaysOfXamarin.iOS/Resources/Default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LaloCo/10DaysOfXamarin/HEAD/TenDaysOfXamarin.iOS/Resources/Default.png
--------------------------------------------------------------------------------
/TenDaysOfXamarin.iOS/Resources/Default@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LaloCo/10DaysOfXamarin/HEAD/TenDaysOfXamarin.iOS/Resources/Default@2x.png
--------------------------------------------------------------------------------
/TenDaysOfXamarin.iOS/Resources/Default-568h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LaloCo/10DaysOfXamarin/HEAD/TenDaysOfXamarin.iOS/Resources/Default-568h@2x.png
--------------------------------------------------------------------------------
/TenDaysOfXamarin.iOS/Resources/Default-Portrait.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LaloCo/10DaysOfXamarin/HEAD/TenDaysOfXamarin.iOS/Resources/Default-Portrait.png
--------------------------------------------------------------------------------
/TenDaysOfXamarin.Android/Resources/mipmap-hdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LaloCo/10DaysOfXamarin/HEAD/TenDaysOfXamarin.Android/Resources/mipmap-hdpi/icon.png
--------------------------------------------------------------------------------
/TenDaysOfXamarin.Android/Resources/mipmap-mdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LaloCo/10DaysOfXamarin/HEAD/TenDaysOfXamarin.Android/Resources/mipmap-mdpi/icon.png
--------------------------------------------------------------------------------
/TenDaysOfXamarin.iOS/Resources/Default-Portrait@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LaloCo/10DaysOfXamarin/HEAD/TenDaysOfXamarin.iOS/Resources/Default-Portrait@2x.png
--------------------------------------------------------------------------------
/TenDaysOfXamarin.Android/Resources/mipmap-xhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LaloCo/10DaysOfXamarin/HEAD/TenDaysOfXamarin.Android/Resources/mipmap-xhdpi/icon.png
--------------------------------------------------------------------------------
/TenDaysOfXamarin.Android/Resources/mipmap-xxhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LaloCo/10DaysOfXamarin/HEAD/TenDaysOfXamarin.Android/Resources/mipmap-xxhdpi/icon.png
--------------------------------------------------------------------------------
/TenDaysOfXamarin.Android/Resources/mipmap-xxxhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LaloCo/10DaysOfXamarin/HEAD/TenDaysOfXamarin.Android/Resources/mipmap-xxxhdpi/icon.png
--------------------------------------------------------------------------------
/TenDaysOfXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon120.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LaloCo/10DaysOfXamarin/HEAD/TenDaysOfXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon120.png
--------------------------------------------------------------------------------
/TenDaysOfXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon152.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LaloCo/10DaysOfXamarin/HEAD/TenDaysOfXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon152.png
--------------------------------------------------------------------------------
/TenDaysOfXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon167.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LaloCo/10DaysOfXamarin/HEAD/TenDaysOfXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon167.png
--------------------------------------------------------------------------------
/TenDaysOfXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon180.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LaloCo/10DaysOfXamarin/HEAD/TenDaysOfXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon180.png
--------------------------------------------------------------------------------
/TenDaysOfXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon20.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LaloCo/10DaysOfXamarin/HEAD/TenDaysOfXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon20.png
--------------------------------------------------------------------------------
/TenDaysOfXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon29.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LaloCo/10DaysOfXamarin/HEAD/TenDaysOfXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon29.png
--------------------------------------------------------------------------------
/TenDaysOfXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LaloCo/10DaysOfXamarin/HEAD/TenDaysOfXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon40.png
--------------------------------------------------------------------------------
/TenDaysOfXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon58.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LaloCo/10DaysOfXamarin/HEAD/TenDaysOfXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon58.png
--------------------------------------------------------------------------------
/TenDaysOfXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon60.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LaloCo/10DaysOfXamarin/HEAD/TenDaysOfXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon60.png
--------------------------------------------------------------------------------
/TenDaysOfXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LaloCo/10DaysOfXamarin/HEAD/TenDaysOfXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon76.png
--------------------------------------------------------------------------------
/TenDaysOfXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon80.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LaloCo/10DaysOfXamarin/HEAD/TenDaysOfXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon80.png
--------------------------------------------------------------------------------
/TenDaysOfXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon87.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LaloCo/10DaysOfXamarin/HEAD/TenDaysOfXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon87.png
--------------------------------------------------------------------------------
/TenDaysOfXamarin.Android/Resources/mipmap-hdpi/launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LaloCo/10DaysOfXamarin/HEAD/TenDaysOfXamarin.Android/Resources/mipmap-hdpi/launcher_foreground.png
--------------------------------------------------------------------------------
/TenDaysOfXamarin.Android/Resources/mipmap-mdpi/launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LaloCo/10DaysOfXamarin/HEAD/TenDaysOfXamarin.Android/Resources/mipmap-mdpi/launcher_foreground.png
--------------------------------------------------------------------------------
/TenDaysOfXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon1024.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LaloCo/10DaysOfXamarin/HEAD/TenDaysOfXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon1024.png
--------------------------------------------------------------------------------
/TenDaysOfXamarin.Android/Resources/mipmap-xhdpi/launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LaloCo/10DaysOfXamarin/HEAD/TenDaysOfXamarin.Android/Resources/mipmap-xhdpi/launcher_foreground.png
--------------------------------------------------------------------------------
/TenDaysOfXamarin.Android/Resources/mipmap-xxhdpi/launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LaloCo/10DaysOfXamarin/HEAD/TenDaysOfXamarin.Android/Resources/mipmap-xxhdpi/launcher_foreground.png
--------------------------------------------------------------------------------
/TenDaysOfXamarin.Android/Resources/mipmap-xxxhdpi/launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LaloCo/10DaysOfXamarin/HEAD/TenDaysOfXamarin.Android/Resources/mipmap-xxxhdpi/launcher_foreground.png
--------------------------------------------------------------------------------
/TenDaysOfXamarin.iOS/Entitlements.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/TenDaysOfXamarin.Android/Resources/mipmap-anydpi-v26/icon.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/TenDaysOfXamarin.Android/Resources/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFFFFF
4 | #3F51B5
5 | #303F9F
6 | #FF4081
7 |
--------------------------------------------------------------------------------
/TenDaysOfXamarin.Android/Resources/mipmap-anydpi-v26/icon_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/TenDaysOfXamarin/Helpers/Constants.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | namespace TenDaysOfXamarin.Helpers
3 | {
4 | public class Constants
5 | {
6 | public const string FOURSQR_CLIENT_ID = "N0CTIEHVIA24DMNXOTF0MT33Z1KH1PPJKLOPZMW1MSZWVTPJ";
7 | public const string FOURSQR_CLIENT_SECRET = "LOYLLSTG5UEUXMQIQ0DSC0VUMBDFNGNBH3MXAASZE0VPLWHE";
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/TenDaysOfXamarin.Android/Resources/layout/Toolbar.axml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/TenDaysOfXamarin.Android/Properties/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/TenDaysOfXamarin.Android/Resources/layout/Tabbar.axml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/TenDaysOfXamarin.iOS/Main.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | using Foundation;
6 | using UIKit;
7 |
8 | namespace TenDaysOfXamarin.iOS
9 | {
10 | public class Application
11 | {
12 | // This is the main entry point of the application.
13 | static void Main(string[] args)
14 | {
15 | // if you want to use a different Application Delegate class from "AppDelegate"
16 | // you can specify it here.
17 | UIApplication.Main(args, null, "AppDelegate");
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Autosave files
2 | *~
3 |
4 | # build
5 | [Oo]bj/
6 | [Bb]in/
7 | packages/
8 | TestResults/
9 |
10 | # globs
11 | Makefile.in
12 | *.DS_Store
13 | *.sln.cache
14 | *.suo
15 | *.cache
16 | *.pidb
17 | *.userprefs
18 | *.usertasks
19 | config.log
20 | config.make
21 | config.status
22 | aclocal.m4
23 | install-sh
24 | autom4te.cache/
25 | *.user
26 | *.tar.gz
27 | tarballs/
28 | test-results/
29 | Thumbs.db
30 | .vs/
31 |
32 | # Mac bundle stuff
33 | *.dmg
34 | *.app
35 |
36 | # resharper
37 | *_Resharper.*
38 | *.Resharper
39 |
40 | # dotCover
41 | *.dotCover
42 |
43 | # Private key files
44 | Constants.cs
45 |
--------------------------------------------------------------------------------
/TenDaysOfXamarin/Views/ExperiencesPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using SQLite;
4 | using TenDaysOfXamarin.Model;
5 | using TenDaysOfXamarin.ViewModels;
6 | using Xamarin.Forms;
7 |
8 | namespace TenDaysOfXamarin.Views
9 | {
10 | public partial class ExperiencesPage : ContentPage
11 | {
12 | ExperiencesVM viewModel;
13 | public ExperiencesPage()
14 | {
15 | InitializeComponent();
16 |
17 | viewModel = Resources["vm"] as ExperiencesVM;
18 | }
19 |
20 | protected override void OnAppearing()
21 | {
22 | base.OnAppearing();
23 |
24 | viewModel.ReadExperiences();
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/TenDaysOfXamarin.Android/Assets/AboutAssets.txt:
--------------------------------------------------------------------------------
1 | Any raw assets you want to be deployed with your application can be placed in
2 | this directory (and child directories) and given a Build Action of "AndroidAsset".
3 |
4 | These files will be deployed with you package and will be accessible using Android's
5 | AssetManager, like this:
6 |
7 | public class ReadAsset : Activity
8 | {
9 | protected override void OnCreate (Bundle bundle)
10 | {
11 | base.OnCreate (bundle);
12 |
13 | InputStream input = Assets.Open ("my_asset.txt");
14 | }
15 | }
16 |
17 | Additionally, some Android functions will automatically load asset files:
18 |
19 | Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
20 |
--------------------------------------------------------------------------------
/TenDaysOfXamarin/ViewModels/Commands/NewExperienceCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Input;
3 |
4 | namespace TenDaysOfXamarin.ViewModels.Commands
5 | {
6 | // added using System.Windows.Input;
7 | public class NewExperienceCommand : ICommand
8 | {
9 | private ExperiencesVM viewModel;
10 | public NewExperienceCommand(ExperiencesVM viewModel)
11 | {
12 | this.viewModel = viewModel;
13 | }
14 |
15 | public event EventHandler CanExecuteChanged;
16 |
17 | public bool CanExecute(object parameter)
18 | {
19 | return true;
20 | }
21 |
22 | public void Execute(object parameter)
23 | {
24 | viewModel.NewExperience();
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 |
3 | name: Bug report
4 | about: Create a report to help us improve
5 | title: ''
6 | labels: ''
7 | assignees: LaloCo
8 |
9 | ---
10 |
11 | - **Day:** [e.g. 1]
12 |
13 | **Describe the bug**
14 | A clear and concise description of what the bug is.
15 |
16 | **To Reproduce**
17 | Steps to reproduce the behavior:
18 |
19 | 1. Go to '...'
20 | 2. Click on '....'
21 | 3. Scroll down to '....'
22 | 4. See error
23 |
24 | **Expected behavior**
25 | A clear and concise description of what you expected to happen.
26 |
27 | **Screenshots**
28 | If applicable, add screenshots to help explain your problem.
29 |
30 | **Desktop (please complete the following information):**
31 |
32 | - OS: [e.g. macOS]
33 | - Visual Studio [e.g. 7.8.2]
34 | - Xamarin Forms Version [e.g. 3.5]
35 |
36 | **Smartphone (please complete the following information):**
37 |
38 | - Device: [e.g. iPhone6]
39 | - OS: [e.g. iOS8.1]
40 |
41 | **Additional context**
42 | Add any other context about the problem here.
43 |
--------------------------------------------------------------------------------
/azure-pipelines.yml:
--------------------------------------------------------------------------------
1 | # Xamarin.iOS
2 | # Build a Xamarin.iOS project.
3 | # Add steps that install certificates, test, sign, and distribute an app, save build artifacts, and more:
4 | # https://docs.microsoft.com/azure/devops/pipelines/languages/xamarin
5 |
6 | trigger:
7 | - master
8 |
9 | pool:
10 | vmImage: 'macOS-10.13'
11 |
12 | steps:
13 | # To manually select a Xamarin SDK version on the Microsoft-hosted macOS agent,
14 | # configure this task with the *Mono* version that is associated with the
15 | # Xamarin SDK version that you need, and set the "enabled" property to true.
16 | # See https://go.microsoft.com/fwlink/?linkid=871629
17 | - script: sudo $AGENT_HOMEDIRECTORY/scripts/select-xamarin-sdk.sh 5_12_0
18 | displayName: 'Select the Xamarin SDK version'
19 | enabled: false
20 |
21 | - task: NuGetToolInstaller@0
22 |
23 | - task: NuGetCommand@2
24 | inputs:
25 | restoreSolution: '**/*.sln'
26 |
27 | - task: XamariniOS@2
28 | inputs:
29 | solutionFile: '**/*.sln'
30 | configuration: 'Release'
31 | buildForSimulator: true
32 | packageApp: false
33 |
--------------------------------------------------------------------------------
/TenDaysOfXamarin/ViewModels/Helpers/PermissionsHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using Plugin.Permissions;
4 | using Plugin.Permissions.Abstractions;
5 |
6 | namespace TenDaysOfXamarin.ViewModels.Helpers
7 | {
8 | public class PermissionsHelper
9 | {
10 | // added using Plugin.Permissions.Abstractions;
11 | // added using System.Threading.Tasks;
12 | public static async Task GetPermission(Permission permissionType)
13 | {
14 | // added using Plugin.Permissions;
15 | var status = await CrossPermissions.Current.CheckPermissionStatusAsync(permissionType);
16 | if (status != PermissionStatus.Granted)
17 | {
18 | // This is the actual permission request
19 | var results = await CrossPermissions.Current.RequestPermissionsAsync(permissionType);
20 | if (results.ContainsKey(permissionType))
21 | status = results[permissionType];
22 | }
23 |
24 | return status;
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/TenDaysOfXamarin/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using TenDaysOfXamarin.Views;
3 | using Xamarin.Forms;
4 | using Xamarin.Forms.Xaml;
5 |
6 | [assembly: XamlCompilation(XamlCompilationOptions.Compile)]
7 | namespace TenDaysOfXamarin
8 | {
9 | public partial class App : Application
10 | {
11 | public static string DatabasePath;
12 |
13 | public App(string databasePath)
14 | {
15 | InitializeComponent();
16 |
17 | DatabasePath = databasePath;
18 |
19 | MainPage = new NavigationPage(new ExperiencesPage()); // added using TenDaysOfXamarin.Views;
20 | }
21 |
22 | public App()
23 | {
24 | InitializeComponent();
25 |
26 | MainPage = new NavigationPage(new ExperiencesPage());
27 | }
28 |
29 | protected override void OnStart()
30 | {
31 | // Handle when your app starts
32 | }
33 |
34 | protected override void OnSleep()
35 | {
36 | // Handle when your app sleeps
37 | }
38 |
39 | protected override void OnResume()
40 | {
41 | // Handle when your app resumes
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/TenDaysOfXamarin/Views/ExperiencesPage.xaml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/TenDaysOfXamarin/ViewModels/Helpers/LocationHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using Plugin.Geolocator;
4 | using Plugin.Geolocator.Abstractions;
5 |
6 | namespace TenDaysOfXamarin.ViewModels.Helpers
7 | {
8 | public class LocationHelper
9 | {
10 | // added using Plugin.Geolocator;
11 | // added using Plugin.Geolocator.Abstractions;
12 | public IGeolocator locator = CrossGeolocator.Current;
13 | public Position position;
14 |
15 | public LocationHelper()
16 | {
17 | locator.PositionChanged += Locator_PositionChanged;
18 | }
19 |
20 | void Locator_PositionChanged(object sender, PositionEventArgs e)
21 | {
22 | position = e.Position;
23 | }
24 |
25 | // added using System.Threading.Tasks;
26 | public async Task GetLocation(TimeSpan minimumTime, int minimumMeters)
27 | {
28 | position = await locator.GetPositionAsync();
29 | await locator.StartListeningAsync(minimumTime, minimumMeters);
30 | return position;
31 | }
32 |
33 | public async void StopListening()
34 | {
35 | await locator.StopListeningAsync();
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/TenDaysOfXamarin/Views/MainPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Plugin.Geolocator;
7 | using Plugin.Geolocator.Abstractions;
8 | using Plugin.Permissions;
9 | using Plugin.Permissions.Abstractions;
10 | using SQLite;
11 | using TenDaysOfXamarin.Model;
12 | using Xamarin.Forms;
13 | using System.Net.Http;
14 | using Newtonsoft.Json;
15 | using TenDaysOfXamarin.ViewModels;
16 | using TenDaysOfXamarin.ViewModels.Helpers;
17 |
18 | namespace TenDaysOfXamarin
19 | {
20 | public partial class MainPage : ContentPage
21 | {
22 | // added using TenDaysOfXamarin.ViewModels;
23 | MainVM viewModel;
24 |
25 | public MainPage()
26 | {
27 | InitializeComponent();
28 |
29 | viewModel = new MainVM();
30 | BindingContext = viewModel;
31 | }
32 |
33 | protected override void OnAppearing()
34 | {
35 | base.OnAppearing();
36 |
37 | viewModel.GetLocationPermission();
38 | }
39 |
40 | protected override void OnDisappearing()
41 | {
42 | base.OnDisappearing();
43 | viewModel.StopListeningLocationUpdates();
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/TenDaysOfXamarin/TenDaysOfXamarin.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 |
6 |
7 |
8 | pdbonly
9 | true
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | MainPage.xaml
30 | Code
31 |
32 |
33 |
--------------------------------------------------------------------------------
/TenDaysOfXamarin.Android/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 | using Android.App;
5 |
6 | // General Information about an assembly is controlled through the following
7 | // set of attributes. Change these attribute values to modify the information
8 | // associated with an assembly.
9 | [assembly: AssemblyTitle("TenDaysOfXamarin.Android")]
10 | [assembly: AssemblyDescription("")]
11 | [assembly: AssemblyConfiguration("")]
12 | [assembly: AssemblyCompany("")]
13 | [assembly: AssemblyProduct("TenDaysOfXamarin.Android")]
14 | [assembly: AssemblyCopyright("Copyright © 2014")]
15 | [assembly: AssemblyTrademark("")]
16 | [assembly: AssemblyCulture("")]
17 | [assembly: ComVisible(false)]
18 |
19 | // Version information for an assembly consists of the following four values:
20 | //
21 | // Major Version
22 | // Minor Version
23 | // Build Number
24 | // Revision
25 | //
26 | // You can specify all the values or you can default the Build and Revision Numbers
27 | // by using the '*' as shown below:
28 | // [assembly: AssemblyVersion("1.0.*")]
29 | [assembly: AssemblyVersion("1.0.0.0")]
30 | [assembly: AssemblyFileVersion("1.0.0.0")]
31 |
32 | // Add some common permissions, these can be removed if not needed
33 | [assembly: UsesPermission(Android.Manifest.Permission.Internet)]
34 | [assembly: UsesPermission(Android.Manifest.Permission.WriteExternalStorage)]
35 |
--------------------------------------------------------------------------------
/TenDaysOfXamarin.iOS/AppDelegate.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 |
6 | using Foundation;
7 | using UIKit;
8 |
9 | namespace TenDaysOfXamarin.iOS
10 | {
11 | // The UIApplicationDelegate for the application. This class is responsible for launching the
12 | // User Interface of the application, as well as listening (and optionally responding) to
13 | // application events from iOS.
14 | [Register("AppDelegate")]
15 | public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
16 | {
17 | //
18 | // This method is invoked when the application has loaded and is ready to run. In this
19 | // method you should instantiate the window, load the UI into it and then make the window
20 | // visible.
21 | //
22 | // You have 17 seconds to return from this method, or iOS will terminate your application.
23 | //
24 | public override bool FinishedLaunching(UIApplication app, NSDictionary options)
25 | {
26 | global::Xamarin.Forms.Forms.Init();
27 |
28 | string fileName = "database.db3";
29 | string folderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "..", "Library");
30 | string fullPath = Path.Combine(folderPath, fileName); //Added using System.IO;
31 |
32 | LoadApplication(new App(fullPath));
33 |
34 | return base.FinishedLaunching(app, options);
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/TenDaysOfXamarin.iOS/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("TenDaysOfXamarin.iOS")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("TenDaysOfXamarin.iOS")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("72bdc44f-c588-44f3-b6df-9aace7daafdd")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/TenDaysOfXamarin.Android/Resources/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
24 |
27 |
--------------------------------------------------------------------------------
/TenDaysOfXamarin/ViewModels/ExperiencesVM.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.ObjectModel;
3 | using System.ComponentModel;
4 | using TenDaysOfXamarin.Model;
5 | using TenDaysOfXamarin.ViewModels.Commands;
6 |
7 | namespace TenDaysOfXamarin.ViewModels
8 | {
9 | public class ExperiencesVM : INotifyPropertyChanged
10 | {
11 | // added using TenDaysOfXamarin.ViewModels.Commands;
12 | public NewExperienceCommand NewExperienceCommand { get; set; }
13 |
14 | public ObservableCollection Experiences { get; set; }
15 |
16 | public ExperiencesVM()
17 | {
18 | NewExperienceCommand = new NewExperienceCommand(this);
19 | Experiences = new ObservableCollection();
20 | ReadExperiences();
21 | }
22 |
23 | public event PropertyChangedEventHandler PropertyChanged;
24 |
25 | public void NewExperience()
26 | {
27 | App.Current.MainPage.Navigation.PushAsync(new MainPage());
28 | }
29 |
30 | public void ReadExperiences()
31 | {
32 | // added using TenDaysOfXamarin.Model;
33 | var experiences = Experience.GetExperiences();
34 |
35 | Experiences.Clear();
36 | foreach(var experience in experiences)
37 | {
38 | Experiences.Add(experience);
39 | }
40 | }
41 |
42 | private void OnPropertyChanged(string propertyName)
43 | {
44 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/TenDaysOfXamarin/Model/Experience.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using SQLite;
4 |
5 | namespace TenDaysOfXamarin.Model
6 | {
7 | public class Experience
8 | {
9 | [PrimaryKey, AutoIncrement] // added using SQLite;
10 | public int Id { get; set; }
11 |
12 | [MaxLength(50)]
13 | public string Title { get; set; }
14 |
15 | public string Content { get; set; }
16 |
17 | public DateTime CreatedAt { get; set; }
18 |
19 | public DateTime UpdatedAt { get; set; }
20 |
21 | public string VenueName { get; set; }
22 |
23 | public string VenueCategory { get; set; }
24 |
25 | public float VenueLat { get; set; }
26 |
27 | public float VenueLng { get; set; }
28 |
29 | public bool InsertExperience()
30 | {
31 | int insertedItems = 0;
32 | using (SQLiteConnection conn = new SQLiteConnection(App.DatabasePath))
33 | {
34 | conn.CreateTable();
35 | insertedItems = conn.Insert(this);
36 | }
37 |
38 | return insertedItems > 0;
39 | }
40 |
41 | public static List GetExperiences()
42 | {
43 | // added using System.Collections.Generic;
44 | using (SQLiteConnection conn = new SQLiteConnection(App.DatabasePath))
45 | {
46 | conn.CreateTable();
47 | return conn.Table().ToList();
48 | }
49 | }
50 |
51 | public override string ToString()
52 | {
53 | return Title;
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/TenDaysOfXamarin.Android/MainActivity.cs:
--------------------------------------------------------------------------------
1 | using Android.App;
2 | using Android.Content.PM;
3 | using Android.Runtime;
4 | using Android.Views;
5 | using Android.Widget;
6 | using Android.OS;
7 | using System.IO;
8 | using Plugin.Permissions;
9 |
10 | namespace TenDaysOfXamarin.Droid
11 | {
12 | [Activity(Label = "TenDaysOfXamarin", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
13 | public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
14 | {
15 | protected override void OnCreate(Bundle savedInstanceState)
16 | {
17 | TabLayoutResource = Resource.Layout.Tabbar;
18 | ToolbarResource = Resource.Layout.Toolbar;
19 |
20 | base.OnCreate(savedInstanceState);
21 | global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
22 | Plugin.CurrentActivity.CrossCurrentActivity.Current.Init(this, savedInstanceState);
23 |
24 | string fileName = "database.db3";
25 | string folderPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments);
26 | string fullPath = Path.Combine(folderPath, fileName); //Added using System.IO;
27 |
28 | LoadApplication(new App(fullPath));
29 | }
30 |
31 | public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Permission[] grantResults)
32 | {
33 | // added using Plugin.Permissions;
34 | PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
35 | base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/TenDaysOfXamarin.iOS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | UIDeviceFamily
6 |
7 | 1
8 | 2
9 |
10 | UISupportedInterfaceOrientations
11 |
12 | UIInterfaceOrientationPortrait
13 | UIInterfaceOrientationLandscapeLeft
14 | UIInterfaceOrientationLandscapeRight
15 |
16 | UISupportedInterfaceOrientations~ipad
17 |
18 | UIInterfaceOrientationPortrait
19 | UIInterfaceOrientationPortraitUpsideDown
20 | UIInterfaceOrientationLandscapeLeft
21 | UIInterfaceOrientationLandscapeRight
22 |
23 | MinimumOSVersion
24 | 8.0
25 | CFBundleDisplayName
26 | TenDaysOfXamarin
27 | CFBundleIdentifier
28 | com.lalorosas.TenDaysOfXamarin
29 | CFBundleVersion
30 | 1.0
31 | UILaunchStoryboardName
32 | LaunchScreen
33 | CFBundleName
34 | TenDaysOfXamarin
35 | XSAppIconAssets
36 | Assets.xcassets/AppIcon.appiconset
37 | NSLocationWhenInUseUsageDescription
38 | We will use your device's location to get nearby venues for the experiences to be pinned to the place where you had them.
39 | NSBluetoothPeripheralUsageDescription
40 | We may use Bluetooth Peripherals to understand what devices you use while saving an experience
41 | NSCalendarsUsageDescription
42 | We may use your calendar to create experiences based on current events
43 |
44 |
45 |
--------------------------------------------------------------------------------
/TenDaysOfXamarin.Android/Resources/AboutResources.txt:
--------------------------------------------------------------------------------
1 | Images, layout descriptions, binary blobs and string dictionaries can be included
2 | in your application as resource files. Various Android APIs are designed to
3 | operate on the resource IDs instead of dealing with images, strings or binary blobs
4 | directly.
5 |
6 | For example, a sample Android app that contains a user interface layout (main.xml),
7 | an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
8 | would keep its resources in the "Resources" directory of the application:
9 |
10 | Resources/
11 | drawable-hdpi/
12 | icon.png
13 |
14 | drawable-ldpi/
15 | icon.png
16 |
17 | drawable-mdpi/
18 | icon.png
19 |
20 | layout/
21 | main.xml
22 |
23 | values/
24 | strings.xml
25 |
26 | In order to get the build system to recognize Android resources, set the build action to
27 | "AndroidResource". The native Android APIs do not operate directly with filenames, but
28 | instead operate on resource IDs. When you compile an Android application that uses resources,
29 | the build system will package the resources for distribution and generate a class called
30 | "Resource" that contains the tokens for each one of the resources included. For example,
31 | for the above Resources layout, this is what the Resource class would expose:
32 |
33 | public class Resource {
34 | public class drawable {
35 | public const int icon = 0x123;
36 | }
37 |
38 | public class layout {
39 | public const int main = 0x456;
40 | }
41 |
42 | public class strings {
43 | public const int first_string = 0xabc;
44 | public const int second_string = 0xbcd;
45 | }
46 | }
47 |
48 | You would then use R.drawable.icon to reference the drawable/icon.png file, or Resource.layout.main
49 | to reference the layout/main.xml file, or Resource.strings.first_string to reference the first
50 | string in the dictionary file values/strings.xml.
51 |
--------------------------------------------------------------------------------
/TenDaysOfXamarin/Views/MainPage.xaml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
11 |
12 |
15 |
21 |
22 |
23 |
25 |
26 |
27 |
28 |
29 |
31 |
33 |
35 |
36 |
37 |
41 |
45 |
48 |
49 |
--------------------------------------------------------------------------------
/TenDaysOfXamarin/App.xaml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | #326273
7 | #EEEEEE
8 | #1C1C1C
9 | #4392F1
10 | #EF798A
11 | #BFBFBF
12 |
13 |
17 |
20 |
23 |
27 |
31 |
35 |
39 |
43 |
44 |
--------------------------------------------------------------------------------
/TenDaysOfXamarin.iOS/Resources/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/TenDaysOfXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images": [
3 | {
4 | "scale": "2x",
5 | "size": "20x20",
6 | "idiom": "iphone",
7 | "filename": "Icon40.png"
8 | },
9 | {
10 | "scale": "3x",
11 | "size": "20x20",
12 | "idiom": "iphone",
13 | "filename": "Icon60.png"
14 | },
15 | {
16 | "scale": "2x",
17 | "size": "29x29",
18 | "idiom": "iphone",
19 | "filename": "Icon58.png"
20 | },
21 | {
22 | "scale": "3x",
23 | "size": "29x29",
24 | "idiom": "iphone",
25 | "filename": "Icon87.png"
26 | },
27 | {
28 | "scale": "2x",
29 | "size": "40x40",
30 | "idiom": "iphone",
31 | "filename": "Icon80.png"
32 | },
33 | {
34 | "scale": "3x",
35 | "size": "40x40",
36 | "idiom": "iphone",
37 | "filename": "Icon120.png"
38 | },
39 | {
40 | "scale": "2x",
41 | "size": "60x60",
42 | "idiom": "iphone",
43 | "filename": "Icon120.png"
44 | },
45 | {
46 | "scale": "3x",
47 | "size": "60x60",
48 | "idiom": "iphone",
49 | "filename": "Icon180.png"
50 | },
51 | {
52 | "scale": "1x",
53 | "size": "20x20",
54 | "idiom": "ipad",
55 | "filename": "Icon20.png"
56 | },
57 | {
58 | "scale": "2x",
59 | "size": "20x20",
60 | "idiom": "ipad",
61 | "filename": "Icon40.png"
62 | },
63 | {
64 | "scale": "1x",
65 | "size": "29x29",
66 | "idiom": "ipad",
67 | "filename": "Icon29.png"
68 | },
69 | {
70 | "scale": "2x",
71 | "size": "29x29",
72 | "idiom": "ipad",
73 | "filename": "Icon58.png"
74 | },
75 | {
76 | "scale": "1x",
77 | "size": "40x40",
78 | "idiom": "ipad",
79 | "filename": "Icon40.png"
80 | },
81 | {
82 | "scale": "2x",
83 | "size": "40x40",
84 | "idiom": "ipad",
85 | "filename": "Icon80.png"
86 | },
87 | {
88 | "scale": "1x",
89 | "size": "76x76",
90 | "idiom": "ipad",
91 | "filename": "Icon76.png"
92 | },
93 | {
94 | "scale": "2x",
95 | "size": "76x76",
96 | "idiom": "ipad",
97 | "filename": "Icon152.png"
98 | },
99 | {
100 | "scale": "2x",
101 | "size": "83.5x83.5",
102 | "idiom": "ipad",
103 | "filename": "Icon167.png"
104 | },
105 | {
106 | "scale": "1x",
107 | "size": "1024x1024",
108 | "idiom": "ios-marketing",
109 | "filename": "Icon1024.png"
110 | }
111 | ],
112 | "properties": {},
113 | "info": {
114 | "version": 1,
115 | "author": "xcode"
116 | }
117 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | # 10 Days.
4 | # 10 Challenges.
5 |
6 | 
7 |
8 | ## Learn Xamarin and create Android and iOS apps that share C# code
9 | With Xamarin you can use C# to create Android and iOS apps. Plus, that C# codebase will be 100% shared between projects, and compile to native code, so performance is not impacted.
10 |
11 | | Share C# Code | Create the UI with XAML |
12 | | ------------- |:-------------:|
13 | |  |  |
14 | | Code your whole logic once, share it between the Android and iOS native projects. | Xamarin translates your XAML code into native UI elements, so your apps feel native -because they are. |
15 |
16 | ## Time to start learning
17 |
18 | | SQLite | REST | MVVM |
19 | | ------------- |:-------------:| -----:|
20 | |  |  |  |
21 | | Learn to define the user interface using XAML, handle user interactions using C#, use a local database to store and retrieve data, and list all the information. | Get the device's location and use it to get a list of nearby venues using the Foursquare REST API and HTTP requests. Then update the SQLite table with that info. | Clean your code by implementing the MVVM architectural pattern and feel like an expert using Binding, Commands and Observable Collections. |
22 |
23 | ## Day by Day
24 |
25 | 
26 |
27 | Curious about what you will learn? Here is the list of topics that we cover day by day:
28 | 1. **XAML and Events.** Defining the interface and handling user interactions.
29 | 2. **Using XAML Styles.** Reusing XAML code with Style Resources.
30 | 3. **Creating an SQLite Database.** Prepare the projects to use SQLite and get the file's path.
31 | 4. **Inserting to the Database.** Model the database table, create a connection and start adding elements to the table.
32 | 5. **Reading and Listing a Table.** Read the database table and list the retrieved elements in a ListView.
33 | 6. **Getting the User's Location.** Get the user's permission to access location, then get the coordinates.
34 | 7. **Making REST Requests.** Make HTTP requests to Foursquare's REST API to get nearby venues.
35 | 8. **The INotifyPropertyChanged interface.** Implement the interface to notify the view of property changes.
36 | 9. **Defining and Binding Commands.** Substitute event handlers with Commands.
37 | 10. **Using Observable Collections.** Notify the view of collection changes with the ObservableCollection class.
38 |
39 | Want the daily challenges delivered to your inbox? [Register to the Email List](https://join.10daysofxamarin.blog/landing)
40 |
--------------------------------------------------------------------------------
/TenDaysOfXamarin/Model/Search.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Collections.Generic;
4 | using System.Net.Http;
5 | using Newtonsoft.Json;
6 | using System.Threading.Tasks;
7 |
8 | namespace TenDaysOfXamarin.Model
9 | {
10 | public class Meta
11 | {
12 | public int code { get; set; }
13 | public string requestId { get; set; }
14 | }
15 |
16 | public class LabeledLatLng
17 | {
18 | public string label { get; set; }
19 | public double lat { get; set; }
20 | public double lng { get; set; }
21 | }
22 |
23 | public class Location
24 | {
25 | public double lat { get; set; }
26 | public double lng { get; set; }
27 | public IList labeledLatLngs { get; set; }
28 | public int distance { get; set; }
29 | public string cc { get; set; }
30 | public string country { get; set; }
31 | public IList formattedAddress { get; set; }
32 |
33 | private string coordinates;
34 | public string Coordinates
35 | {
36 | get { return $"{lat:0.000}, {lng:0.000}"; }
37 | }
38 | }
39 |
40 | public class Icon
41 | {
42 | public string prefix { get; set; }
43 | public string suffix { get; set; }
44 | }
45 |
46 | public class Category
47 | {
48 | public string id { get; set; }
49 | public string name { get; set; }
50 | public string pluralName { get; set; }
51 | public string shortName { get; set; }
52 | public Icon icon { get; set; }
53 | public bool primary { get; set; }
54 | }
55 |
56 | public class Venue
57 | {
58 | public string id { get; set; }
59 | public string name { get; set; }
60 | public Location location { get; set; }
61 | public IList categories { get; set; }
62 | public string referralId { get; set; }
63 | public bool hasPerk { get; set; }
64 |
65 | private string mainCategory;
66 | public string MainCategory
67 | {
68 | // added using System.Linq;
69 | get { return categories.FirstOrDefault()?.name; }
70 | }
71 | }
72 |
73 | public class Response
74 | {
75 | public IList venues { get; set; }
76 | public bool confident { get; set; }
77 | }
78 |
79 | public class Search
80 | {
81 | public Meta meta { get; set; }
82 | public Response response { get; set; }
83 |
84 | public static async Task SearchRequest(double lat, double lng, int radius, string query, int limit = 3)
85 | {
86 | string url = $"https://api.foursquare.com/v2/venues/search?ll={lat},{lng}&radius={radius}&query={query}&limit={limit}&client_id={Helpers.Constants.FOURSQR_CLIENT_ID}&client_secret={Helpers.Constants.FOURSQR_CLIENT_SECRET}&v={DateTime.Now.ToString("yyyyMMdd")}";
87 |
88 | // added using System.Net.Http;
89 | using (HttpClient client = new HttpClient())
90 | {
91 | // made the method async
92 | string json = await client.GetStringAsync(url);
93 |
94 | // added using Newtonsoft.Json;
95 | return JsonConvert.DeserializeObject(json).response;
96 | }
97 | }
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/TenDaysOfXamarin.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TenDaysOfXamarin.Android", "TenDaysOfXamarin.Android\TenDaysOfXamarin.Android.csproj", "{79B2137E-6B01-4037-A432-26C1A830E7EF}"
5 | EndProject
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TenDaysOfXamarin.iOS", "TenDaysOfXamarin.iOS\TenDaysOfXamarin.iOS.csproj", "{74883EA8-38F4-42EE-900A-5B9DE431F60F}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TenDaysOfXamarin", "TenDaysOfXamarin\TenDaysOfXamarin.csproj", "{FD092F1C-FFD7-40A5-BF65-31CBDB19D512}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | Debug|iPhoneSimulator = Debug|iPhoneSimulator
15 | Release|iPhoneSimulator = Release|iPhoneSimulator
16 | Debug|iPhone = Debug|iPhone
17 | Release|iPhone = Release|iPhone
18 | Ad-Hoc|iPhone = Ad-Hoc|iPhone
19 | AppStore|iPhone = AppStore|iPhone
20 | EndGlobalSection
21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
22 | {79B2137E-6B01-4037-A432-26C1A830E7EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23 | {79B2137E-6B01-4037-A432-26C1A830E7EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
24 | {79B2137E-6B01-4037-A432-26C1A830E7EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
25 | {79B2137E-6B01-4037-A432-26C1A830E7EF}.Release|Any CPU.Build.0 = Release|Any CPU
26 | {79B2137E-6B01-4037-A432-26C1A830E7EF}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
27 | {79B2137E-6B01-4037-A432-26C1A830E7EF}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
28 | {79B2137E-6B01-4037-A432-26C1A830E7EF}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
29 | {79B2137E-6B01-4037-A432-26C1A830E7EF}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
30 | {79B2137E-6B01-4037-A432-26C1A830E7EF}.Debug|iPhone.ActiveCfg = Debug|Any CPU
31 | {79B2137E-6B01-4037-A432-26C1A830E7EF}.Debug|iPhone.Build.0 = Debug|Any CPU
32 | {79B2137E-6B01-4037-A432-26C1A830E7EF}.Release|iPhone.ActiveCfg = Release|Any CPU
33 | {79B2137E-6B01-4037-A432-26C1A830E7EF}.Release|iPhone.Build.0 = Release|Any CPU
34 | {79B2137E-6B01-4037-A432-26C1A830E7EF}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
35 | {79B2137E-6B01-4037-A432-26C1A830E7EF}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
36 | {79B2137E-6B01-4037-A432-26C1A830E7EF}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
37 | {79B2137E-6B01-4037-A432-26C1A830E7EF}.AppStore|iPhone.Build.0 = Debug|Any CPU
38 | {74883EA8-38F4-42EE-900A-5B9DE431F60F}.Debug|Any CPU.ActiveCfg = Debug|iPhoneSimulator
39 | {74883EA8-38F4-42EE-900A-5B9DE431F60F}.Debug|Any CPU.Build.0 = Debug|iPhoneSimulator
40 | {74883EA8-38F4-42EE-900A-5B9DE431F60F}.Release|Any CPU.ActiveCfg = Release|iPhoneSimulator
41 | {74883EA8-38F4-42EE-900A-5B9DE431F60F}.Release|Any CPU.Build.0 = Release|iPhoneSimulator
42 | {74883EA8-38F4-42EE-900A-5B9DE431F60F}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
43 | {74883EA8-38F4-42EE-900A-5B9DE431F60F}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
44 | {74883EA8-38F4-42EE-900A-5B9DE431F60F}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
45 | {74883EA8-38F4-42EE-900A-5B9DE431F60F}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
46 | {74883EA8-38F4-42EE-900A-5B9DE431F60F}.Debug|iPhone.ActiveCfg = Debug|iPhone
47 | {74883EA8-38F4-42EE-900A-5B9DE431F60F}.Debug|iPhone.Build.0 = Debug|iPhone
48 | {74883EA8-38F4-42EE-900A-5B9DE431F60F}.Release|iPhone.ActiveCfg = Release|iPhone
49 | {74883EA8-38F4-42EE-900A-5B9DE431F60F}.Release|iPhone.Build.0 = Release|iPhone
50 | {74883EA8-38F4-42EE-900A-5B9DE431F60F}.Ad-Hoc|iPhone.ActiveCfg = Ad-Hoc|iPhone
51 | {74883EA8-38F4-42EE-900A-5B9DE431F60F}.Ad-Hoc|iPhone.Build.0 = Ad-Hoc|iPhone
52 | {74883EA8-38F4-42EE-900A-5B9DE431F60F}.AppStore|iPhone.ActiveCfg = AppStore|iPhone
53 | {74883EA8-38F4-42EE-900A-5B9DE431F60F}.AppStore|iPhone.Build.0 = AppStore|iPhone
54 | {FD092F1C-FFD7-40A5-BF65-31CBDB19D512}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
55 | {FD092F1C-FFD7-40A5-BF65-31CBDB19D512}.Debug|Any CPU.Build.0 = Debug|Any CPU
56 | {FD092F1C-FFD7-40A5-BF65-31CBDB19D512}.Release|Any CPU.ActiveCfg = Release|Any CPU
57 | {FD092F1C-FFD7-40A5-BF65-31CBDB19D512}.Release|Any CPU.Build.0 = Release|Any CPU
58 | {FD092F1C-FFD7-40A5-BF65-31CBDB19D512}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
59 | {FD092F1C-FFD7-40A5-BF65-31CBDB19D512}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
60 | {FD092F1C-FFD7-40A5-BF65-31CBDB19D512}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
61 | {FD092F1C-FFD7-40A5-BF65-31CBDB19D512}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
62 | {FD092F1C-FFD7-40A5-BF65-31CBDB19D512}.Debug|iPhone.ActiveCfg = Debug|Any CPU
63 | {FD092F1C-FFD7-40A5-BF65-31CBDB19D512}.Debug|iPhone.Build.0 = Debug|Any CPU
64 | {FD092F1C-FFD7-40A5-BF65-31CBDB19D512}.Release|iPhone.ActiveCfg = Release|Any CPU
65 | {FD092F1C-FFD7-40A5-BF65-31CBDB19D512}.Release|iPhone.Build.0 = Release|Any CPU
66 | {FD092F1C-FFD7-40A5-BF65-31CBDB19D512}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
67 | {FD092F1C-FFD7-40A5-BF65-31CBDB19D512}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
68 | {FD092F1C-FFD7-40A5-BF65-31CBDB19D512}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
69 | {FD092F1C-FFD7-40A5-BF65-31CBDB19D512}.AppStore|iPhone.Build.0 = Debug|Any CPU
70 | EndGlobalSection
71 | EndGlobal
72 |
--------------------------------------------------------------------------------
/TenDaysOfXamarin.Android/TenDaysOfXamarin.Android.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | {79B2137E-6B01-4037-A432-26C1A830E7EF}
7 | {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
8 | {c9e5eea5-ca05-42a1-839b-61506e0a37df}
9 | Library
10 | TenDaysOfXamarin.Droid
11 | TenDaysOfXamarin.Android
12 | True
13 | Resources\Resource.designer.cs
14 | Resource
15 | Properties\AndroidManifest.xml
16 | Resources
17 | Assets
18 | v8.1
19 | Xamarin.Android.Net.AndroidClientHandler
20 |
21 |
22 |
23 |
24 | true
25 | portable
26 | false
27 | bin\Debug
28 | DEBUG;
29 | prompt
30 | 4
31 | None
32 |
33 |
34 | true
35 | pdbonly
36 | true
37 | bin\Release
38 | prompt
39 | 4
40 | true
41 | false
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | 1.5.231
59 |
60 |
61 | 3.0.0.12
62 |
63 |
64 | 2.1.0.4
65 |
66 |
67 | 4.5.0.6
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 | {FD092F1C-FFD7-40A5-BF65-31CBDB19D512}
108 | TenDaysOfXamarin
109 |
110 |
111 |
112 |
113 |
--------------------------------------------------------------------------------
/TenDaysOfXamarin/ViewModels/MainVM.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.ObjectModel;
3 | using System.ComponentModel;
4 | using System.Windows.Input;
5 | using Plugin.Permissions.Abstractions;
6 | using SQLite;
7 | using TenDaysOfXamarin.Model;
8 | using TenDaysOfXamarin.ViewModels.Helpers;
9 | using Xamarin.Forms;
10 |
11 | namespace TenDaysOfXamarin.ViewModels
12 | {
13 | public class MainVM : INotifyPropertyChanged // added using System.ComponentModel;
14 | {
15 | private string title;
16 | public string Title
17 | {
18 | get { return title; }
19 | set
20 | {
21 | title = value;
22 | OnPropertyChanged("Title");
23 | OnPropertyChanged("CanSave");
24 | }
25 | }
26 |
27 | private string query;
28 | public string Query
29 | {
30 | get { return query; }
31 | set
32 | {
33 | query = value;
34 | if (!string.IsNullOrWhiteSpace(query))
35 | {
36 | GetVenues();
37 | ShowVenues = true;
38 | }
39 | else
40 | {
41 | ShowVenues = false;
42 | }
43 | OnPropertyChanged("Query");
44 | }
45 | }
46 |
47 | private Venue selectedVenue; // added using TenDaysOfXamarin.Model;
48 | public Venue SelectedVenue
49 | {
50 | get { return selectedVenue; }
51 | set
52 | {
53 | selectedVenue = value;
54 | if (selectedVenue != null)
55 | {
56 | ShowVenues = false;
57 | Query = string.Empty;
58 | }
59 |
60 | OnPropertyChanged("SelectedVenue");
61 | OnPropertyChanged("ShowSelectedVenue");
62 | }
63 | }
64 |
65 | private string content;
66 | public string Content
67 | {
68 | get { return content; }
69 | set
70 | {
71 | content = value;
72 | OnPropertyChanged("Content");
73 | OnPropertyChanged("CanSave");
74 | }
75 | }
76 |
77 | public bool CanSave
78 | {
79 | get { return !string.IsNullOrWhiteSpace(Title) && !string.IsNullOrWhiteSpace(Content); }
80 | }
81 |
82 | public bool ShowSelectedVenue
83 | {
84 | get { return SelectedVenue != null; }
85 | }
86 |
87 | private bool showVenues;
88 | public bool ShowVenues
89 | {
90 | get { return showVenues; }
91 | set
92 | {
93 | showVenues = value;
94 | OnPropertyChanged("ShowVenues");
95 | }
96 | }
97 |
98 | // added using System.Collections.ObjectModel;
99 | public ObservableCollection Venues { get; set; }
100 |
101 | // added using System.Windows.Input;
102 | public ICommand CancelCommand { get; set; }
103 | public ICommand SaveCommand { get; set; }
104 |
105 | LocationHelper locationHelper;
106 | public MainVM()
107 | {
108 | // added using Xamarin.Forms;
109 | CancelCommand = new Command(CancelAction);
110 | SaveCommand = new Command(SaveAction, CanExecuteSave);
111 |
112 | Venues = new ObservableCollection();
113 |
114 | locationHelper = new LocationHelper();
115 | }
116 |
117 | public async void GetVenues()
118 | {
119 | var response = await Search.SearchRequest(locationHelper.position.Latitude, locationHelper.position.Longitude, 500, Query);
120 |
121 | Venues.Clear();
122 | foreach(var venue in response.venues)
123 | {
124 | Venues.Add(venue);
125 | }
126 | }
127 |
128 | public async void GetLocationPermission()
129 | {
130 | // added using TenDaysOfXamarin.ViewModels.Helpers;
131 | // added using Plugin.Permissions.Abstractions;
132 | var status = await PermissionsHelper.GetPermission(Permission.LocationWhenInUse);
133 |
134 | // Already granted (maybe), go on
135 | if (status == PermissionStatus.Granted)
136 | {
137 | // Granted! Get the location
138 | await locationHelper.GetLocation(TimeSpan.FromMinutes(30), 500);
139 | }
140 | else
141 | {
142 | await App.Current.MainPage.DisplayAlert("Access to location denied", "We don't have access to your location", "Ok");
143 | }
144 | }
145 |
146 | public void StopListeningLocationUpdates()
147 | {
148 | locationHelper.StopListening();
149 | }
150 |
151 | bool CanExecuteSave(bool arg)
152 | {
153 | return arg;
154 | }
155 |
156 | void SaveAction(bool obj)
157 | {
158 | Experience newExperience = new Experience()
159 | {
160 | Title = Title,
161 | Content = Content,
162 | CreatedAt = DateTime.Now,
163 | UpdatedAt = DateTime.Now,
164 | VenueName = SelectedVenue.name,
165 | VenueCategory = SelectedVenue.MainCategory,
166 | VenueLat = float.Parse(SelectedVenue.location.Coordinates.Split(',')[0]),
167 | VenueLng = float.Parse(SelectedVenue.location.Coordinates.Split(',')[1])
168 | };
169 |
170 | bool insertSuccessful = newExperience.InsertExperience();
171 |
172 | // here the conn has been disposed of, hence closed
173 | if (insertSuccessful)
174 | {
175 | Title = string.Empty;
176 | Content = string.Empty;
177 | SelectedVenue = null;
178 | }
179 | else
180 | {
181 | App.Current.MainPage.DisplayAlert("Error", "There was an error inserting the Experience, please try again", "Ok");
182 | }
183 | }
184 |
185 | void CancelAction(object obj)
186 | {
187 | App.Current.MainPage.Navigation.PopAsync();
188 | }
189 |
190 | public event PropertyChangedEventHandler PropertyChanged;
191 |
192 | private void OnPropertyChanged(string propertyName)
193 | {
194 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
195 | }
196 | }
197 | }
198 |
--------------------------------------------------------------------------------
/TenDaysOfXamarin.iOS/TenDaysOfXamarin.iOS.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | iPhoneSimulator
6 | 8.0.30703
7 | 2.0
8 | {74883EA8-38F4-42EE-900A-5B9DE431F60F}
9 | {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
10 | {6143fdea-f3c2-4a09-aafa-6e230626515e}
11 | Exe
12 | TenDaysOfXamarin.iOS
13 | Resources
14 | TenDaysOfXamarin.iOS
15 | NSUrlSessionHandler
16 |
17 |
18 |
19 |
20 | true
21 | full
22 | false
23 | bin\iPhoneSimulator\Debug
24 | DEBUG
25 | prompt
26 | 4
27 | false
28 | x86_64
29 | None
30 | true
31 |
32 |
33 | none
34 | true
35 | bin\iPhoneSimulator\Release
36 | prompt
37 | 4
38 | None
39 | x86_64
40 | false
41 |
42 |
43 | true
44 | full
45 | false
46 | bin\iPhone\Debug
47 | DEBUG
48 | prompt
49 | 4
50 | false
51 | ARM64
52 | iPhone Developer
53 | true
54 | Entitlements.plist
55 |
56 |
57 | none
58 | true
59 | bin\iPhone\Release
60 | prompt
61 | 4
62 | ARM64
63 | false
64 | iPhone Developer
65 | Entitlements.plist
66 |
67 |
68 | none
69 | True
70 | bin\iPhone\Ad-Hoc
71 | prompt
72 | 4
73 | False
74 | ARM64
75 | True
76 | Automatic:AdHoc
77 | iPhone Distribution
78 | Entitlements.plist
79 |
80 |
81 | none
82 | True
83 | bin\iPhone\AppStore
84 | prompt
85 | 4
86 | False
87 | ARM64
88 | Automatic:AppStore
89 | iPhone Distribution
90 | Entitlements.plist
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 | false
103 |
104 |
105 | false
106 |
107 |
108 | false
109 |
110 |
111 | false
112 |
113 |
114 | false
115 |
116 |
117 | false
118 |
119 |
120 | false
121 |
122 |
123 | false
124 |
125 |
126 | false
127 |
128 |
129 | false
130 |
131 |
132 | false
133 |
134 |
135 | false
136 |
137 |
138 | false
139 |
140 |
141 | false
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 | 1.5.231
154 |
155 |
156 | 3.0.0.12
157 |
158 |
159 | 4.5.0.6
160 |
161 |
162 |
163 |
164 |
165 | {FD092F1C-FFD7-40A5-BF65-31CBDB19D512}
166 | TenDaysOfXamarin
167 |
168 |
169 |
--------------------------------------------------------------------------------