Ejemplo n.º 1
0
        public DVCLogIn()
            : base(UITableViewStyle.Grouped, null, true)
        {
            loginView = new FBLoginView (ExtendedPermissions);

            if (UIDevice.CurrentDevice.CheckSystemVersion (7, 0)) {
                loginView.Frame = new RectangleF (51, 0, 218, 46);
            } else {
                loginView.Frame = new RectangleF (40, 0, 218, 46);
            }

            loginView.FetchedUserInfo += (sender, e) => {
                if (Root.Count < 3) {
                    user = e.User;
                    pictureView.ProfileID = user.Id;

                    Root.Add (new Section ("Hello " + user.Name) {
                        new StringElement ("Actions Menu", () => {
                            var dvc = new DVCActions (user);
                            NavigationController.PushViewController (dvc, true);
                        }) {
                            Alignment = UITextAlignment.Center
                        }
                    });
                }
            };
            loginView.ShowingLoggedOutUser += (sender, e) => {
                pictureView.ProfileID = null;
                if (Root.Count >= 3) {
                    InvokeOnMainThread (() => {
                        var section = Root [2];
                        section.Remove (0);
                        Root.Remove (section);
                        ReloadData ();
                    });
                }
            };

            pictureView = new FBProfilePictureView () ;

            if (UIDevice.CurrentDevice.CheckSystemVersion (7,0)) {
                pictureView.Frame = new RectangleF (50, 0, 220, 220);
            }
            else {
                pictureView.Frame = new RectangleF (40, 0, 220, 220);
            }

            Root = new RootElement ("Facebook Sample") {
                new Section () {
                    new UIViewElement ("", loginView, true) {
                        Flags = UIViewElement.CellFlags.DisableSelection | UIViewElement.CellFlags.Transparent,
                    }
                },
                new Section () {
                    new UIViewElement ("", pictureView, true) {
                        Flags = UIViewElement.CellFlags.DisableSelection | UIViewElement.CellFlags.Transparent,
                    },
                }
            };
        }
Ejemplo n.º 2
0
        public DVCActions(FBGraphUser facebookUser)
            : base(UITableViewStyle.Grouped, null, true)
        {
            this.user = facebookUser;

            pictureView = new FBProfilePictureView () {
                ProfileID = user.Id
            };

            if (UIDevice.CurrentDevice.CheckSystemVersion (7,0)) {
                pictureView.Frame = new RectangleF (120, 0, 80, 80);
            }
            else {
                pictureView.Frame = new RectangleF (110, 0, 80, 80);
            }

            Root = new RootElement ("Menu") {
                new Section (){
                    new UIViewElement ("", pictureView, true) {
                        Flags = UIViewElement.CellFlags.DisableSelection | UIViewElement.CellFlags.Transparent,
                    }
                },
                new Section () {
                    new StringElement (user.Name) {
                        Alignment = UITextAlignment.Center
                    }
                },
                new Section ("Actions") {
                    new StringElement ("Share Xamarin.com", ShareUrl) {
                        Alignment = UITextAlignment.Center
                    },
                    new StringElement ("FQL Sample - Show 25 friends", FQLSample) {
                        Alignment = UITextAlignment.Center
                    },
                    new StringElement ("Graph API Sample - Post \"Hello\"", GraphApiPost) {
                        Alignment = UITextAlignment.Center
                    },
                    new StringElement ("Graph API Sample - Delete \"Hello\"", GraphApiDeletePost) {
                        Alignment = UITextAlignment.Center
                    },
                    new StringElement ("Select Some Friends", FriendPicker) {
                        Alignment = UITextAlignment.Center
                    },
                    new StringElement ("Select a Place", PlacePicker) {
                        Alignment = UITextAlignment.Center
                    }
                }
            };
        }
