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
services.AddTransient<IMainViewModel, MainViewModel>(); | |
services.AddTransient<ISomarViewModel, SomarViewModel>(); | |
services.AddTransient<MainPage>(); | |
services.AddTransient<SomarPage>(); | |
//Importante ser singleton | |
services.AddSingleton<IEventAggregator, EventAggregator>(); | |
services.AddSingleton<App>(); |
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
using System; | |
using System.Threading.Tasks; | |
using MvvmHelpers; | |
using XamarinFormsEventAggregator.Events; | |
namespace XamarinFormsEventAggregator.ViewModels | |
{ | |
public class SomarViewModel : BaseViewModel | |
{ | |
private readonly IEventAggregator _EventAggregator; |
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
using System; | |
using System.Threading.Tasks; | |
using MvvmHelpers; | |
using MvvmHelpers.Commands; | |
using Xamarin.Forms; | |
using XamarinFormsEventAggregator.Events; | |
namespace XamarinFormsEventAggregator.ViewModels | |
{ | |
public class MainViewModel : BaseViewModel |
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
using System; | |
namespace XamarinFormsEventAggregator.Events | |
{ | |
public class SomarMessage | |
{ | |
public string Texto { get; 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
<?xml version="1.0" encoding="UTF-8" ?> | |
<ContentPage | |
xmlns="http://xamarin.com/schemas/2014/forms" | |
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | |
x:Class="XamarinFormsEventAggregator.SomarPage"> | |
<ContentPage.Content> | |
<StackLayout> | |
<Frame BackgroundColor="#2196F3" Padding="24" CornerRadius="0"> | |
<Label Text="EventAggregator" HorizontalTextAlignment="Center" TextColor="White" FontSize="36"/> | |
</Frame> |
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
<?xml version="1.0" encoding="utf-8" ?> | |
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" | |
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | |
Padding="0,60,0,0" | |
x:Class="XamarinFormsEventAggregator.MainPage"> | |
<StackLayout> | |
<Frame BackgroundColor="#2196F3" Padding="24" CornerRadius="0"> | |
<Label Text="EventAggregator" HorizontalTextAlignment="Center" TextColor="White" FontSize="36"/> | |
</Frame> |
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
private static EventAggregator instance; | |
public static EventAggregator Instance | |
{ | |
get | |
{ | |
if (instance == null) | |
{ | |
instance = new EventAggregator(); | |
} | |
return instance; |
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading; | |
namespace XamarinFormsEventAggregator.Events | |
{ | |
public class EventAggregator : IEventAggregator | |
{ |
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
using System; | |
namespace XamarinFormsEventAggregator.Events | |
{ | |
public interface IEventAggregator | |
{ | |
// Envia Mensagem e aguarda para ser processado na UI thread antes de retornar | |
void SendMessage<T>(T message); | |
// Publica a mensagem para processamento posterior na UI thread , retornando imediatamente. |
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 AppDelegate : UIApplicationDelegate | |
{ | |
NSObject _screenshotNotification = null; | |
public override void OnActivated (UIApplication application) | |
{ | |
// Inicia a verificação | |
if (_screenshotNotification == null) | |
{ | |
_screenshotNotification = UIApplication.Notifications.ObserveUserDidTakeScreenshot((sender, args) => |