-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
96177a0
commit cdeb67f
Showing
14 changed files
with
134 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using Newtonsoft.Json; | ||
|
||
namespace Diplomatic.Models | ||
{ | ||
[Serializable] | ||
public class Signature | ||
{ | ||
[JsonProperty("name")] | ||
public string Name { get; set; } | ||
[JsonProperty("id")] | ||
public string Id { get; set; } | ||
public Uri ImageUri { | ||
get { | ||
string basePath = $"https://qri7p78aml.execute-api.eu-west-2.amazonaws.com/dev/preview/signature/{Id}"; | ||
return new Uri(basePath + "?width=200&height=80"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,20 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
|
||
namespace Diplomatic | ||
namespace Diplomatic.Models | ||
{ | ||
[Serializable] | ||
public class Template | ||
{ | ||
[JsonProperty("name")] | ||
public string TemplateName { get; set; } | ||
[JsonProperty("path")] | ||
public string Path { get; set; } | ||
[JsonProperty("fields")] | ||
public IEnumerable<Field> Fields { get; set; } | ||
public IEnumerable<Field> Fields { get; } | ||
public Signature Signature { get; set; } | ||
public string Name { get; set; } | ||
public bool HasSignature { get; } | ||
|
||
public Template(string name, string path, IEnumerable<Field> fields) | ||
public Template(bool signature, IEnumerable<Field> fields) | ||
{ | ||
TemplateName = name; | ||
Path = path; | ||
Fields = fields; | ||
HasSignature = signature; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Net; | ||
using Newtonsoft.Json; | ||
|
||
namespace Diplomatic.Utils | ||
{ | ||
using Models; | ||
|
||
public class WebSignatureProvider | ||
{ | ||
private readonly IEnumerable<Signature> signatures; | ||
public IEnumerable<Signature> GetTemplates() => signatures.Select(obj => obj); | ||
|
||
public WebSignatureProvider() | ||
{ | ||
var request = WebRequest.Create(new Uri("https://qri7p78aml.execute-api.eu-west-2.amazonaws.com/dev/signatures.json")); | ||
request.ContentType = "application/json"; | ||
request.Method = "GET"; | ||
|
||
using (var response = request.GetResponse() as HttpWebResponse) | ||
using (var reader = new StreamReader(response.GetResponseStream())) | ||
{ | ||
string content = reader.ReadToEnd(); | ||
signatures = JsonConvert.DeserializeObject<List<Signature>>(content); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,20 @@ | ||
using Xamarin.Forms; | ||
using System.Linq; | ||
|
||
namespace Diplomatic.ViewModels | ||
{ | ||
using Models; | ||
using Utils; | ||
|
||
public class SignaturePickerViewModel | ||
{ | ||
// List of signature items to be displayed. | ||
public ImageCell[] SignatureItems { get; set; } | ||
public Signature[] Signatures { get; set; } | ||
public Template SelectedTemplate { get; set; } | ||
|
||
public SignaturePickerViewModel(Template selectedTemplate) | ||
{ | ||
SelectedTemplate = selectedTemplate; | ||
SignatureItems = new ImageCell[] | ||
{ | ||
// Creating a few signatures for testing purposes | ||
new ImageCell() | ||
{ | ||
ImageSource = "donaldtrump.png", | ||
Text = "Donald Trump", | ||
Detail = "President" | ||
|
||
}, | ||
new ImageCell() | ||
{ | ||
ImageSource = "gavinbelson.png", | ||
Text = "Gavin Belson", | ||
Detail = "Visionary behind 'The box 3'" | ||
}, | ||
new ImageCell() | ||
{ | ||
ImageSource = "waltdisney.png", | ||
Text = "Walt Disney", | ||
Detail = "Interesting" | ||
} | ||
}; | ||
Signatures = new WebSignatureProvider().GetTemplates().ToArray(); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Diplomatic.Utils; | ||
|
||
|
||
namespace Diplomatic.ViewModels | ||
{ | ||
using Models; | ||
public class TemplatePickerViewModel | ||
{ | ||
public Template[] TemplateList { get; set; } | ||
public Template[] Templates { get; set; } | ||
public TemplatePickerViewModel() | ||
{ | ||
TemplateList = new WebTemplateProvider().GetTemplates().ToArray(); | ||
Templates = new WebTemplateProvider().GetTemplates().ToArray(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters