public EventListView(Group grp)
		{
			InitializeComponent();
			group = grp;
			currentView = 5;
			setUp();
		}
Example #2
0
		public async Task<Group> CreateEditGroup(Group grp)
		{
			var uri = "";
			var content = JsonConvert.SerializeObject(grp);
			List<Group> groups = await PostGroupServerCall(uri, content);
			if (groups == null || groups.Count == 0) return null;
			return groups[0];
		}
Example #3
0
		//Design design = Design.ShowAll;

		public GroupDesignView(Group group, int dims, Design design) : base(dims)
		{
			this.group = group;
			try
			{
				SetInfo(group.ImageSource, group.Name, group.Description, design, ModelType.Group);
			}
			catch (Exception ex) { }

			subjBtn.Clicked += (sender, e) => { 
				if (dims >= 200)
				{
					OtherFunctions of = new OtherFunctions();
					of.ViewImages(new List<string>() { group.ImageSource });
					//subjBtn.Clicked += (sender, e) => { App.coreView.setContentViewReplaceCurrent(new InspectController(group), 1); };
				}
				else {
					App.coreView.setContentViewWithQueue(new InspectController(group));
				}
			};

			setInfo(dims);
		}
		public ProfileDesignView(Profile profile, Group grpInvitingTo, int dims) : base(dims)
		{
			this.profile = profile;
			design = Design.NameAndButtons;
			SetupButtons(true);
			if (grpInvitingTo.ProfilesRequestingToJoin.Exists(p => p.ProfileId == profile.ProfileId))
			{
				HandleButtonRequests(delegate ()
				{
					return _dataManager.GroupApiManager.InviteDeclineToGroup(grpInvitingTo.GroupId, true, new List<Profile> { profile });
				}, addBtn, "Accept", "Acceptd");
				HandleButtonRequests(delegate ()
				{
					return _dataManager.GroupApiManager.InviteDeclineToGroup(grpInvitingTo.GroupId, false, new List<Profile> { profile });
				}, removeBtn, "Decline", "Declined");
			} else  if (!grpInvitingTo.Members.Exists(p => p.ProfileId == profile.ProfileId))
			{
				HandleButtonRequests(delegate ()
				{
					return _dataManager.GroupApiManager.InviteDeclineToGroup(grpInvitingTo.GroupId, true, new List<Profile> { profile });
				}, addBtn, "Invite", "Invited");
			}
			setPillButtonLayout(new List<Button>() {addBtn, removeBtn });
		}
Example #5
0
		async void setInfo(int dims)
		{
			if(group != null)group = await new DataManager().GroupApiManager.GetGroup(group.GroupId);
			try
			{
				if (App.coreView._dataManager.AreYouGroupOwner(group))
				{
					/*
					editBtn.IsVisible = true;
					editBtn.Text = "Edit";
					editBtn.Clicked += (sender, e) =>
					{
						App.coreView.setContentViewWithQueue(new CreateGroup(group, false));
					};

					addBtn.IsVisible = true;
					addBtn.Text = "Invite";
					addBtn.Clicked += (sender, e) =>
					{
						App.coreView.setContentViewWithQueue(new InviteListView(group, false));
					};

					removeBtn.IsVisible = true;
					removeBtn.Text = "Invite as owner";
					removeBtn.Clicked += (sender, e) =>
					{
						App.coreView.setContentViewWithQueue(new InviteListView(group, true));
					}; */
					/*
					if (group.OrganizationOwner != null)
					{
						if (group.Members.Exists(p => p.ProfileId == App.StoredUserFacebookId))
						{
							removeBtn.IsVisible = true;
							removeBtn.Text = "Leave";
							removeBtn.Clicked += async (sender, e) =>
							{
								await _dataManager.GroupApiManager.RequestAcceptDeclineLeaveGroup(group.GroupId, GroupApiManager.GroupHandlingType.Leave);
								App.coreView.setContentViewWithQueue(new InspectController(group));
							};
						}
						else {
							removeBtn.IsVisible = true;
							removeBtn.Text = "Joine";
							removeBtn.Clicked += async (sender, e) =>
							{
								await _dataManager.GroupApiManager.RequestAcceptDeclineLeaveGroup(group.GroupId, GroupApiManager.GroupHandlingType.Request);
								App.coreView.setContentViewWithQueue(new InspectController(group));
							};
						}

					}
					*/
				}
				else if (App.userProfile.GroupsInviteTo.Exists(g => g.GroupId == group.GroupId) || App.userProfile.GroupsInviteToAsOwner.Exists(g => g.GroupId == group.GroupId))
				{
					bool owner = false;
					if (App.userProfile.GroupsInviteToAsOwner.Exists(g => g.GroupId == group.GroupId)) { owner = true;}

					addBtn.IsVisible = true;
					addBtn.Text = "Accept";
					addBtn.Clicked += async (sender, e) =>
					{
						if (owner)
						{
							await _dataManager.GroupApiManager.RequestAcceptDeclineLeaveGroupAsOwner(group.GroupId, OwnerHandlingType.Accept);
						} else {
							await _dataManager.GroupApiManager.RequestAcceptDeclineLeaveGroup(group.GroupId, GroupApiManager.GroupHandlingType.Accept);
						}
						await _dataManager.ProfileApiManager.GetLoggedInProfile();
						if (dims >= 200)
						{
							App.coreView.setContentViewReplaceCurrent(new InspectController(group), 1);
						}
						else {
							//addBtn.IsEnabled = false;
							//removeBtn.IsVisible = false;
							App.coreView.setContentView(4);
						}
					};
					removeBtn.IsVisible = true;
					removeBtn.Text = "Decline";
					removeBtn.Clicked += async (sender, e) =>
					{
						if (owner)
						{
							await _dataManager.GroupApiManager.RequestAcceptDeclineLeaveGroupAsOwner(group.GroupId, OwnerHandlingType.Decline);
						}
						else {
							await _dataManager.GroupApiManager.RequestAcceptDeclineLeaveGroup(group.GroupId, GroupApiManager.GroupHandlingType.Decline);
						}
						await _dataManager.ProfileApiManager.GetLoggedInProfile();
						if (dims >= 200)
						{
							App.coreView.setContentView(4);
						}
						else {
							//removeBtn.IsEnabled = false;
							//addBtn.IsVisible = false;
							App.coreView.setContentView(4);
						}
					};
					setPillButtonLayout(new List<Button>() { addBtn, removeBtn });
				}
				/*
				else if (App.userProfile.Groups.Exists(g => g.GroupId == group.GroupId))
				{
					removeBtn.IsVisible = true;
					removeBtn.Text = "Leave";
					removeBtn.Clicked += async (sender, e) =>
					{
						await _dataManager.GroupApiManager.RequestAcceptDeclineLeaveGroup(group.GroupId, GroupApiManager.GroupHandlingType.Leave);
						await _dataManager.ProfileApiManager.GetLoggedInProfile();
						App.coreView.setContentView(4);
					};
				} */
				else if (!App.userProfile.Groups.Exists(g => g.GroupId == group.GroupId))
				{
					addBtn.IsVisible = true;
					addBtn.Text = "Join";
					addBtn.Clicked += async (sender, e) =>
					{
						await _dataManager.GroupApiManager.RequestAcceptDeclineLeaveGroup(group.GroupId, GroupApiManager.GroupHandlingType.Request);
						await _dataManager.ProfileApiManager.GetLoggedInProfile();
						if (dims >= 200)
						{
							App.coreView.setContentViewReplaceCurrent(new InspectController(group), 1);
						}
						else {
							App.coreView.setContentView(4);
						}
					};
				}
			}
			catch (Exception ex) {}
		}
Example #6
0
		public CreateGroup (Group group, bool isCreate)
		{
			_dataManager = new DataManager ();
			InitializeComponent ();
			newGroup = group;
			if (isCreate) {
				cancelButton.IsVisible = false;
				newGroup.GroupId = "0";
			}
			else {
				setEditEvent();
			}

			title.TextChanged += (sender, e) => { newGroup.Name = title.Text; };
			description.TextChanged += (sender, e) => { newGroup.Description = description.Text; };

			// Here's the visibility of the group selected
			visibilityPicker.SelectedIndexChanged += (sender, e) =>
			{
				if (visibilityPicker.SelectedIndex == 0) { newGroup.Visibility = GroupVisibility.Public; }
				if (visibilityPicker.SelectedIndex == 1) { newGroup.Visibility = GroupVisibility.Closed; }
				if (visibilityPicker.SelectedIndex == 2) { newGroup.Visibility = GroupVisibility.Private; }
				visibilityString.Text = visibilityPicker.Items[visibilityPicker.SelectedIndex];
			};
			visibilityString.Text = visibilityPicker.Title;

			var pictureImage = new TapGestureRecognizer();
			pictureImage.Tapped += async (sender, e) =>
			{
				try
				{
					imageStreams = await _dataManager.UtilityManager.PictureFromAlbum(SelectedBannerImage.Source);
				}
				catch (Exception ex) { }
			};
			takePictureButton.GestureRecognizers.Add(pictureImage);

			var albumImage = new TapGestureRecognizer();
			albumImage.Tapped += async (SenderOfEvent, e) =>
			{
				try
				{
					imageStreams = await _dataManager.UtilityManager.PictureFromAlbum(SelectedBannerImage.Source);
				}
				catch (Exception ex) { }
			};
			albumPictureButton.GestureRecognizers.Add(albumImage);

			selectBannerButton.Clicked += (sender, e) => {
				SelectBannerView selectBannerView = new SelectBannerView();
				selectBannerView.createGroupView = this;
				App.coreView.setContentViewWithQueue(selectBannerView);
			};



			launchButton.Clicked += (sender, e) => {
				if (isCreate && !Launching)
				{
					LaunchGroup(newGroup);
					Launching = true;
				}
				else if (!isCreate && !Launching)
				{
					LaunchGroup(newGroup);
				}
			};

			cancelButton.Clicked += (sender, e) => {
				DeleteGroup(group);
			};
		}
Example #7
0
		/*
		private async void UpdateGroup(Group groupToUpdate)
		{
			if (mediaFile != null)
			{
				groupToUpdate.ImageSource = await _dataManager.UtilityManager.UploadImageToStorage(mediaFile.GetStream(), App.StoredUserFacebookId + "." + DateTime.Now.ToString("G"));
			}

			var groupUpdated = await _dataManager.GroupApiManager.CreateEditGroup(groupToUpdate);

			if (groupUpdated != null) {
				InspectController inspect = new InspectController(groupUpdated);
				App.coreView.setContentViewWithQueue(inspect, "Group", inspect.getScrollView());
			} else {
				await App.coreView.displayAlertMessage ("Error", "Group not updated, try again", "Ok");
			}
		}
		*/

		public async void DeleteGroup(Group groupToDelete)
		{
			bool confirmDelete = await App.coreView.displayConfirmMessage ("Warning", "You are about to delete this group permanently, would you like to continue", "Yes", "No");

			if (confirmDelete) {
				bool groupDeleted = await _dataManager.GroupApiManager.DeleteGroup (groupToDelete.GroupId);
				if (groupDeleted) {
					await App.coreView.displayAlertMessage ("Group Deleted", "The group was successfully deleted", "Ok");
					App.coreView.setContentView (2);
				} else {
					App.coreView.displayAlertMessage ("Group Not Deleted", "The group was not deleted, try again", "Ok");
				}
			}
		}
