Ejemplo n.º 1
0
        public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            base.OnCreateView (inflater, container, savedInstanceState);
            var view = inflater.Inflate (Resource.Layout.LaborHoursLayout, null, true);

            laborViewModel = ServiceContainer.Resolve<LaborViewModel> ();

            laborListView = view.FindViewById<ListView> (Resource.Id.laborListViewFragment);

            ReloadLaborHours ();
            laborListView.ItemClick += (sender, e) => {
                var textView = e.View.FindViewById<TextView> (Resource.Id.laborHours);

                var labor = LaborHours.ElementAtOrDefault ((int)textView.Tag);

                laborDialog = new AddLaborDialog (Activity);
                laborDialog.Assignment = Assignment;
                laborDialog.CurrentLabor = labor;
                laborDialog.Show ();
            };
            return view;
        }
Ejemplo n.º 2
0
        protected override void OnCreate (Bundle bundle)
        {
            base.OnCreate (bundle);

            Window.RequestFeature (WindowFeatures.ActionBar);

            SetContentView (Resource.Layout.SummaryFragmentLayout);

            number = FindViewById<TextView> (Resource.Id.selectedAssignmentNumber);
            name = FindViewById<TextView> (Resource.Id.selectedAssignmentContactName);
            phone = FindViewById<TextView> (Resource.Id.selectedAssignmentPhoneNumber);
            address = FindViewById<TextView> (Resource.Id.selectedAssignmentAddress);
            items = FindViewById<TextView> (Resource.Id.selectedAssignmentTotalItems);
            addItems = FindViewById<Button> (Resource.Id.selectedAssignmentAddItem);
            addLabor = FindViewById<Button> (Resource.Id.selectedAssignmentAddLabor);
            addExpense = FindViewById<Button> (Resource.Id.selectedAssignmentAddExpense);
            navigationFragmentContainer = FindViewById<FrameLayout> (Resource.Id.navigationFragmentContainer);
            mapButton = FindViewById<LinearLayout> (Resource.Id.summaryMapIconLayout);
            phoneButton = FindViewById<LinearLayout> (Resource.Id.summaryPhoneIconLayout);

            phoneButton.Click += (sender, e) => {
                AndroidExtensions.MakePhoneCall (this, phone.Text);
            };
            mapButton.Click += (sender, e) => {
                var navFragment = FragmentManager.FindFragmentById<NavigationFragment> (Resource.Id.navigationFragmentContainer);
                var index = Constants.Navigation.IndexOf ("Map");
                navFragment.SetNavigation (index);
            };

            if (assignment != null) {
                ActionBar.Title = string.Format ("#{0} {1} {2}", assignment.JobNumber, "Summary", assignment.StartDate.ToShortDateString ());

                number.Text = assignment.Priority.ToString ();
                name.Text = assignment.ContactName;
                phone.Text = assignment.ContactPhone;
                address.Text = string.Format ("{0}\n{1}, {2} {3}", assignment.Address, assignment.City, assignment.State, assignment.Zip);
            }

            //portrait mode, flip back and forth when selecting the navigation menu.
            if (Resources.Configuration.Orientation == Orientation.Landscape) {
                navigationFragmentContainer.Visibility = ViewStates.Visible;
            } else {
                navigationFragmentContainer.Visibility = ViewStates.Invisible;
            }

            //setting up default fragments
            var transaction = FragmentManager.BeginTransaction ();
            navigationFragment = new NavigationFragment ();
            navigationFragment.Assignment = assignment;
            transaction.SetTransition (FragmentTransit.FragmentOpen);
            transaction.Replace (Resource.Id.navigationFragmentContainer, navigationFragment);
            transaction.Commit ();

            items.Visibility =
                 addItems.Visibility = ViewStates.Invisible;
            addLabor.Visibility = ViewStates.Gone;

            addItems.Click += (sender, e) => {
                itemDialog = new ItemsDialog (this);
                itemDialog.Assignment = assignment;
                itemDialog.Show ();
            };
            addLabor.Click += (sender, e) => {
                laborDialog = new AddLaborDialog (this);
                laborDialog.Assignment = assignment;
                laborDialog.CurrentLabor = new Labor ();
                laborDialog.Show ();
            };
            addExpense.Click += (sender, e) => {
                //show add expense dialog;
                expenseDialog = new ExpenseDialog (this);
                expenseDialog.Assignment = assignment;
                expenseDialog.CurrentExpense = new Expense ();
                expenseDialog.Show ();
            };

            ActionBar.SetLogo (Resource.Drawable.XamarinTitle);
            ActionBar.SetBackgroundDrawable (Resources.GetDrawable (Resource.Drawable.actionbar));
            ActionBar.SetDisplayHomeAsUpEnabled (true);
        }