Esempio n. 1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.ViewTripDetail);

            _expensesView = FindViewById<ListView>(Resource.Id.viewTripDetailListViewExpenses);

            var tripId = Intent.GetStringExtra("SelectedTripId");
            _trip =  new TripManager().GetTrip(new Guid(tripId));
            // In case the Trip was just created, intialize expenses
            
            UpdateUI();

            FindViewById<Button>(Resource.Id.viewTripDetaiButtonAdd).Click += (s, e) =>
            {
                var intent = new Intent(this, typeof(EditExpenseScreen));
                intent.PutExtra("SelectedTripId", _trip.Id.ToString());
                base.StartActivity(intent);
            };

            _expensesView.ItemClick += (s, e) =>
            {
                var intent = new Intent(this, typeof(EditExpenseScreen));
                intent.PutExtra("SelectedTripId", _trip.Id.ToString());
                intent.PutExtra("SelectedExpenseId", _trip.Expenses[e.Position].Id.ToString());
                base.StartActivity(intent);
            };
        }
Esempio n. 2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.EditTrip);

            var tripId = Intent.GetStringExtra("SelectedTripId");
            _trip = String.IsNullOrEmpty(tripId)
                        ? new Trip() { StartDate = DateTime.Now, EndDate = DateTime.Now }
                        : new TripManager().GetTrip(new Guid(tripId));

            UpdateUI();

            FindViewById<Button>(Resource.Id.editTripButtonSave).Click += (s, e) =>
                {
                    UpdateTrip();
                    new TripManager().SaveTrip(_trip);

                    var intent = new Intent(this, typeof(ViewTripDetailScreen));
                    intent.PutExtra("SelectedTripId", _trip.Id.ToString());

                    base.StartActivity(intent);
                };

            FindViewById<Button>(Resource.Id.editTripButtonDelete).Click += (s, e) =>
            {
               
                new TripManager().RemoveTrip(_trip);
                var intent = new Intent(this, typeof(HomeScreen));
                base.StartActivity(intent);
            };

        }
Esempio n. 3
0
        public void SaveExpense(Trip trip, Expense expense)
        {
            if (trip.Expenses.FirstOrDefault((x) => x.Id == expense.Id) != null)
                trip.Expenses.Remove(expense);
            trip.Expenses.Add(expense);
            SaveTrip(trip);

        }
Esempio n. 4
0
 public void SaveTrip(Trip trip)
 {
     if (trip == null) return;
     // If a trip is already present, Remove & add. Works like update
     if (GetTrip(trip.Id) != null)
         _trips.Remove(trip);
     _trips.Add(trip);
     SaveTrips();
 }
		/// <summary>
		/// Initializes a new instance of the <see cref="TripXpense.iPhone.EditTripScreenController"/> class.
		/// </summary>
		/// <param name="trip">Trip.</param>
		public EditTripScreenController (Trip selectedTrip)
		{
			string title = "add";
			if (selectedTrip == null) {
				this.trip = new Trip () { StartDate = DateTime.Now, EndDate = DateTime.Now };
			} else {
				this.trip = selectedTrip;
				title = "edit";
			}
			this.Title = string.Format ("{0} trip", title);
		}