Example #8
0
		private async void LaunchGroup(Group groupToCreate)
		{
			App.coreView.IsLoading(true);
			if (imageStreams != null)
			{
				groupToCreate.ImageSource = await _dataManager.UtilityManager.UploadImageToStorage(new MemoryStream(imageStreams[1]), App.StoredUserFacebookId + "." + DateTime.Now.ToString("G"));
			}
			groupToCreate.ProfileOwners = new List<Profile> {  new Profile() { ProfileId = App.userProfile.ProfileId, } };

			if (String.IsNullOrWhiteSpace(groupToCreate.Name))
			{
				await App.coreView.displayAlertMessage("Name Missing", "Name is missing", "Ok");
			}
			else if (String.IsNullOrWhiteSpace(groupToCreate.Description))
			{
				await App.coreView.displayAlertMessage("Description Missing", "Description is missing", "Ok");
			}
			else if (String.IsNullOrWhiteSpace(groupToCreate.ImageSource))
			{
				await App.coreView.displayAlertMessage("Banner Missing", "No banner has been selected", "Ok");
			}
			else {
				
				var groupCreated = await _dataManager.GroupApiManager.CreateEditGroup(groupToCreate);

				if (groupCreated != null)
				{
					InspectController inspect = new InspectController(groupCreated);
					App.coreView.setContentViewWithQueue(inspect);
					App.coreView.updateHomeView();
					App.coreView.createGroup = new CreateGroup(new Group(), true);
					App.coreView.updateCreateViews();
				}
				else {
					await App.coreView.displayAlertMessage("Error", "Event not created, try again", "Ok");
				}
			}
			Launching = false; 
			App.coreView.IsLoading(false);
		}
		public InviteListView(Group grp, bool owner)
		{
			InitializeComponent();
			if (owner)
			{
				foreach (Profile p in grp.ProfileOwners)
				{
					profilesThatCanBeAdded.Remove(profilesThatCanBeAdded.Find(r => r.ProfileId == p.ProfileId));
				}
			}
			else {
				foreach (Profile p in grp.Members)
				{
					profilesThatCanBeAdded.Remove(profilesThatCanBeAdded.Find(r => r.ProfileId == p.ProfileId));
				}
			}

			setup();
			addBtn.Clicked += async (sender, e) =>
			{
				if (profilesAdded.Count > 0)
				{
					bool success = false;
					if (owner)
					{
						await _dataManager.GroupApiManager.InviteToGroupAsOwner(grp.GroupId, profilesAdded);
					}
					else {
						await _dataManager.GroupApiManager.InviteDeclineToGroup(grp.GroupId, true, profilesAdded);
					}
					if (success)
					{
						App.coreView.returnToPreviousView();
					}
					else {
						App.coreView.displayAlertMessage("Error", "Error inviting.", "Ok");
					}
				}
			};

		}
		public async Task<Group> createList(List<Profile> profiles, List<Group> groups,
		                       Event eventInvitingTo, Group groupInvitingTo, bool preview, bool buttons, bool returnClick)
		{
			thisGrid.Children.Clear();
			thisGrid.RowDefinitions.Clear();
			thisGrid.ColumnDefinitions.Clear();
			Grid grid = thisGrid;

			TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>();
			Group clickedGroup = null;

			GenericDesignView.Design design = GenericDesignView.Design.Name;

			int height = 0;
			int newRowValue = 3;
			if (buttons)
			{
				design = GenericDesignView.Design.NameAndButtons;
				newRowValue = 3;
				height = 100;
			}
			else {
				newRowValue = 4;
				height = 75;
			}
			float rowHeight = height * 1.3f;
			int column = 0;
			int row = 0;
			int count = 0;

			if (!preview && !buttons)
			{
				findFriendsBtn.Clicked += (sender, e) =>
				{
					App.coreView.setContentViewWithQueue(new FindNewFriendsView(0));
				};
			}

			grid.Children.Clear();

			if (profiles != null)
			{
				count = profiles.Count;
			}
			else if (groups != null)
			{
				count = groups.Count;
			}

			grid.RowDefinitions.Add (new RowDefinition{ Height = rowHeight });

			for (int i = 0; i < count; i++)
			{
				if (column == newRowValue)
				{
					column = 0;
					row++;
					grid.RowDefinitions.Add(new RowDefinition { Height = rowHeight });
				}
				Grid cell = new Grid();

				if (profiles != null)
				{
					if (eventInvitingTo != null)
					{
						cell.Children.Add(new ProfileDesignView(profiles[i], eventInvitingTo, height), 0, 0);
					}
					else if (groupInvitingTo != null)
					{
						cell.Children.Add(new ProfileDesignView(profiles[i], groupInvitingTo, height), 0, 0);
					}
					else {
						cell.Children.Add(new ProfileDesignView(profiles[i], height, true, design), 0, 0);
					}
				}
				else if (groups != null)
				{
					cell.Children.Add(new GroupDesignView(groups[i], height, design), 0, 0);
				}

				grid.Children.Add(cell, column, row);
				if(returnClick) {
					Button clickedGroupBtn = new Button() { };
					Group clickedGrp = groups[i];
					grid.Children.Add(clickedGroupBtn, column, row);

					clickedGroupBtn.Clicked += (sender, e) =>
					{
						clickedGroup = clickedGrp;
						tcs.TrySetResult(true);
					};
				}
				column ++;

				if (preview && count > newRowValue && i == (newRowValue-2))
				{
					Button b = new Button() { BackgroundColor = App.HowlOut, HeightRequest = height, WidthRequest = height, Text="more", TextColor=Color.White, BorderRadius=height / 2};
					Grid g = new Grid() { RowSpacing=0 };
					g.RowDefinitions.Add(new RowDefinition { Height = 1});
					g.RowDefinitions.Add(new RowDefinition { Height = height });
					g.ColumnDefinitions.Add(new ColumnDefinition { Width = height });
					Grid g2 = new Grid();
					g.Children.Add(b,0,1);
					g2.Children.Add(g);
					grid.Children.Add(g2, column, row);
					b.Clicked += (sender, e) =>
					{
						App.coreView.setContentViewWithQueue(new ListsAndButtons(profiles, groups, false, buttons));
					};

					break;
				}
			}

			if (returnClick)
			{
				await tcs.Task;
			}
			return clickedGroup;
		}
		public ListsAndButtons(List<Profile> profiles, List<Group> groups,
							   Event eventInvitingTo, Group groupInvitingTo)
		{
			InitializeComponent();
			createList(profiles, groups, eventInvitingTo, groupInvitingTo, true, true, false);
		}
		async void addGroupMenu(Group grp)
		{
			App.coreView.topBar.setRightButton("ic_menu.png").Clicked += async (sender, e) =>
			{
				List<Action> actions = new List<Action>();
				List<string> titles = new List<string>();
				List<string> images = new List<string>();

				if (grp.ProfileOwners.Exists(p => p.ProfileId == App.userProfile.ProfileId))
				{
					actions.Add(() => { App.coreView.setContentViewWithQueue(new CreateGroup(grp, false)); });
					titles.Add("Edit");
					images.Add("ic_settings.png");

					actions.Add(() => { App.coreView.setContentViewWithQueue(new InviteListView(grp, false)); });
					titles.Add("Invite Members");
					images.Add("ic_settings.png");

					actions.Add(() => { App.coreView.setContentViewWithQueue(new InviteListView(grp, true)); });
					titles.Add("Invite Owners");
					images.Add("ic_settings.png");

					if (grp.ProfileOwners.Count > 1)
					{
						actions.Add(async () => { await _dataManager.GroupApiManager.RequestAcceptDeclineLeaveGroupAsOwner(grp.GroupId, OwnerHandlingType.Leave); });
						titles.Add("Leave");
						images.Add("ic_settings.png");
					}

					await App.coreView.DisplayOptions(actions, titles, images);
				}
				else if (grp.Members.Exists(p => p.ProfileId == App.userProfile.ProfileId))
				{
					actions.Add(async() => { 
						bool success = await _dataManager.GroupApiManager.RequestAcceptDeclineLeaveGroup(grp.GroupId, GroupApiManager.GroupHandlingType.Leave);
						if (success) { App.coreView.setContentView(4); }
						else { await App.coreView.displayAlertMessage("Error", "Error", "Ok"); }
					});
					titles.Add("Leave");
					images.Add("ic_settings.png");

					await App.coreView.DisplayOptions(actions, titles, images);
				}




			};
		}
		async void SetGroupInspect(Group userGroup)
		{
			try
			{
				this.grp = userGroup;
				userGroup = await _dataManager.GroupApiManager.GetGroup(userGroup.GroupId);
				this.grp = userGroup;
				addGroupMenu(userGroup);

				infoView.Content = new GroupDesignView(userGroup, 200, GenericDesignView.Design.ShowAll);
				infoView.Padding = new Thickness(0, 10, 0, 0);

				if (_dataManager.AreYouGroupMember(userGroup))
				{
					if (userGroup.ProfilesRequestingToJoin.Count > 0)
					{
						addNewElement(new ListsAndButtons(userGroup.ProfilesRequestingToJoin, null, null, userGroup), "Requesting To Join", userGroup.ProfilesRequestingToJoin.Count);
					}

					addNewElement(new ListsAndButtons(userGroup.ProfileOwners, null, true, false), "Owners", userGroup.ProfileOwners.Count);
					if (userGroup.Members.Count > 0)
					{
						addNewElement(new ListsAndButtons(userGroup.Members, null, true, false), "Members", userGroup.Members.Count);
					}

					if (userGroup.NumberOfActiveEvents > 0) addNewElement(new EventListView(userGroup), "Events", userGroup.NumberOfActiveEvents);
					StackLayout wall = new StackLayout();
					conversationView = new ConversationView(userGroup.Comments, MessageApiManager.CommentType.GroupComment, userGroup.GroupId, wall);
					wall.Children.Add(conversationView);
					addWallElement(wall, "Wall", userGroup.GroupId, ConversationModelType.Group);
				}
			}catch (Exception ex) {
				App.coreView.displayAlertMessage("Error", "Error loading content", "Ok");
				App.coreView.returnToPreviousView(); 
			}
		}
		public InspectController(Group userGroup)
		{
			InitializeComponent();
			if (userGroup != null)
			{
				Title = userGroup.Name;
				SetGroupInspect(userGroup);
				_dataManager.setUpdateSeen(userGroup.GroupId, NotificationModelType.Group);
			}
		}