Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Interface with new webAPI #24

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Interface with new webAPI #24

wants to merge 6 commits into from

Conversation

MaxJohansen
Copy link
Contributor

Changes 🎈

Signatures are now fetched from the web API instead of from local storage! I've deleted a LOT of leftover resources and code from the old implementation and fixed the failing tests.

Types of changes

What types of changes does your code introduce? Mark boxes that apply with an x.

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist ✔️

Mark boxes that apply with an x. These can also be filled out after the pull request is created.

  • I have read the coding convention guidelines and my code follows these.
  • Unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Copy link
Contributor

@jonjohansen jonjohansen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good but not 💯 🥇

@@ -1,15 +1,17 @@
using System.Collections.Generic;
using System.Linq;
using Diplomatic.Utils;


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary newline 👎

public partial class Templates : ContentPage
{

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newline before new block?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No

@@ -18,8 +19,10 @@ public Templates()
{
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newliner 🥈

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newliner 🥉

{
BindingContext = new ResultViewModel(endpoint, Filename)
};
await Navigation.PushAsync(next);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥉 Newliner

@@ -10,6 +10,8 @@ public class Field
public string Name { get; }
[JsonIgnore]
public string Value { get; set; }
[JsonIgnore]
virtual public bool IsValid => !string.IsNullOrEmpty(Value);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be virtual. 🥈

@MaxJohansen MaxJohansen force-pushed the feature/signatures branch from 0856613 to 1d445b0 Compare July 5, 2018 07:16
[JsonProperty("id")]
public string Id { get; set; }
public Uri ImageUri {
get {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newlines bro 🥉

@@ -22,7 +23,12 @@ public WebTemplateProvider()
using (var reader = new StreamReader(response.GetResponseStream()))
{
string content = reader.ReadToEnd();
templates = JsonConvert.DeserializeObject<List<Template>>(content);
Dictionary<string, Template> rawTemplates = JsonConvert.DeserializeObject<Dictionary<string, Template>>(content);
foreach (KeyValuePair<string, Template> entry in rawTemplates)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newline bro :4th_place_medal:

public class TemplatePickerViewModel
{
public Template[] TemplateList { get; set; }
public Template[] Templates { get; set; }
public TemplatePickerViewModel()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newline

@@ -1,5 +1,6 @@
namespace Diplomatic.ViewModels
{
using Models;
public class TextFieldViewModel
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newline

namespace Diplomatic.Views
{
using ViewModels;
public partial class MainPage : ContentPage
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newline :11st_place_medal:

{
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No space before first function parameter.

var queryParams = new List<string> { };
foreach (var field in template.Fields)
foreach (Field field in template.Fields)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newline before this line

{
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}");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And after the block <3

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This starts a block, so a newline before it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initializers aren't real blocks to me 👀

{
BindingContext = new SignaturePickerViewModel(selectedTemplate)
};
await Navigation.PushAsync(next);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newline.

await Navigation.PushAsync(next);
Template template = ((TextFieldViewModel)BindingContext).SelectedTemplate;
var queryParams = new List<string> { };
foreach (Field field in template.Fields)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newliner before and after ❤️

{
BindingContext = new ResultViewModel(endpoint)
};
await Navigation.PushAsync(next);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Come on man... :22nd_place_medal:

Copy link
Contributor

@IsakSundeSingh IsakSundeSingh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix it

@MaxJohansen MaxJohansen force-pushed the feature/signatures branch 4 times, most recently from 1e404fa to 9e52de4 Compare July 5, 2018 07:49
MaxJohansen and others added 3 commits July 5, 2018 09:50
Interface for saving images has been added
 - Implemented on iOS
 - Permissions have been set for iOS

Views:
Result has gotten two buttons
Save button now has an action, which should run a code-behind function for saving
 NOTE: the name of the image saved in the codebehind should be changed
It now works on android!
Filename sent in is "Navn" for now. This needs to change
Images now have names (Only available on an ANDROID near you)!
Also
	Stuff looks clean now
@MaxJohansen MaxJohansen force-pushed the feature/signatures branch from 9e52de4 to d7bed33 Compare July 5, 2018 07:55
Resolved scaling issue (Might have to refactor this into a decent scale later)
Aligned signatures to the left.
@jonjohansen jonjohansen force-pushed the feature/signatures branch from 72673d6 to 2425d7c Compare July 5, 2018 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants