mekasu0124

Untitled

Mar 9th, 2024
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.71 KB | None | 0 0
  1. using SeedDb.Services;
  2. using ReactiveUI;
  3. using System.Reactive;
  4. using SeedDb.Models;
  5. using System;
  6.  
  7. namespace SeedDb.ViewModels;
  8.  
  9. public class TermsOfServiceViewModel : ViewModelBase
  10. {
  11.     private JsonEngine _js = new();
  12.     private Helpers _hp = new();
  13.  
  14.     private string _title = "";
  15.     private string _info = "";
  16.  
  17.     public TermsOfServiceViewModel(JsonEngine js, Helpers hp)
  18.     {
  19.         _js = js;
  20.         _hp = hp;
  21.  
  22.         Title = "Terms Of Service";
  23.         Info = Hp.GetTosText();
  24.  
  25.         IObservable<bool> okEnabled = this.WhenAnyValue(
  26.             x => x.Info,
  27.             x => !string.IsNullOrEmpty(x));
  28.  
  29.         Ok = ReactiveCommand.Create(ReturnAgreedTos, okEnabled);
  30.         Cancel = ReactiveCommand.Create(ReturnDeclinedTos, okEnabled);
  31.     }
  32.  
  33.     public SetupModel ReturnAgreedTos()
  34.     {
  35.         return new SetupModel()
  36.         {
  37.             Setup = false,
  38.             Tos = Js.UpdateTos()
  39.         };
  40.     }
  41.  
  42.     public SetupModel ReturnDeclinedTos()
  43.     {
  44.         return new SetupModel()
  45.         {
  46.             Setup = false,
  47.             Tos = false
  48.         };
  49.     }
  50.  
  51.     public ReactiveCommand<Unit, SetupModel> Ok { get; }
  52.     public ReactiveCommand<Unit, SetupModel> Cancel { get; }
  53.  
  54.     public JsonEngine Js
  55.     {
  56.         get => _js;
  57.         set => this.RaiseAndSetIfChanged(ref _js, value);
  58.     }
  59.  
  60.     public Helpers Hp
  61.     {
  62.         get => _hp;
  63.         set => this.RaiseAndSetIfChanged(ref _hp, value);
  64.     }
  65.  
  66.     public string Title
  67.     {
  68.         get => _title;
  69.         set => this.RaiseAndSetIfChanged(ref _title, value);
  70.     }
  71.  
  72.     public string Info
  73.     {
  74.         get => _info;
  75.         set => this.RaiseAndSetIfChanged(ref _info, value);
  76.     }
  77. }
  78.  
Advertisement
Add Comment
Please, Sign In to add comment