This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<StackLayout Margin="20"> | |
<Entry Text="{Binding Title, Mode=TwoWay}" Placeholder="Title"/> | |
<StackLayout Orientation="Horizontal"> | |
<Label Text="{Binding TitleLength, Mode=OneWay}"/> | |
<Label Text="letters used from"/> | |
<Label Text="{Binding TitleLengthMax, Mode=OneWay}"/> | |
</StackLayout> | |
<Entry Text="{Binding Message, Mode=TwoWay}" Placeholder="Message"/> | |
<StackLayout Orientation="Horizontal"> | |
<Label Text="{Binding MessageLength, Mode=OneWay}"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<StackPanel Width="300" VerticalAlignment="Center"> | |
<TextBlock Text="Feedback" Style="{StaticResource TitleTextBlockStyle}" /> | |
<TextBox Text="{x:Bind ViewModel.Title, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" | |
MaxLength="{x:Bind ViewModel.TitleLengthMax}" | |
PlaceholderText="Title" /> | |
<TextBlock Style="{StaticResource CaptionTextBlockStyle}" Margin="0 5"> | |
<Run Text="{x:Bind ViewModel.TitleLength, Mode=OneWay}"/> | |
<Run Text="letters used from"/> | |
<Run Text="{x:Bind ViewModel.TitleLengthMax}"/> | |
</TextBlock> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Fact] | |
public void ShouldValidateFormAndSendFeedback() | |
{ | |
// Create stubs for all dependencies and inject them. | |
var sender = Substitute.For<ISender>(); | |
var clock = Substitute.For<IClock>(); | |
var feedback = new FeedbackViewModel(sender, clock); | |
feedback.HasErrors.Should().BeTrue(); | |
// Emulate user input. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public sealed partial class FeedbackView : Page, IViewFor<FeedbackViewModel> | |
{ | |
public static readonly DependencyProperty ViewModelProperty = DependencyProperty | |
.Register(nameof(ViewModel), typeof(FeedbackViewModel), typeof(FeedbackView), null); | |
public FeedbackView() | |
{ | |
InitializeComponent(); | |
ViewModel = new FeedbackViewModel(new UwpSender(), new Clock()); | |
this.WhenActivated(disposables => { /* handle interactions, etc. */ }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Program | |
open System | |
open Funogram.Bot | |
/// Handles all Telegram events. | |
let update context = | |
context.Update.UpdateId | |
|> printfn "Received update: %i" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Program | |
open Funogram.Bot | |
open Funogram.Api | |
open ExtCore.Control | |
open System | |
/// Handler for '/hello'. | |
let onHello context = | |
maybe { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public partial class FeedbackView : Form, IViewFor<FeedbackViewModel> | |
{ | |
public FeedbackView() | |
{ | |
InitializeComponent(); | |
ViewModel = new FeedbackViewModel(new WinFormsSender(), new Clock()); | |
this.WhenActivated(subscriptions => | |
{ | |
this.Bind(ViewModel, x => x.Title, x => x.TitleTextBox.Text) | |
.DisposeWith(subscriptions); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public sealed class FeedbackViewModel : ReactiveObject, IActivatableViewModel | |
{ | |
public ViewModelActivator Activator { get; } = new ViewModelActivator(); | |
public ReactiveCommand<Unit, Unit> Submit { get; } | |
[Reactive] public bool HasErrors { get; private set; } | |
[Reactive] public string Elapsed { get; private set; } = string.Empty; | |
[Reactive] public string Title { get; set; } = string.Empty; | |
[Reactive] public int TitleLength { get; private set; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<StackPanel> | |
<!-- Note the ".Value" suffix added to "Name" and "Greeting" properties. --> | |
<TextBox Text="{Binding Name.Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/> | |
<TextBlock Text="{Binding Greeting.Value, Mode=OneWay}"/> | |
<Button Content="Clear" Command="{Binding Clear}"/> | |
</StackPanel> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ViewModel : INotifyPropertyChanged | |
{ | |
public ViewModel() | |
{ | |
Clear = new Command(() => Name = string.Empty); | |
} | |
public ICommand Clear { get; } | |
public string Greeting => $"Hello, {Name}!"; |
OlderNewer