Skip to content

Commit

Permalink
Simplified
Browse files Browse the repository at this point in the history
  • Loading branch information
papafe committed May 7, 2024
1 parent 222ee93 commit 1244ac0
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions examples/QuickJournal/ViewModels/EntriesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ public async Task AddEntry()
});
});

await GoToEntry(entry);
await GoToEntry(new JournalEntryViewModel(entry));
}

[RelayCommand]
public async Task EditEntry(JournalEntryViewModel entry)
{
await GoToEntry(entry.Entry);
await GoToEntry(entry);
}

[RelayCommand]
Expand All @@ -53,17 +53,17 @@ await realm.WriteAsync(() =>
});
}

private async Task GoToEntry(JournalEntry entry)
private async Task GoToEntry(JournalEntryViewModel entry)
{
var navigationParameter = new Dictionary<string, object>
{
{ "Entry", entry },
{ "Entry", entry.Entry },
};
await Shell.Current.GoToAsync($"entryDetail", navigationParameter);
}
}

public class WrapperCollection<T, TViewModel> : INotifyCollectionChanged, IEnumerable<TViewModel>
public class WrapperCollection<T, TViewModel> : INotifyCollectionChanged, IReadOnlyList<TViewModel>
where T : IRealmObject
where TViewModel : class
{
Expand All @@ -72,6 +72,8 @@ public class WrapperCollection<T, TViewModel> : INotifyCollectionChanged, IEnume

public int Count => _results.Count;

public TViewModel this[int index] => _viewModelFactory(_results[index]);

public event NotifyCollectionChangedEventHandler? CollectionChanged
{
add { _results.CollectionChanged += value; }
Expand Down

0 comments on commit 1244ac0

Please sign in to comment.