Skip to content

Commit

Permalink
Merge pull request #40 from martinstoeckli/feature/polishing
Browse files Browse the repository at this point in the history
Feature/polishing
  • Loading branch information
martinstoeckli authored Jan 6, 2020
2 parents 63dd7f3 + e32e9e9 commit 0540e72
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
14 changes: 13 additions & 1 deletion src/SilentNotes.Shared/Controllers/NoteRepositoryController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class NoteRepositoryController : ControllerBase
private readonly IRazorViewService _viewStop;
private NoteRepositoryViewModel _viewModel;
private StopViewModel _stopViewModel;
private string _scrollToNote;

/// <summary>
/// Initializes a new instance of the <see cref="NoteRepositoryController"/> class.
Expand Down Expand Up @@ -58,6 +59,7 @@ public override void ShowInView(IHtmlView htmlView, KeyValueList<string, string>
base.ShowInView(htmlView, variables);
View.NavigationCompleted += NavigationCompletedEventHandler;
IRepositoryStorageService repositoryService = Ioc.GetOrCreate<IRepositoryStorageService>();
_scrollToNote = variables?.GetValueOrDefault(ControllerParameters.NoteId);

RepositoryStorageLoadResult loadResult = repositoryService.LoadRepositoryOrDefault(out _);
if (loadResult != RepositoryStorageLoadResult.InvalidRepository)
Expand Down Expand Up @@ -127,7 +129,17 @@ protected override void SetHtmlViewBackgroundColor(IHtmlView htmlView)
private void NavigationCompletedEventHandler(object sender, EventArgs e)
{
View.NavigationCompleted -= NavigationCompletedEventHandler;
View.ExecuteJavaScript("makeSortable();");

string scrollToNoteScript = BuildScrollToNoteScript(_scrollToNote);
View.ExecuteJavaScript("makeSortable();" + scrollToNoteScript);
}

private static string BuildScrollToNoteScript(string noteId)
{
if (string.IsNullOrEmpty(noteId))
return null;
else
return string.Format("$('[data-note=\"{0}\"]').get(0).scrollIntoView();", noteId);
}

private void NotesChangedEventHandler(object obj)
Expand Down
8 changes: 6 additions & 2 deletions src/SilentNotes.Shared/Services/LanguageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ private void LoadEnglishResources(Dictionary<string, string> resources)
resources["continue"] = "Continue";

resources["error_loading_repository"] = "Could not read the notes. The application was stopped, to avoid further damage of already existing notes.";
resources["welcome_note"] = "<h1>Welcome to SilentNotes</h1><ul><li>SilentNotes respects your privacy with end-to-end encryption.</li><li>Take your notes and synchronize them between your pc and mobile devices.</li></ul>";
resources["welcome_note"] = "<h1>Welcome 💛</h1><p>SilentNotes respects your privacy. It doesn't collect personal data, runs free of adds and is open source.</p>";
resources["welcome_note_2"] = "<h1>Ordering notes</h1><p>Drag the double-arrow icon on a note to change the order.</p>";
resources["welcome_note_3"] = "<h1>Password protection</h1><p>Open the safe and use the lock icon to protect a note.</p>";

resources["note_create_new"] = "Create new note";
resources["note_undelete"] = "Restore note";
Expand Down Expand Up @@ -157,7 +159,9 @@ private void LoadGermanResources(Dictionary<string, string> resources)
resources["continue"] = "Weiter";

resources["error_loading_repository"] = "Die Notizen konnten nicht gelesen werden. Die Anwendung wurde gestoppt um bereits existierende Notizen nicht weiter zu beschädigen.";
resources["welcome_note"] = "<h1>Willkommen bei SilentNotes</h1><ul><li>SilentNotes respektiert Ihre Privatsphäre mit Ende-zu-Ende Verschlüsselung.</li><li>Schreiben Sie Ihre Notizen und synchronisieren Sie sie zwischen PC und Mobilgeräten.</li></ul>";
resources["welcome_note"] = "<h1>Willkommen 💛</h1><p>SilentNotes respektiert Ihre Privatsphäre, es sammelt keine Benutzerdaten, verzichtet auf Werbung und ist Open Source.";
resources["welcome_note_2"] = "<h1>Notizen ordnen</h1><p>Ziehen Sie das Doppelpfeil-Icon einer Notiz um die Reihenfolge zu ändern.</p>";
resources["welcome_note_3"] = "<h1>Passwortschutz</h1><p>Öffnen Sie den Tresor und benützen Sie das Schloss-Icon um eine Notiz zu schützen.</p>";

resources["note_create_new"] = "Neue Notiz erstellen";
resources["note_undelete"] = "Notiz wiederherstellen";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,13 @@ public bool TrySaveRepository(NoteRepositoryModel repositoryModel)

private void AddWelcomeNote(NoteRepositoryModel repositoryModel)
{
NoteModel welcomeNote = new NoteModel
NoteModel[] notes = new NoteModel[]
{
HtmlContent = _languageService.LoadText("welcome_note"),
new NoteModel { HtmlContent = _languageService.LoadText("welcome_note"), BackgroundColorHex = "#fbf4c1" },
new NoteModel { HtmlContent = _languageService.LoadText("welcome_note_2"), BackgroundColorHex = "#d9f8c8" },
new NoteModel { HtmlContent = _languageService.LoadText("welcome_note_3"), BackgroundColorHex = "#d0f8f9" },
};
repositoryModel.Notes.Add(welcomeNote);
repositoryModel.Notes.AddRange(notes);
}
}
}
2 changes: 1 addition & 1 deletion src/SilentNotes.Shared/Services/ThemeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace SilentNotes.Services
/// </summary>
public class ThemeService : IThemeService
{
private const int DefaultTheme = 2;
private const int DefaultTheme = 0;
private readonly ISettingsService _settingsService;

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/SilentNotes.Shared/ViewModels/NoteViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public override void OnStoringUnsavedData()
/// <inheritdoc/>
private void GoBack()
{
_navigationService.Navigate(ControllerNames.NoteRepository);
_navigationService.Navigate(ControllerNames.NoteRepository, ControllerParameters.NoteId, Model.Id.ToString());
}

/// <inheritdoc/>
Expand Down

0 comments on commit 0540e72

Please sign in to comment.