Praeclarum.UI.DocumentsViewController.HandleRenameRequested C# (CSharp) Method

HandleRenameRequested() private method

private HandleRenameRequested ( DocumentReference docRef, object arg2 ) : void
docRef Praeclarum.App.DocumentReference
arg2 object
return void
		void HandleRenameRequested (DocumentReference docRef, object arg2)
		{
			var name = docRef.Name;
			var dir = Path.GetDirectoryName (docRef.File.Path);
			var c = new TextInputController {
				Title = "Rename " + (docRef.File.IsDirectory ? "Folder" : DocumentAppDelegate.Shared.App.DocumentBaseName),
				InputText = name,
				ValidateFunc = n => DocumentAppDelegate.ValidateNewName (dir, n, docRef.Name),
			};

			var nc = new UINavigationController (c);
			nc.NavigationBar.BarStyle = DocumentAppDelegate.Shared.Theme.NavigationBarStyle;
			nc.ModalPresentationStyle = UIModalPresentationStyle.FormSheet;

			var presenter = this;

			c.Cancelled += (ss, ee) => presenter.DismissViewController (true, null);
			c.Done += async (ss, ee) => {
				presenter.DismissViewController (true, null);

				if (!string.IsNullOrWhiteSpace (c.InputText) && c.InputText != name) {
					await Rename (docRef, c.InputText);
				}
			};

			presenter.PresentViewController (nc, true, null);
		}