Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Android.Content;
- using Android.Views;
- using Android.Widget;
- using AndroidX.ConstraintLayout.Widget;
- using Kdd.IdaCare.Mobile.Common.Enums;
- using Kdd.IdaCare.Mobile.Droid.Extensions;
- using Kdd.IdaCare.Mobile.Droid.Renderers.Native.Abstract;
- using Kdd.IdaCare.Mobile.Droid.Renderers.Native.Main.More;
- using Kdd.IdaCare.Mobile.Droid.Views.Controls.RecyclerViews.Adapters;
- using Kdd.IdaCare.Mobile.Droid.Views.ViewHolders.More;
- using Kdd.IdaCare.Mobile.Extensions.MvvmCross;
- using Kdd.IdaCare.Mobile.Resources;
- using Kdd.IdaCare.Mobile.UI.UI.Controls.Native.Main.More;
- using Kdd.IdaCare.Mobile.ViewModels.Items;
- using Kdd.IdaCare.Mobile.ViewModels.More;
- using MvvmCross.DroidX.RecyclerView;
- using MvvmCross.Platforms.Android.Binding;
- [assembly: Xamarin.Forms.ExportRenderer(typeof(MoreView), typeof(MoreViewRenderer))]
- namespace Kdd.IdaCare.Mobile.Droid.Renderers.Native.Main.More
- {
- public sealed class MoreViewRenderer : BaseNativeLayoutRenderer<MoreView, ConstraintLayout, MoreViewModel>
- {
- private MvxRecyclerView _recyclerView;
- private TextView _usernameTextView;
- private TextView _workingGroupTextView;
- private TextView _versionTextView;
- private TextView _deviceIdTextView;
- private TextView _changesCountTextView;
- private TextView _lastDateTextView;
- private FrameLayout _syncFrameLayout;
- private FrameLayout _loadingOverlay;
- private FrameLayout _workingGroupFrameLayout;
- private ImageView _logoutImageView;
- private ImageView _syncImageView;
- private TextView _syncTextView;
- public MoreViewRenderer(Context context)
- : base(context)
- {
- }
- protected override int LayoutId => Resource.Layout.layout_more;
- protected override void Initialize(ConstraintLayout control)
- {
- _loadingOverlay = control.FindViewById<FrameLayout>(Resource.Id.loading_overlay);
- _recyclerView = control.FindViewById<MvxRecyclerView>(Resource.Id.recycler_view);
- _usernameTextView = control.FindViewById<TextView>(Resource.Id.username_text_view);
- _workingGroupTextView = control.FindViewById<TextView>(Resource.Id.working_group_text_view);
- _versionTextView = control.FindViewById<TextView>(Resource.Id.version_text_view);
- _deviceIdTextView = control.FindViewById<TextView>(Resource.Id.device_id_text_view);
- _changesCountTextView = control.FindViewById<TextView>(Resource.Id.changes_count_text_view);
- _lastDateTextView = control.FindViewById<TextView>(Resource.Id.last_date_text_view);
- _syncFrameLayout = control.FindViewById<FrameLayout>(Resource.Id.synced_frame_layout);
- _workingGroupFrameLayout = control.FindViewById<FrameLayout>(Resource.Id.working_group_frame_layout);
- _logoutImageView = control.FindViewById<ImageView>(Resource.Id.logout_image_view);
- _syncImageView = control.FindViewById<ImageView>(Resource.Id.sync_image_view);
- _syncTextView = control.FindViewById<TextView>(Resource.Id.sync_text_view);
- var logoutTextView = control.FindViewById<TextView>(Resource.Id.logout_text_view);
- logoutTextView.Text = AppStrings.Logout;
- var syncTextView = control.FindViewById<TextView>(Resource.Id.sync_text_view);
- syncTextView.Text = AppStrings.SyncShort;
- var changesTextView = control.FindViewById<TextView>(Resource.Id.changes_text_view);
- changesTextView.Text = $"{AppStrings.Changes}:";
- var adapter = new RecyclerAdapter(this);
- _recyclerView.Adapter = adapter
- .Register<MoreItemViewModel, MoreItemViewHolder>(Resource.Layout.item_more);
- var headerView = control.FindViewById<View>(Resource.Id.header_view);
- headerView.SetRoundedCorners(2);
- _workingGroupFrameLayout.SetRoundedCorners(2);
- _syncFrameLayout.SetRoundedCorners(24);
- }
- protected override void Bind()
- {
- using var bindingSet = CreateBindingSet();
- bindingSet.Bind(_recyclerView).For(v => v.ItemsSource).To(vm => vm.Items);
- bindingSet.Bind(_recyclerView).For(v => v.ItemClick).To(vm => vm.ExecuteItemActionCommand);
- bindingSet.Bind(_usernameTextView).For(v => v.Text).To(vm => vm.CurrentUser);
- bindingSet.Bind(_workingGroupTextView).For(v => v.Text).To(vm => vm.WorkingGroupPresentation);
- bindingSet.Bind(_versionTextView).For(v => v.Text).To(vm => vm.SoftwareVersionPresentation);
- bindingSet.Bind(_deviceIdTextView).For(v => v.Text).To(vm => vm.RegisterDeviceIdPresentation);
- bindingSet.Bind(_changesCountTextView).For(v => v.Text).To(vm => vm.Changes);
- bindingSet.Bind(_lastDateTextView).For(v => v.Text).To(vm => vm.LastUpdatePresentation);
- bindingSet.Bind(_workingGroupFrameLayout).For(v => v.BindBackgroundColor()).To(vm => vm.WorkingGroupColorPresentation);
- bindingSet.Bind(_logoutImageView).For(v => v.BindTintColor()).To(vm => vm.WorkingGroupColorPresentation);
- bindingSet.Bind(_logoutImageView).For(v => v.BindClick()).To(vm => vm.LogoutCommand);
- bindingSet.Bind(_loadingOverlay).For(v => v.BindVisible()).To(vm => vm.IsBusy);
- bindingSet.Bind(_syncFrameLayout).For(v => v.BindBackgroundColor()).To(vm => vm.CanSync)
- .WithBoolConversion(AppColor.RedLightest, AppColor.BlueLightest);
- bindingSet.Bind(_syncImageView).For(v => v.BindTintColor()).To(vm => vm.CanSync)
- .WithBoolConversion(AppColor.Red, AppColor.Blue);
- bindingSet.Bind(_syncTextView).For(v => v.BindTextColor()).To(vm => vm.CanSync)
- .WithBoolConversion(AppColor.Red, AppColor.Blue);
- bindingSet.Bind(_syncFrameLayout).For(v => v.BindClick()).To(vm => vm.SyncCommand);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment