sharee.bike-App/TINK/TINK/View/FeedbackPopup.xaml.cs

64 lines
1.8 KiB
C#
Raw Normal View History

2021-05-13 20:16:41 +02:00
using System;
using Xamarin.CommunityToolkit.UI.Views;
using Xamarin.Forms.Xaml;
namespace TINK.View
{
2021-06-26 20:57:55 +02:00
[XamlCompilation(XamlCompilationOptions.Compile)]
2021-08-01 17:24:15 +02:00
public partial class FeedbackPopup : Popup<FeedbackPopup.Result>
{
2022-01-04 18:54:03 +01:00
/// <summary> Constructs user feedback popup.</summary>
/// <param name="co2Saving"> Co2 saving information.</param>
public FeedbackPopup(string co2Saving = null)
2021-08-01 17:24:15 +02:00
{
InitializeComponent();
2022-01-04 18:54:03 +01:00
if (string.IsNullOrEmpty(co2Saving))
Co2SavingFrame.IsVisible = false;
else
Co2SavingLabel.Text = co2Saving;
2021-08-01 17:24:15 +02:00
}
2021-05-13 20:16:41 +02:00
protected override FeedbackPopup.Result GetLightDismissResult()
{
return new Result
2021-08-01 17:24:15 +02:00
{
Message = feedbackMessage.Text,
IsBikeBroken = brockenCheckBox.IsChecked
};
2021-05-13 20:16:41 +02:00
}
2021-08-01 17:24:15 +02:00
private void OnOkClicked(object sender, EventArgs eventArgs)
2021-05-13 20:16:41 +02:00
{
2021-08-01 17:24:15 +02:00
var result = new Result
{
Message = feedbackMessage.Text,
IsBikeBroken = brockenCheckBox.IsChecked
};
2021-05-13 20:16:41 +02:00
2021-08-01 17:24:15 +02:00
Dismiss(result);
2021-05-13 20:16:41 +02:00
}
2021-08-01 17:24:15 +02:00
/// <summary>
/// Feedback given by user when returning bike.
/// </summary>
2021-06-26 20:57:55 +02:00
#if USCSHARP9
2021-05-13 20:16:41 +02:00
public class Result : IViewService.IUserFeedback
2021-06-26 20:57:55 +02:00
#else
2021-08-01 17:24:15 +02:00
public new class Result : IUserFeedback
2021-06-26 20:57:55 +02:00
#endif
2021-08-01 17:24:15 +02:00
{
/// <summary>
/// Holds whether bike is broken or not.
/// </summary>
public bool IsBikeBroken { get; set; }
2021-05-13 20:16:41 +02:00
2021-08-01 17:24:15 +02:00
/// <summary>
/// Holds either
/// - general feedback
/// - error description of broken bike
/// or both.
/// </summary>
public string Message { get; set; }
}
}
2021-05-13 20:16:41 +02:00
}