Esempio n. 6
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.EditExpense);

            var tripId = Intent.GetStringExtra("SelectedTripId");

            _trip = new TripManager().GetTrip(new Guid(tripId));
            var expenseId = Intent.GetStringExtra("SelectedExpenseId");

            if (!string.IsNullOrEmpty(expenseId))
                _expense = _trip.Expenses.FirstOrDefault((x) => x.Id == new Guid(expenseId));
            else
            {
                _expense = new Expense() {Date = DateTime.Now};
            }

            FindViewById<Button>(Resource.Id.editExpenseButtonSave).Click += (s, e) =>
            {
                UpdateExpense();
                new TripManager().SaveExpense(_trip, _expense);

                var intent = new Intent(this, typeof(ViewTripDetailScreen));
                intent.PutExtra("SelectedTripId", _trip.Id.ToString());

                base.StartActivity(intent);
            };

            FindViewById<Button>(Resource.Id.editExpenseButtonDelete).Click += (s, e) =>
            {
                
                new TripManager().RemoveExpense(_trip, _expense);

                var intent = new Intent(this, typeof(ViewTripDetailScreen));
                intent.PutExtra("SelectedTripId", _trip.Id.ToString());
                base.StartActivity(intent);
            };

            UpdateUI();
        }
		public EditTripScreenView (RectangleF frame, Trip trip)
		{
			//this.Frame = frame;

			_scrollView = new UIScrollView (frame);
			this.BackgroundColor = UIColor.White;

			_tripNameTextField = new UITextField () { 
				Placeholder = "Trip Name",
				BorderStyle = UITextBorderStyle.RoundedRect,
			};

			_tripNameTextField = new UITextField () { 
				Placeholder = "trip name",
				BorderStyle = UITextBorderStyle.None,
				Font = UIFont.FromName("AvenirNext-Medium", 16f),
				TextColor = UIColor.Black,
				BackgroundColor = UIColor.White
			};

			_btnStartDate = UIButton.FromType (UIButtonType.Custom);
			_btnStartDate.SetTitle ("from Wednessday, Jul 17, 2013", UIControlState.Normal);
			_btnStartDate.SetTitleColor (UIColor.White, UIControlState.Normal);
			_btnStartDate.SetTitleColor (UIColor.LightGray, UIControlState.Highlighted);
			_btnStartDate.Font = UIFont.FromName ("AvenirNext-Medium", 16f);



			actionSheetDatePickerStartDate = new ActionSheetDatePicker (this);
			actionSheetDatePickerStartDate.Title = "Choose Date:";
			actionSheetDatePickerStartDate.DatePicker.Mode = UIDatePickerMode.Date;
			actionSheetDatePickerStartDate.DatePicker.ValueChanged += (sender, e) => {
				DateTime selectedDate = (sender as UIDatePicker).Date;
				_btnStartDate.SetTitle(selectedDate.ToString("D"), UIControlState.Normal); 
			};

			_btnStartDate.TouchUpInside += (sender, e) => {
				actionSheetDatePickerStartDate.Show(); 
			};

			_btnEndDate = UIButton.FromType (UIButtonType.Custom);
			_btnEndDate.SetTitle ("to Wednessday, Jul 17, 2013", UIControlState.Normal);
			_btnEndDate.SetTitleColor (UIColor.White, UIControlState.Normal);
			_btnEndDate.SetTitleColor (UIColor.LightGray, UIControlState.Highlighted);
			_btnEndDate.Font = UIFont.FromName ("AvenirNext-Medium", 16f);

			_btnEndDate.TouchUpInside += (sender, e) => {
				actionSheetDatePickerEndDate.Show();
			};
			actionSheetDatePickerEndDate = new ActionSheetDatePicker (this);
			actionSheetDatePickerEndDate.Title = "Choose Date:";
			actionSheetDatePickerEndDate.DatePicker.Mode = UIDatePickerMode.Date;
			actionSheetDatePickerEndDate.DatePicker.ValueChanged += (sender, e) => {
				DateTime selectedDate = (sender as UIDatePicker).Date;
				_btnEndDate.SetTitle(selectedDate.ToString("D"), UIControlState.Normal); 
			};


			_tripDescTextField = new UITextView () { 
				Font = UIFont.FromName("AvenirNext-Medium", 16f),
				TextColor = UIColor.Black,
				BackgroundColor = UIColor.White,
				Text = "Desc"
			};


			_tripBudgetTextField = new UITextField () { 
				Placeholder = "budget",
				BorderStyle = UITextBorderStyle.None,
				Font = UIFont.FromName("AvenirNext-Medium", 16f),
				TextColor = UIColor.Black,
				BackgroundColor = UIColor.White,
				KeyboardType = UIKeyboardType.NumberPad
			};

			ButtonExpenses = UIButton.FromType (UIButtonType.RoundedRect);
			ButtonExpenses.SetTitle ("expenses", UIControlState.Normal);


			ButtonDeleteTrip = UIButton.FromType (UIButtonType.RoundedRect);
			ButtonDeleteTrip.SetTitle ("delete trip", UIControlState.Normal);

			_tripNameTextField.SizeToFit ();
			_btnStartDate.SizeToFit ();
			_btnEndDate.SizeToFit ();
			_tripDescTextField.SizeToFit ();
			_tripBudgetTextField.SizeToFit ();
			ButtonExpenses.SizeToFit ();

			ButtonDeleteTrip.SizeToFit();

			_tripNameTextField.ShouldReturn += (t) => {
				t.ResignFirstResponder();
				return true;
			};


			// set content size to default for now
			//TODO: implement observer and set accordingly
			_scrollView.ContentSize = new SizeF (frame.Width, frame.Height);

			_scrollView.AddSubviews (_tripNameTextField, _btnStartDate, 
			                         _btnEndDate, _tripDescTextField,
			                         _tripBudgetTextField, ButtonExpenses, ButtonDeleteTrip);

			_scrollView.SizeToFit ();
			_scrollView.BackgroundColor = this.BackgroundColor = UIColor.DarkGray;

			this.AddSubview ( _scrollView);
		}
Esempio n. 8
0
 public void RemoveExpense(Trip trip, Expense expense)
 {
     trip.Expenses.Remove(expense);
     SaveTrip(trip);
 }
Esempio n. 9
0
 public void RemoveTrip(Trip trip)
 {
     if (trip != null)
         _trips.Remove(trip);
     SaveTrips();
 }
Esempio n. 10
0
 public void RemoveExpense(Trip trip, Expense expense)
 {
     _tripRepository.RemoveExpense(trip, expense);
 }
Esempio n. 11
0
 public void SaveExpense(Trip trip, Expense expense)
 {
     _tripRepository.SaveExpense(trip, expense);
 }
Esempio n. 12
0
 public void RemoveTrip(Trip trip)
 {
     _tripRepository.RemoveTrip(trip);
 }
Esempio n. 13
0
 public void SaveTrip(Trip trip)
 {
     _tripRepository.SaveTrip(trip);
 }