Ejemplo n.º 3
0
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			this.Add (faceBookView);
			this.Add (facebookView2);

			iPhoneLocationManager = new CLLocationManager ();
			iPhoneLocationManager.DesiredAccuracy = CLLocation.AccuracyNearestTenMeters;
			iPhoneLocationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => {

			};
				
			iPhoneLocationManager.RequestAlwaysAuthorization ();
			if (CLLocationManager.LocationServicesEnabled) {
				iPhoneLocationManager.StartUpdatingLocation ();
			}
			#region observadores del teclado
			// Keyboard popup
			NSNotificationCenter.DefaultCenter.AddObserver
			(UIKeyboard.DidShowNotification,KeyBoardUpNotification);

			// Keyboard Down
			NSNotificationCenter.DefaultCenter.AddObserver
			(UIKeyboard.WillHideNotification,KeyBoardDownNotification);
			#endregion

			#region declaracion de vista de Facebook
			// Create the Facebook LogIn View with the needed Permissions
			// https://developers.facebook.com/ios/login-ui-control/
			loginView = new FBLoginView (ExtendedPermissions) {
				Frame = new CGRect (0,0,45, 45)
			};

			// Create view that will display user's profile picture
			// https://developers.facebook.com/ios/profilepicture-ui-control/

			pictureView = new FBProfilePictureView () {
				Frame = new CGRect (0, 0, 45, 45)
			};
			pictureView.UserInteractionEnabled = true;
			// Hook up to FetchedUserInfo event, so you know when
			// you have the user information available
			loginView.FetchedUserInfo += (sender, e) => {
				user = e.User;
				pictureView.ProfileID = user.GetId ();
				MainView.isWithFacebook = true;
				loginView.Alpha = 0.1f;
				pictureView.Hidden = false;
			};

			// Clean user Picture and label when Logged Out
			loginView.ShowingLoggedOutUser += (sender, e) => {
				pictureView.ProfileID = null;
				pictureView.Hidden = true;
				lblUserName.Text = string.Empty;
				loginView.Alpha = 1f;
				MainView.isWithFacebook = false;
			};
		
			this.faceBookView.Add(pictureView);
			this.faceBookView.Add(loginView);
			#endregion

			var documents = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
			_pathToDatabase = Path.Combine(documents, "db_sqlite-net.db");

			//Creamos la base de datos y la tabla de persona
			using (var conn= new SQLite.SQLiteConnection(_pathToDatabase))
			{
				conn.CreateTable<Person>();
				conn.CreateTable<State> ();
				conn.CreateTable<Terms> ();
				conn.CreateTable<PrivacyNotice> ();
			}

			using (var db = new SQLite.SQLiteConnection(_pathToDatabase ))
			{
				people = new List<Person> (from p in db.Table<Person> () select p);
				states = new List<State> (from s in db.Table<State> () select s);
				terms = new List<Terms> (from t in db.Table<Terms> ()select t);
				privacyNotices = new List<PrivacyNotice> (from pr in db.Table<PrivacyNotice> () select pr);
			}

			if(people.Count > 0){
				Person user = people.ElementAt(0);
				MainView.userId = user.ID;
				Console.WriteLine ("El Id de usuario es: "+ user.ID);
			}

			if(states.Count > 0){
				State estado = states.ElementAt(0);
				MainView.localityId = estado.localityId;
				Console.WriteLine ("El Id de localidad es: "+ estado.stateId);
			}
				
			//Boton para entrar al menu de la aplicacion.
			this.btnEntrar.TouchUpInside += (sender, e) => {
				scanView = new ScanView();
				this.NavigationController.PushViewController(scanView, true);
			};

			this.btnListas.TouchUpInside += (sender, e) => {
				using (var db = new SQLite.SQLiteConnection(_pathToDatabase ))
				{
					people = new List<Person> (from p in db.Table<Person> () select p);
				}
				if(people.Count > 0){
					MyListsView mylists = new MyListsView();
					this.NavigationController.PushViewController(mylists,true);
				}else{
					UIAlertView alert = new UIAlertView () { 
						Title = "Espera!", Message = "Debes iniciar sesion para acceder a tus listas"
					};
					alert.AddButton ("Aceptar");
					alert.Show ();
				}
			};

			//Boton para hacer busqueda por nombre de producto
			this.btnBuscar.TouchUpInside += (sender, e) => {
				if(this.cmpNombre.Text == ""){
					UIAlertView alert = new UIAlertView () { 
						Title = "Espera!", Message = "Debes ingresar el nombre del producto a buscar"
					};
					alert.AddButton ("Aceptar");
					alert.Show ();
				}
				else if (states.Count < 1){
					UIAlertView alert = new UIAlertView () { 
						Title = "Espera!", Message = "Debes seleccionar tu ubicacion antes de comenzar a usar FixBuy, por favor ingresa " +
							"Al menu de opciones para establecerla"
					};
					alert.AddButton ("Aceptar");
					alert.Clicked += (s, o) => {
						StatesView statesView = new StatesView();
						this.NavigationController.PushViewController(statesView, true);
					};
					alert.Show ();
				}
				else{
					this._loadPop = new LoadingOverlay (UIScreen.MainScreen.Bounds);
					this.View.Add ( this._loadPop );
					this.cmpNombre.ResignFirstResponder();
					Task.Factory.StartNew (
						() => {
							System.Threading.Thread.Sleep ( 1 * 1000 );
						}
					).ContinueWith ( 
						t => {
							nsr = new NameSearchResultView();
							nsr.setProductName(this.cmpNombre.Text.Trim());
							this.NavigationController.PushViewController(nsr,true);
							this._loadPop.Hide ();
						}, TaskScheduler.FromCurrentSynchronizationContext()
					);
				}
			};

			this.cmpNombre.ShouldReturn += (textField) => {
				if(this.cmpNombre.Text == ""){
					UIAlertView alert = new UIAlertView () { 
						Title = "Espera!", Message = "Debes ingresar el nombre del producto a buscar"
					};
					alert.AddButton ("Aceptar");
					alert.Show ();
				}
				else if (states.Count < 1){
					UIAlertView alert = new UIAlertView () { 
						Title = "Espera!", Message = "Debes seleccionar tu ubicacion antes de comenzar a usar FixBuy, por favor ingresa " +
							"Al menu de opciones para establecerla"
					};
					alert.AddButton ("Aceptar");
					alert.Clicked += (s, o) => {
						StatesView statesView = new StatesView();
						this.NavigationController.PushViewController(statesView, true);
					};
					alert.Show ();
				}
				else{
					this._loadPop = new LoadingOverlay (UIScreen.MainScreen.Bounds);
					this.View.Add ( this._loadPop );
					this.cmpNombre.ResignFirstResponder();
					Task.Factory.StartNew (
						() => {
							System.Threading.Thread.Sleep ( 1 * 1000 );
						}
					).ContinueWith ( 
						t => {
							nsr = new NameSearchResultView();
							nsr.setProductName(this.cmpNombre.Text.Trim());
							this.NavigationController.PushViewController(nsr,true);
							this._loadPop.Hide ();
						}, TaskScheduler.FromCurrentSynchronizationContext()
					);
				} 
				return true; 
			};

			//Boton para iniciar el escaner de codigo de barras
			this.btnCodigo.TouchUpInside += (sender, e) => {
				if(states.Count > 0){
					// Configurar el escaner de codigo de barras.
					picker = new ScanditSDKRotatingBarcodePicker (appKey);
					picker.OverlayController.Delegate = new overlayControllerDelegate(picker, this);
					picker.OverlayController.ShowToolBar(true);
					picker.OverlayController.ShowSearchBar(true);
					picker.OverlayController.SetToolBarButtonCaption("Cancelar");
					picker.OverlayController.SetSearchBarKeyboardType(UIKeyboardType.Default);
					picker.OverlayController.SetSearchBarPlaceholderText("Búsqueda por nombre de producto");
					picker.OverlayController.SetCameraSwitchVisibility(SICameraSwitchVisibility.OnTablet);
					picker.OverlayController.SetTextForInitializingCamera("Iniciando la camara");
					this.PresentViewController (picker, true, null);
					picker.StartScanning ();
				}else{
					UIAlertView alert = new UIAlertView () { 
						Title = "Espera!", Message = "Debes seleccionar tu ubicacion antes de comenzar a usar FixBuy, por favor ingresa " +
							"Al menu de opciones para establecerla"
					};
					alert.AddButton ("Aceptar");
					alert.Clicked += (s, o) => {
						StatesView statesView = new StatesView();
						this.NavigationController.PushViewController(statesView, true);
					};
					alert.Show ();
				}
			};
		}