This repository was archived by the owner on Jul 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 610
Expand file tree
/
Copy pathPromoteViewController.cs
More file actions
67 lines (56 loc) · 2.43 KB
/
PromoteViewController.cs
File metadata and controls
67 lines (56 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using UIKit;
using System;
namespace CodeHub.iOS.ViewControllers.Walkthrough
{
public partial class PromoteViewController : BaseViewController
{
private bool _shouldWatch;
private bool _shouldStar;
public PromoteViewController()
: base("PromoteViewController", null)
{
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
StarButton.BackgroundColor = UIColor.FromRGB(0x2c, 0x3e, 0x50);
StarButton.SetTitleColor(UIColor.White, UIControlState.Normal);
StarButton.Layer.CornerRadius = 6f;
WatchButton.BackgroundColor = UIColor.FromRGB(0x7f, 0x8c, 0x8d);
WatchButton.SetTitleColor(UIColor.White, UIControlState.Normal);
WatchButton.Layer.CornerRadius = 6f;
OnActivation(d => {
d(WatchButton.GetClickedObservable().Subscribe(_ => WatchCodeHub()));
d(StarButton.GetClickedObservable().Subscribe(_ => StarCodeHub()));
});
}
private void StarCodeHub()
{
_shouldStar = !_shouldStar;
Core.Settings.ShouldStar = _shouldStar;
var color = _shouldStar ? UIColor.FromRGB(0xbd, 0xc3, 0xc7) : UIColor.FromRGB(0x2c, 0x3e, 0x50);
StarButton.SetTitle(_shouldStar ? "Good Choice!" : "Star", UIControlState.Normal);
UIView.Animate(0.3f, () => StarButton.BackgroundColor = color);
Alert();
}
private void WatchCodeHub()
{
_shouldWatch = !_shouldWatch;
Core.Settings.ShouldWatch = _shouldWatch;
var color = _shouldWatch ? UIColor.FromRGB(0xbd, 0xc3, 0xc7) : UIColor.FromRGB(0x7f, 0x8c, 0x8d);
WatchButton.SetTitle(_shouldWatch ? "Very Nice!" : "Watch", UIControlState.Normal);
UIView.Animate(0.3f, () => WatchButton.BackgroundColor = color);
Alert();
}
private bool _hasAlerted;
private void Alert()
{
if (_hasAlerted)
return;
_hasAlerted = true;
var alert = UIAlertController.Create("Awesome!", "When you login to your account I will make the changes! Thanks for helping create a better CodeHub!", UIAlertControllerStyle.Alert);
alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, x => {}));
PresentViewController(alert, true, null);
}
}
}