diff --git a/Diplomatic.Android/Diplomatic.Droid.csproj b/Diplomatic.Android/Diplomatic.Droid.csproj
index 24b5877..e3cba95 100644
--- a/Diplomatic.Android/Diplomatic.Droid.csproj
+++ b/Diplomatic.Android/Diplomatic.Droid.csproj
@@ -79,12 +79,6 @@
-
-
-
-
-
-
@@ -117,4 +111,4 @@
-
\ No newline at end of file
+
diff --git a/Diplomatic.Android/Resources/drawable/donaldtrump.png b/Diplomatic.Android/Resources/drawable/donaldtrump.png
deleted file mode 100644
index 309c9c1..0000000
Binary files a/Diplomatic.Android/Resources/drawable/donaldtrump.png and /dev/null differ
diff --git a/Diplomatic.Android/Resources/drawable/employee.png b/Diplomatic.Android/Resources/drawable/employee.png
deleted file mode 100644
index f402bd6..0000000
Binary files a/Diplomatic.Android/Resources/drawable/employee.png and /dev/null differ
diff --git a/Diplomatic.Android/Resources/drawable/gavinbelson.png b/Diplomatic.Android/Resources/drawable/gavinbelson.png
deleted file mode 100644
index 4a321f8..0000000
Binary files a/Diplomatic.Android/Resources/drawable/gavinbelson.png and /dev/null differ
diff --git a/Diplomatic.Android/Resources/drawable/good_effort.png b/Diplomatic.Android/Resources/drawable/good_effort.png
deleted file mode 100644
index da0ff19..0000000
Binary files a/Diplomatic.Android/Resources/drawable/good_effort.png and /dev/null differ
diff --git a/Diplomatic.Android/Resources/drawable/harrypotter.png b/Diplomatic.Android/Resources/drawable/harrypotter.png
deleted file mode 100644
index 5aa487a..0000000
Binary files a/Diplomatic.Android/Resources/drawable/harrypotter.png and /dev/null differ
diff --git a/Diplomatic.Android/Resources/drawable/student.png b/Diplomatic.Android/Resources/drawable/student.png
deleted file mode 100644
index 84353ed..0000000
Binary files a/Diplomatic.Android/Resources/drawable/student.png and /dev/null differ
diff --git a/Diplomatic.Android/Resources/drawable/waltdisney.png b/Diplomatic.Android/Resources/drawable/waltdisney.png
deleted file mode 100644
index e698b1d..0000000
Binary files a/Diplomatic.Android/Resources/drawable/waltdisney.png and /dev/null differ
diff --git a/Diplomatic.Core/Classes/Field.cs b/Diplomatic.Core/Classes/Field.cs
deleted file mode 100644
index ee9cce7..0000000
--- a/Diplomatic.Core/Classes/Field.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using Newtonsoft.Json;
-using System;
-
-namespace Diplomatic.Core
-{
- [Serializable]
- public class Field
- {
- [JsonProperty("name")]
- public string Name { get; }
- [JsonIgnore]
- public string Value { get; set; }
-
- public Field(string name)
- {
- Name = name;
- Value = "";
- }
- }
-}
diff --git a/Diplomatic.Core/Classes/Template.cs b/Diplomatic.Core/Classes/Template.cs
deleted file mode 100644
index bf670ca..0000000
--- a/Diplomatic.Core/Classes/Template.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using Newtonsoft.Json;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-
-namespace Diplomatic.Core
-{
- [Serializable]
- public class Template
- {
- [JsonProperty("name")]
- public string TemplateName { get; set; }
- [JsonProperty("path")]
- public string Path { get; set; }
- [JsonProperty("fields")]
- public IEnumerable Fields { get; set; }
-
- public Template(string name, string path, IEnumerable fields)
- {
- TemplateName = name;
- Path = path;
- Fields = fields;
- }
- }
-}
diff --git a/Diplomatic.Core/Diplomatic.Core.csproj b/Diplomatic.Core/Diplomatic.Core.csproj
deleted file mode 100644
index a012065..0000000
--- a/Diplomatic.Core/Diplomatic.Core.csproj
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
- netstandard2.0
-
-
-
- 7.2
-
-
-
- 7.2
-
-
-
-
-
-
-
-
diff --git a/Diplomatic.Tests/Diplomatic.Tests.csproj b/Diplomatic.Tests/Diplomatic.Tests.csproj
index a2824a8..62b4fa9 100644
--- a/Diplomatic.Tests/Diplomatic.Tests.csproj
+++ b/Diplomatic.Tests/Diplomatic.Tests.csproj
@@ -43,167 +43,10 @@
4
-
- ..\packages\Castle.Core.4.3.0\lib\net45\Castle.Core.dll
-
-
- ..\packages\Microsoft.Win32.Primitives.4.3.0\lib\net46\Microsoft.Win32.Primitives.dll
- True
-
-
- ..\packages\Moq.4.8.3\lib\net45\Moq.dll
-
..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll
-
- ..\packages\SixLabors.Core.1.0.0-beta0005\lib\netstandard1.1\SixLabors.Core.dll
-
-
- ..\packages\SixLabors.Fonts.1.0.0-beta0005\lib\netstandard2.0\SixLabors.Fonts.dll
-
-
- ..\packages\SixLabors.ImageSharp.1.0.0-beta0004\lib\netstandard2.0\SixLabors.ImageSharp.dll
-
-
- ..\packages\SixLabors.ImageSharp.Drawing.1.0.0-beta0004\lib\netstandard2.0\SixLabors.ImageSharp.Drawing.dll
-
-
- ..\packages\SixLabors.Shapes.1.0.0-beta0005\lib\netstandard2.0\SixLabors.Shapes.dll
-
-
- ..\packages\SixLabors.Shapes.Text.1.0.0-beta0005\lib\netstandard2.0\SixLabors.Shapes.Text.dll
-
-
- ..\packages\SkiaSharp.1.60.1\lib\net45\SkiaSharp.dll
-
-
-
- ..\packages\System.AppContext.4.3.0\lib\net463\System.AppContext.dll
- True
-
-
- ..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll
-
-
- ..\packages\System.Collections.Immutable.1.4.0\lib\netstandard2.0\System.Collections.Immutable.dll
-
-
-
- ..\packages\System.Console.4.3.0\lib\net46\System.Console.dll
- True
-
-
-
- ..\packages\System.Diagnostics.DiagnosticSource.4.3.0\lib\net46\System.Diagnostics.DiagnosticSource.dll
-
-
- ..\packages\System.Diagnostics.Tracing.4.3.0\lib\net462\System.Diagnostics.Tracing.dll
- True
- True
-
-
- ..\packages\System.Globalization.Calendars.4.3.0\lib\net46\System.Globalization.Calendars.dll
- True
-
-
- ..\packages\System.IO.4.3.0\lib\net462\System.IO.dll
- True
-
-
- ..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll
- True
- True
-
-
-
- ..\packages\System.IO.Compression.ZipFile.4.3.0\lib\net46\System.IO.Compression.ZipFile.dll
- True
-
-
- ..\packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll
- True
-
-
- ..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll
- True
-
-
- ..\packages\System.Linq.4.3.0\lib\net463\System.Linq.dll
- True
-
-
- ..\packages\System.Linq.Expressions.4.3.0\lib\net463\System.Linq.Expressions.dll
- True
-
-
- ..\packages\System.Memory.4.5.0-rc1\lib\netstandard2.0\System.Memory.dll
-
-
- ..\packages\System.Net.Http.4.3.0\lib\net46\System.Net.Http.dll
- True
- True
-
-
- ..\packages\System.Net.Sockets.4.3.0\lib\net46\System.Net.Sockets.dll
- True
- True
-
-
-
- ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll
-
-
- ..\packages\System.Reflection.4.3.0\lib\net462\System.Reflection.dll
- True
-
-
- ..\packages\System.Runtime.4.3.0\lib\net462\System.Runtime.dll
- True
-
-
- ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.0-rc1\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll
-
-
- ..\packages\System.Runtime.Extensions.4.3.0\lib\net462\System.Runtime.Extensions.dll
- True
-
-
- ..\packages\System.Runtime.InteropServices.4.3.0\lib\net463\System.Runtime.InteropServices.dll
- True
-
-
- ..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll
- True
-
-
- ..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net463\System.Security.Cryptography.Algorithms.dll
- True
- True
-
-
- ..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll
- True
-
-
- ..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll
- True
-
-
- ..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll
- True
-
-
- ..\packages\System.Text.RegularExpressions.4.3.0\lib\net463\System.Text.RegularExpressions.dll
- True
-
-
- ..\packages\System.Threading.Tasks.Extensions.4.3.0\lib\portable-net45+win8+wp8+wpa81\System.Threading.Tasks.Extensions.dll
-
-
- ..\packages\System.ValueTuple.4.4.0\lib\net47\System.ValueTuple.dll
-
..\packages\Xamarin.Forms.3.0.0.482510\lib\netstandard2.0\Xamarin.Forms.Core.dll
@@ -213,12 +56,6 @@
..\packages\Xamarin.Forms.3.0.0.482510\lib\netstandard2.0\Xamarin.Forms.Xaml.dll
-
-
-
- ..\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll
- True
-
..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll
@@ -238,9 +75,6 @@
-
-
-
diff --git a/Diplomatic.Tests/FieldTest.cs b/Diplomatic.Tests/FieldTest.cs
index e8ebf33..f098d00 100644
--- a/Diplomatic.Tests/FieldTest.cs
+++ b/Diplomatic.Tests/FieldTest.cs
@@ -1,41 +1,31 @@
-using Diplomatic.Core;
using Newtonsoft.Json;
using Xunit;
namespace Diplomatic.Tests
{
+ using Models;
public class FieldTest
{
- readonly Field subject;
- readonly string serialized;
+ private readonly Field subject;
+ private readonly string serialized;
public FieldTest()
{
- subject = new Field("Test field", 1, 2, 3, 4);
- serialized = @"{
- ""Name"":""Test field"",
- ""XOffset"":1,
- ""YOffset"":2,
- ""Height"":3,
- ""Width"":4
- }";
+ subject = new Field("Test field");
+ serialized = @"{""name"":""Test field""}";
}
[Fact]
public void FieldSerializesToJSON()
{
- var output = JsonConvert.SerializeObject(subject);
- Assert.Contains("Name", output);
- Assert.Contains("XOffset", output);
- Assert.Contains("YOffset", output);
- Assert.Contains("Width", output);
- Assert.Contains("Height", output);
+ string output = JsonConvert.SerializeObject(subject);
+ Assert.Contains("name", output);
}
[Fact]
public void FieldDeserializesFromJSON()
{
- var field = JsonConvert.DeserializeObject(serialized);
+ Field field = JsonConvert.DeserializeObject(serialized);
Assert.Equal("Test field", field.Name);
}
@@ -52,15 +42,5 @@ public void FilledFieldIsValid()
subject.Value = "test";
Assert.True(subject.IsValid);
}
-
- [Fact]
- public void DestructuresWithTupleAssignment()
- {
- (var x, var y, var w, var h) = subject;
- Assert.Equal(1, x);
- Assert.Equal(2, y);
- Assert.Equal(3, w);
- Assert.Equal(4, h);
- }
}
}
diff --git a/Diplomatic.Tests/ResourceLoaderTest.cs b/Diplomatic.Tests/ResourceLoaderTest.cs
index 27b5c2c..05d730a 100644
--- a/Diplomatic.Tests/ResourceLoaderTest.cs
+++ b/Diplomatic.Tests/ResourceLoaderTest.cs
@@ -17,7 +17,7 @@ public class LoadText
public void CanLoadText()
{
// TODO: Fix dependency on actual file existence
- string resource = "templates.json";
+ string resource = "Images.test.png";
var loader = new ResourceLoader();
string result = loader.LoadText(resource);
@@ -52,7 +52,7 @@ public class LoadTextAsync
public async Task CanLoadText()
{
// TODO: Fix dependency on actual file existence
- string resource = "templates.json";
+ string resource = "Images.test.png";
var loader = new ResourceLoader();
string result = await loader.LoadTextAsync(resource);
@@ -118,7 +118,7 @@ public class LoadBinary
public void CanLoadBinary()
{
// TODO: Fix dependency on actual file existence
- string resource = "templates.json";
+ string resource = "Images.test.png";
var loader = new ResourceLoader();
byte[] bytes = loader.LoadBinary(resource).ToArray();
@@ -150,7 +150,7 @@ public class LoadBinaryAsync
public async Task CanLoadBinary()
{
// TODO: Fix dependency on actual file existence
- string resource = "templates.json";
+ string resource = "Images.test.png";
var loader = new ResourceLoader();
byte[] bytes = (await loader.LoadBinaryAsync(resource)).ToArray();
diff --git a/Diplomatic.Tests/TemplateTest.cs b/Diplomatic.Tests/TemplateTest.cs
index 3bbb307..1c1e834 100644
--- a/Diplomatic.Tests/TemplateTest.cs
+++ b/Diplomatic.Tests/TemplateTest.cs
@@ -1,76 +1,54 @@
-using Diplomatic.Core;
-using Moq;
-using Newtonsoft.Json;
-using System.IO;
using System.Linq;
+using Newtonsoft.Json;
using Xunit;
namespace Diplomatic.Tests
{
+ using Models;
public class TemplateTest
{
- readonly IField[] ValidFields;
- readonly ITemplateStream ValidStream;
- Template subject;
+ private readonly Field[] validFields;
+ private readonly Field[] invalidFields;
+ private Template subject;
public TemplateTest()
{
- var mockField = new Mock();
- mockField.Setup(field => field.IsValid).Returns(true);
- ValidFields = new IField[] { mockField.Object };
+ var validField = new Field("Valid");
+ validField.Value = "non-empty";
+ validFields = new Field[] { validField };
- var mockStream = new Mock();
- mockStream.Setup(stream => stream.IsValid).Returns(true);
- ValidStream = mockStream.Object;
+ var invalidField = new Field("Invalid");
+ invalidFields = new Field[] { invalidField };
}
[Fact]
public void ValidatesFieldsAreFilled()
{
- subject = new Template("Template with filled fields", ValidStream, ValidFields);
- Assert.True(subject.IsValid);
- }
-
- [Fact]
- public void NotValidWithoutFields()
- {
- Template subject = new Template("Template with no fields", ValidStream, new Field[] { });
+ subject = new Template(true, invalidFields);
Assert.False(subject.IsValid);
- }
- [Fact]
- public void NotValidWithoutStream()
- {
- var mockStream = new Mock();
- mockStream.Setup(stream => stream.IsValid).Returns(false);
- var badStream = mockStream.Object;
-
- Template subject = new Template("Test template", badStream, ValidFields);
-
- Assert.False(subject.IsValid);
+ subject = new Template(true, validFields);
+ Assert.True(subject.IsValid);
}
[Fact]
public void DeserializesFromJSON()
{
- var serialized = @"{
- ""FilePath"":""testFile.pdf"",
- ""TemplateName"":""Diploma"",
- ""Fields"":[]}";
- var subject = JsonConvert.DeserializeObject(serialized, new TemplateConverter());
- Assert.Equal("Diploma", subject.TemplateName);
- Assert.IsAssignableFrom(subject.RawTemplate);
+ string serialized = @"{""signature"": true, ""fields"":[]}";
+
+ subject = JsonConvert.DeserializeObject(serialized);
+
Assert.Empty(subject.Fields.ToArray());
}
[Fact]
public void SerializesToJSON()
{
- var subject = new Template("Serializes", ValidStream, new Field[] { });
+ var subject = new Template(true, new Field[] { });
- var json = JsonConvert.SerializeObject(subject);
+ string json = JsonConvert.SerializeObject(subject);
- Assert.Equal(@"{""TemplateName"":""Serializes"",""Fields"":[]}", json);
+ Assert.Equal(@"{""fields"":[],""signature"":true}", json);
}
}
}
diff --git a/Diplomatic.Tests/packages.config b/Diplomatic.Tests/packages.config
deleted file mode 100644
index 22e481f..0000000
--- a/Diplomatic.Tests/packages.config
+++ /dev/null
@@ -1,78 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Diplomatic.UWP/App.xaml.cs b/Diplomatic.UWP/App.xaml.cs
index cef24bb..aa5bffb 100644
--- a/Diplomatic.UWP/App.xaml.cs
+++ b/Diplomatic.UWP/App.xaml.cs
@@ -92,7 +92,7 @@ void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
/// Details about the suspend request.
private void OnSuspending(object sender, SuspendingEventArgs e)
{
- var deferral = e.SuspendingOperation.GetDeferral();
+ SuspendingDeferral deferral = e.SuspendingOperation.GetDeferral();
//TODO: Save application state and stop any background activity
deferral.Complete();
}
diff --git a/Diplomatic.iOS/Diplomatic.iOS.csproj b/Diplomatic.iOS/Diplomatic.iOS.csproj
index 869ce34..90e6dfd 100644
--- a/Diplomatic.iOS/Diplomatic.iOS.csproj
+++ b/Diplomatic.iOS/Diplomatic.iOS.csproj
@@ -98,8 +98,6 @@
-
-
@@ -200,15 +198,9 @@
-
-
-
-
-
-
-
\ No newline at end of file
+
diff --git a/Diplomatic.iOS/Resources/donaldtrump.png b/Diplomatic.iOS/Resources/donaldtrump.png
deleted file mode 100644
index 309c9c1..0000000
Binary files a/Diplomatic.iOS/Resources/donaldtrump.png and /dev/null differ
diff --git a/Diplomatic.iOS/Resources/employee.png b/Diplomatic.iOS/Resources/employee.png
deleted file mode 100644
index f402bd6..0000000
Binary files a/Diplomatic.iOS/Resources/employee.png and /dev/null differ
diff --git a/Diplomatic.iOS/Resources/gavinbelson.png b/Diplomatic.iOS/Resources/gavinbelson.png
deleted file mode 100644
index 4a321f8..0000000
Binary files a/Diplomatic.iOS/Resources/gavinbelson.png and /dev/null differ
diff --git a/Diplomatic.iOS/Resources/good_effort.png b/Diplomatic.iOS/Resources/good_effort.png
deleted file mode 100644
index da0ff19..0000000
Binary files a/Diplomatic.iOS/Resources/good_effort.png and /dev/null differ
diff --git a/Diplomatic.iOS/Resources/student.png b/Diplomatic.iOS/Resources/student.png
deleted file mode 100644
index 84353ed..0000000
Binary files a/Diplomatic.iOS/Resources/student.png and /dev/null differ
diff --git a/Diplomatic.iOS/Resources/waltdisney.png b/Diplomatic.iOS/Resources/waltdisney.png
deleted file mode 100644
index e698b1d..0000000
Binary files a/Diplomatic.iOS/Resources/waltdisney.png and /dev/null differ
diff --git a/Diplomatic/App.xaml.cs b/Diplomatic/App.xaml.cs
index 137b20d..f1876ac 100644
--- a/Diplomatic/App.xaml.cs
+++ b/Diplomatic/App.xaml.cs
@@ -1,12 +1,12 @@
-using System;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
-using Diplomatic.Views;
-[assembly: XamlCompilation (XamlCompilationOptions.Compile)]
+[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
namespace Diplomatic
{
- public partial class App : Application
+ using Views;
+
+ public partial class App : Application
{
public App ()
{
diff --git a/Diplomatic/Assets/Images/diplomatic.png b/Diplomatic/Assets/Images/diplomatic.png
deleted file mode 100644
index a284408..0000000
Binary files a/Diplomatic/Assets/Images/diplomatic.png and /dev/null differ
diff --git a/Diplomatic/Assets/Images/gavinbelson.png b/Diplomatic/Assets/Images/gavinbelson.png
deleted file mode 100644
index 4a321f8..0000000
Binary files a/Diplomatic/Assets/Images/gavinbelson.png and /dev/null differ
diff --git a/Diplomatic/Diplomatic.csproj b/Diplomatic/Diplomatic.csproj
index cab6d30..6864554 100644
--- a/Diplomatic/Diplomatic.csproj
+++ b/Diplomatic/Diplomatic.csproj
@@ -7,6 +7,9 @@
Always
+
+ Always
+
@@ -19,6 +22,7 @@
+
diff --git a/Diplomatic/Models/Field.cs b/Diplomatic/Models/Field.cs
index ad804ac..4d3b736 100644
--- a/Diplomatic/Models/Field.cs
+++ b/Diplomatic/Models/Field.cs
@@ -1,7 +1,7 @@
-using Newtonsoft.Json;
using System;
+using Newtonsoft.Json;
-namespace Diplomatic
+namespace Diplomatic.Models
{
[Serializable]
public class Field
@@ -10,6 +10,8 @@ public class Field
public string Name { get; }
[JsonIgnore]
public string Value { get; set; }
+ [JsonIgnore]
+ public bool IsValid => !string.IsNullOrEmpty(Value);
public Field(string name)
{
diff --git a/Diplomatic/Models/Signature.cs b/Diplomatic/Models/Signature.cs
new file mode 100644
index 0000000..8a9c1a2
--- /dev/null
+++ b/Diplomatic/Models/Signature.cs
@@ -0,0 +1,22 @@
+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);
+ }
+ }
+ }
+}
diff --git a/Diplomatic/Models/Template.cs b/Diplomatic/Models/Template.cs
index 174e3f1..5bc8aba 100644
--- a/Diplomatic/Models/Template.cs
+++ b/Diplomatic/Models/Template.cs
@@ -1,24 +1,26 @@
-using System;
using System.Collections.Generic;
+using System.Linq;
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 Fields { get; set; }
+ public IEnumerable Fields { get; }
+ [JsonProperty("signature")]
+ public bool HasSignature { get; }
+ [JsonIgnore]
+ public string Name { get; set; }
+ [JsonIgnore]
+ public Signature Signature { get; set; }
+ [JsonIgnore]
+ public bool IsValid => Fields.All(f => f.IsValid);
- public Template(string name, string path, IEnumerable fields)
+ public Template(bool signature, IEnumerable fields)
{
- TemplateName = name;
- Path = path;
Fields = fields;
+ HasSignature = signature;
}
}
}
diff --git a/Diplomatic/Utils/WebSignatureProvider.cs b/Diplomatic/Utils/WebSignatureProvider.cs
new file mode 100644
index 0000000..a8d821c
--- /dev/null
+++ b/Diplomatic/Utils/WebSignatureProvider.cs
@@ -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 signatures;
+ public IEnumerable 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>(content);
+ }
+ }
+ }
+}
diff --git a/Diplomatic/Utils/WebResourceProvider.cs b/Diplomatic/Utils/WebTemplateProvider.cs
similarity index 69%
rename from Diplomatic/Utils/WebResourceProvider.cs
rename to Diplomatic/Utils/WebTemplateProvider.cs
index e257e67..66d3270 100644
--- a/Diplomatic/Utils/WebResourceProvider.cs
+++ b/Diplomatic/Utils/WebTemplateProvider.cs
@@ -7,6 +7,8 @@
namespace Diplomatic.Utils
{
+ using Models;
+
public class WebTemplateProvider
{
private readonly List templates;
@@ -22,7 +24,14 @@ public WebTemplateProvider()
using (var reader = new StreamReader(response.GetResponseStream()))
{
string content = reader.ReadToEnd();
- templates = JsonConvert.DeserializeObject>(content);
+ Dictionary rawTemplates = JsonConvert.DeserializeObject>(content);
+
+ foreach (KeyValuePair entry in rawTemplates)
+ {
+ entry.Value.Name = entry.Key;
+ }
+
+ templates = rawTemplates.Values.ToList();
}
}
}
diff --git a/Diplomatic/ViewModels/ResultViewModel.cs b/Diplomatic/ViewModels/ResultViewModel.cs
index 2c26cae..2cf6e6e 100644
--- a/Diplomatic/ViewModels/ResultViewModel.cs
+++ b/Diplomatic/ViewModels/ResultViewModel.cs
@@ -1,7 +1,4 @@
using System;
-using System.Linq;
-using Diplomatic.Utils;
-
namespace Diplomatic.ViewModels
{
diff --git a/Diplomatic/ViewModels/SignaturePickerViewModel.cs b/Diplomatic/ViewModels/SignaturePickerViewModel.cs
index 72cf7fd..dd5fd65 100644
--- a/Diplomatic/ViewModels/SignaturePickerViewModel.cs
+++ b/Diplomatic/ViewModels/SignaturePickerViewModel.cs
@@ -1,39 +1,19 @@
-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();
}
-
}
}
diff --git a/Diplomatic/ViewModels/TemplatePickerViewModel.cs b/Diplomatic/ViewModels/TemplatePickerViewModel.cs
index 3061f47..44a4dd0 100644
--- a/Diplomatic/ViewModels/TemplatePickerViewModel.cs
+++ b/Diplomatic/ViewModels/TemplatePickerViewModel.cs
@@ -1,15 +1,17 @@
using System.Linq;
-using Diplomatic.Utils;
-
namespace Diplomatic.ViewModels
{
+ using Models;
+ using Utils;
+
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();
}
}
}
diff --git a/Diplomatic/ViewModels/TextFieldViewModel.cs b/Diplomatic/ViewModels/TextFieldViewModel.cs
index d4444f2..87dec96 100644
--- a/Diplomatic/ViewModels/TextFieldViewModel.cs
+++ b/Diplomatic/ViewModels/TextFieldViewModel.cs
@@ -1,8 +1,11 @@
namespace Diplomatic.ViewModels
{
+ using Models;
+
public class TextFieldViewModel
{
public Template SelectedTemplate { get; set; }
+
public TextFieldViewModel(Template selectedTemplate)
{
SelectedTemplate = selectedTemplate;
diff --git a/Diplomatic/Views/MainPage.xaml.cs b/Diplomatic/Views/MainPage.xaml.cs
index c35893e..db56af8 100644
--- a/Diplomatic/Views/MainPage.xaml.cs
+++ b/Diplomatic/Views/MainPage.xaml.cs
@@ -1,35 +1,33 @@
using System;
using Xamarin.Forms;
-using Diplomatic.ViewModels;
+
namespace Diplomatic.Views
{
+ using ViewModels;
+
public partial class MainPage : ContentPage
- {
+ {
public MainPage()
{
InitializeComponent();
}
- async void NextPage (object sender, EventArgs e)
+ private async void NextPage(object sender, EventArgs e)
{
var next = new Templates();
next.BindingContext = new TemplatePickerViewModel();
- // We do not need to submit any info to the page here yet
await Navigation.PushAsync(next);
}
- void OnShow ( object sender, EventArgs e)
+ private void OnShow(object sender, EventArgs e)
{
InfoLabel.IsVisible = !InfoLabel.IsVisible;
LinkLabel.IsVisible = !LinkLabel.IsVisible;
}
- void OnLink ( object sender, EventArgs e)
+ private void OnLink(object sender, EventArgs e)
{
Device.OpenUri(new Uri("https://github.com/Dualog-students/Diplomatic"));
}
-
-
-
}
}
diff --git a/Diplomatic/Views/Result.xaml.cs b/Diplomatic/Views/Result.xaml.cs
index 14198cb..ccdb292 100644
--- a/Diplomatic/Views/Result.xaml.cs
+++ b/Diplomatic/Views/Result.xaml.cs
@@ -1,12 +1,13 @@
-using System;
+using System;
using System.Net;
-using Diplomatic.Interfaces;
-using Diplomatic.ViewModels;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace Diplomatic.Views
{
+ using Interfaces;
+ using ViewModels;
+
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class Result : ContentPage
{
@@ -21,8 +22,9 @@ public async void SaveButtonClicked(object sender, EventArgs e)
string Filename = ((ResultViewModel)BindingContext).Filename;
byte[] imageBytes = await webClient.DownloadDataTaskAsync(((ResultViewModel)BindingContext).ImageUri);
DependencyService.Get().SavePictureToDisk(Filename, imageBytes);
+
await DisplayAlert("Save diploma", "Your diploma has been saved!", "OK");
}
}
}
-}
\ No newline at end of file
+}
diff --git a/Diplomatic/Views/Signatures.xaml b/Diplomatic/Views/Signatures.xaml
index c866130..6b95845 100644
--- a/Diplomatic/Views/Signatures.xaml
+++ b/Diplomatic/Views/Signatures.xaml
@@ -8,7 +8,7 @@
-
+
@@ -19,10 +19,10 @@
-
+
@@ -31,11 +31,6 @@
-
-
-
diff --git a/Diplomatic/Views/Signatures.xaml.cs b/Diplomatic/Views/Signatures.xaml.cs
index 0f7b2ea..50f790a 100644
--- a/Diplomatic/Views/Signatures.xaml.cs
+++ b/Diplomatic/Views/Signatures.xaml.cs
@@ -1,10 +1,13 @@
using System;
using System.Collections.Generic;
-using Diplomatic.ViewModels;
+using System.Threading.Tasks;
using Xamarin.Forms;
namespace Diplomatic.Views
{
+ using Models;
+ using ViewModels;
+
public partial class Signatures : ContentPage
{
public Signatures()
@@ -12,23 +15,28 @@ public Signatures()
InitializeComponent();
}
- async void NextPage(object sender, EventArgs e)
+ private async void NextPage(object sender, SelectedItemChangedEventArgs e)
{
- var template = ((SignaturePickerViewModel)BindingContext).SelectedTemplate;
- string Filename = template.TemplateName + "_";
+ Template template = ((SignaturePickerViewModel)BindingContext).SelectedTemplate;
+ template.Signature = (Signature)e.SelectedItem;
+ string Filename = template.Name + "_";
var queryParams = new List { };
- foreach (var field in template.Fields)
+
+ foreach (Field field in template.Fields)
{
Filename += field.Name + "_" + field.Value +"_";
queryParams.Add($"{field.Name.ToLower()}={field.Value}");
}
- var query = string.Join("&", queryParams.ToArray());
- string final = "https://qri7p78aml.execute-api.eu-west-2.amazonaws.com/dev/" + template.TemplateName.ToLower() + "?" + query;
+
+ queryParams.Add($"signature={template.Signature.Id}");
+ string query = string.Join("&", queryParams.ToArray());
+ string final = "https://qri7p78aml.execute-api.eu-west-2.amazonaws.com/dev/" + template.Name.ToLower() + "?" + query;
var endpoint = new Uri(Uri.EscapeUriString(final));
var next = new Result
{
BindingContext = new ResultViewModel(endpoint, Filename)
};
+
await Navigation.PushAsync(next);
}
}
diff --git a/Diplomatic/Views/Templates.xaml b/Diplomatic/Views/Templates.xaml
index 4287111..26bc026 100644
--- a/Diplomatic/Views/Templates.xaml
+++ b/Diplomatic/Views/Templates.xaml
@@ -4,7 +4,7 @@
-
+
@@ -12,8 +12,13 @@
-
-
+
diff --git a/Diplomatic/Views/Templates.xaml.cs b/Diplomatic/Views/Templates.xaml.cs
index 3c972e0..67d35bc 100644
--- a/Diplomatic/Views/Templates.xaml.cs
+++ b/Diplomatic/Views/Templates.xaml.cs
@@ -1,25 +1,28 @@
-using Diplomatic.ViewModels;
using Xamarin.Forms;
namespace Diplomatic.Views
{
+ using Models;
+ using ViewModels;
+
public partial class Templates : ContentPage
{
-
public Templates()
{
InitializeComponent();
-
}
- async void OnSelection(object sender, SelectedItemChangedEventArgs e)
+ private async void OnSelection(object sender, SelectedItemChangedEventArgs e)
{
if (e.SelectedItem == null)
{
return; //ItemSelected is called on deselection, which results in SelectedItem being set to null
}
- var next = new TextFields();
- next.BindingContext = new TextFieldViewModel((Template)e.SelectedItem);
+
+ var next = new TextFields
+ {
+ BindingContext = new TextFieldViewModel((Template)e.SelectedItem)
+ };
await Navigation.PushAsync(next);
}
diff --git a/Diplomatic/Views/TextFields.xaml.cs b/Diplomatic/Views/TextFields.xaml.cs
index fb5b33a..8e93ca6 100644
--- a/Diplomatic/Views/TextFields.xaml.cs
+++ b/Diplomatic/Views/TextFields.xaml.cs
@@ -1,8 +1,12 @@
using System;
-using Diplomatic.ViewModels;
+using System.Collections.Generic;
using Xamarin.Forms;
+
namespace Diplomatic.Views
{
+ using Models;
+ using ViewModels;
+
public partial class TextFields : ContentPage
{
public TextFields()
@@ -12,11 +16,39 @@ public TextFields()
private async void NextPage(object sender, EventArgs e)
{
- var next = new Signatures
+ Template selectedTemplate = ((TextFieldViewModel)BindingContext).SelectedTemplate;
+
+ if (selectedTemplate.HasSignature)
+ {
+ var next = new Signatures
+ {
+ BindingContext = new SignaturePickerViewModel(selectedTemplate)
+ };
+
+ await Navigation.PushAsync(next);
+ }
+ else
{
- BindingContext = new SignaturePickerViewModel(((TextFieldViewModel)BindingContext).SelectedTemplate)
- };
- await Navigation.PushAsync(next);
+ Template template = ((TextFieldViewModel)BindingContext).SelectedTemplate;
+ string Filename = template.Name + "_";
+ var queryParams = new List { };
+
+ foreach (Field field in template.Fields)
+ {
+ Filename += field.Name + "_" + field.Value + "_";
+ queryParams.Add($"{field.Name.ToLower()}={field.Value}");
+ }
+
+ string query = string.Join("&", queryParams.ToArray());
+ string final = "https://qri7p78aml.execute-api.eu-west-2.amazonaws.com/dev/" + template.Name.ToLower() + "?" + query;
+ var endpoint = new Uri(Uri.EscapeUriString(final));
+ var next = new Result
+ {
+ BindingContext = new ResultViewModel(endpoint, Filename)
+ };
+
+ await Navigation.PushAsync(next);
+ }
}
}
}
diff --git a/Resources/Diplomatic.png b/Resources/Diplomatic.png
deleted file mode 100644
index a284408..0000000
Binary files a/Resources/Diplomatic.png and /dev/null differ
diff --git a/Resources/diplomatic_icon b/Resources/diplomatic_icon
deleted file mode 100644
index 80fb644..0000000
Binary files a/Resources/diplomatic_icon and /dev/null differ
diff --git a/Resources/employee.png b/Resources/employee.png
deleted file mode 100644
index f402bd6..0000000
Binary files a/Resources/employee.png and /dev/null differ
diff --git a/Resources/good_effort.png b/Resources/good_effort.png
deleted file mode 100644
index da0ff19..0000000
Binary files a/Resources/good_effort.png and /dev/null differ
diff --git a/Resources/student.png b/Resources/student.png
deleted file mode 100644
index 84353ed..0000000
Binary files a/Resources/student.png and /dev/null differ
diff --git a/Resources/templates.json b/Resources/templates.json
deleted file mode 100644
index ff17e67..0000000
--- a/Resources/templates.json
+++ /dev/null
@@ -1,57 +0,0 @@
-[{
- "FilePath": "employee.png",
- "TemplateName": "Employee",
- "Fields": [{
- "Name": "name",
- "XOffset": 0.25,
- "YOffset": 0.25,
- "Height": 0.15,
- "Width": 0.5
- }, {
- "Name": "date",
- "XOffset": 0.12,
- "YOffset": 0.72,
- "Height": 0.06,
- "Width": 0.34
- }, {
- "Name": "boss",
- "XOffset": 0.54,
- "YOffset": 0.72,
- "Height": 0.06,
- "Width": 0.34
- }]
- }, {
- "FilePath": "student.png",
- "TemplateName": "Student",
- "Fields": [{
- "Name": "name",
- "XOffset": 0.25,
- "YOffset": 0.33,
- "Height": 0.15,
- "Width": 0.5
- }, {
- "Name": "helped with",
- "XOffset": 0.71,
- "YOffset": 0.59,
- "Height": 0.05,
- "Width": 0.125
- }, {
- "Name": "teacher name",
- "XOffset": 0.33,
- "YOffset": 0.8,
- "Height": 0.075,
- "Width": 0.33
- }]
- },
- {
- "FilePath": "good_effort.png",
- "TemplateName": "Good effort",
- "Fields": [{
- "Name": "name",
- "XOffset": 0.45,
- "YOffset": 0.4,
- "Height": 0.2,
- "Width": 0.4
- }]
- }
-]