public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { base.OnCreateView(inflater, container, savedInstanceState); HasOptionsMenu = true; var view = this.BindingInflate(Resource.Layout.fragment_chat, container, false); ((MainActivity)Activity).ToastSent += toast => { var bar = TSnackbar.Make(view.FindViewById(Android.Resource.Id.Content), toast.Text, TSnackbar.LengthLong); bar.View.SetBackgroundColor(Color.Gray); if (toast.Action != null) { bar.SetAction(toast.ActionText, toast.Action); } bar.Show(); }; tabView = view.FindViewById <RecyclerView>(Resource.Id.channelTabs); tabView.SetLayoutManager(new LinearLayoutManager(Context, LinearLayoutManager.Horizontal, false)); if (ViewModel.SelectedTab != null) { ScrollToTab(); } var messageList = view.FindViewById <MvxListView>(Resource.Id.messageList); messageList.Adapter = new MessageAdapter(Context, (IMvxAndroidBindingContext)BindingContext, () => messageList.Post(() => { if (messageList.ChildCount == 0) { return; } if (messageList.LastVisiblePosition == messageList.Adapter.Count - 2 && messageList.GetChildAt(messageList.ChildCount - 1).Bottom <= messageList.Height) { messageList.SetSelection(messageList.Adapter.Count - 1); } })); ViewModel.TabSelected += () => { ScrollToTab(); messageList.SetSelection(messageList.Count - 1); Activity.InvalidateOptionsMenu(); }; RegisterForContextMenu(view.FindViewById <Button>(Resource.Id.sendButton)); view.FindViewById <EditText>(Resource.Id.input).EditorAction += (sender, args) => { var enter = args.Event != null && args.Event.DeviceId > 0 && (args.Event.Action == KeyEventActions.Down && args.Event.KeyCode == Keycode.Enter || !args.Event.IsShiftPressed); if (args.ActionId == ImeAction.Send || args.ActionId == ImeAction.Done || enter) { if (ViewModel.SelectedTab.SendCommand.CanExecute()) { ViewModel.SelectedTab.SendCommand.Execute(); } args.Handled = true; } }; return(view); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { base.OnCreateView(inflater, container, savedInstanceState); HasOptionsMenu = true; ViewModel.PropertyChanged += (sender, args) => { if (args.PropertyName == nameof(ViewModel.SelectedCharacter)) { Activity.InvalidateOptionsMenu(); } }; var view = this.BindingInflate(Resource.Layout.fragment_people, container, false); ((MainActivity)Activity).ToastSent += toast => { var bar = TSnackbar.Make(view.FindViewById(Android.Resource.Id.Content), toast.Text, TSnackbar.LengthLong); if (toast.Action != null) { bar.SetAction(toast.ActionText, toast.Action); } bar.Show(); }; var listView = view.FindViewById <MvxListView>(Resource.Id.list); var tabLayout = view.FindViewById <TabLayout>(Resource.Id.tabs); var tabs = ViewModel.Tabs.ToDictionary(x => tabLayout.NewTab().SetText(x.Name)); foreach (var tab in tabs.Keys) { tabLayout.AddTab(tab); } tabLayout.TabSelected += (sender, args) => { ViewModel.TabSelectedCommand.Execute(tabs[args.Tab]); listView.ItemTemplateId = args.Tab.Position == 2 ? Resource.Layout.list_item_character : Resource.Layout.list_item_character_image; }; var value = new TypedValue(); Context.Theme.ResolveAttribute(Resource.Attribute.colorAccent, value, true); listView.Selector = new ColorDrawable(new Color(value.Data)); return(view); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { base.OnCreateView(inflater, container, savedInstanceState); HasOptionsMenu = true; var view = this.BindingInflate(Resource.Layout.fragment_channels, container, false); ((MainActivity)Activity).ToastSent += toast => { var bar = TSnackbar.Make(view.FindViewById(Android.Resource.Id.Content), toast.Text, TSnackbar.LengthLong); if (toast.Action != null) { bar.SetAction(toast.ActionText, toast.Action); } bar.Show(); }; var tabLayout = view.FindViewById <TabLayout>(Resource.Id.tabs); var tabs = ViewModel.Tabs.ToDictionary(x => tabLayout.NewTab().SetText(x.Name)); foreach (var tab in tabs.Keys) { tabLayout.AddTab(tab); } tabLayout.TabSelected += (sender, args) => ViewModel.TabSelectedCommand.Execute(tabs[args.Tab]); return(view); }
public void onShown(TSnackbar TSnackbar) { }
public void onDismissed(TSnackbar TSnackbar, int ev) { }