-
-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support custom code on file transfer by dropping onto the window #123
Support custom code on file transfer by dropping onto the window #123
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this. I have one idea for how we might want to do it instead.
internal/ui/tabs.go
Outdated
@@ -31,6 +31,8 @@ func Create(app fyne.App, window fyne.Window) *container.AppTabs { | |||
tabs.SelectIndex(0) | |||
} | |||
|
|||
send.client.CustomCode = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about instead bringing up a dialog asking the user just if they want to use a custom code or not?
Maybe even a setting to control if the user want the question to pop up or not? If the user says yes, we can set CustomCode = true
and the backend wouldn't have to know then if it is a drop or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing, would be consistent & intuitive too. Though I might need more time to explore Fyne though 😅 .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool. I think most of what needs doing should be similar to code that is already there. However, you are of course more than welcome to ask if you need any help :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Jacalz, I've made an update. Now when file is being dropped, a prompt is shown. But I can't set the CustomCode
properly back to false
after it's being set to true
:
confirm := dialog.NewConfirm("Create using custom code", "Create using custom code?", func(custom bool) {
send.client.CustomCode = custom
send.newTransfer(uris)
send.client.CustomCode = false // -> won't work because the newTransfer is being done concurrently (I guess)
}, window)
confirm.Show()
This will cause a side effect: the Use a custom code
tick will not be ticked but the state of the send.client.CustomCode
is still set to false.
So in order to mitigate this problem, I'm updating the state of the whole window, by newly creating it every time the Add content to send
button is tapped:
contentToSend := &widget.Button{Text: "Add content to send", Icon: theme.ContentAddIcon(), OnTapped: func() {
codeChoice := &widget.Check{Text: "Use a custom code", OnChanged: s.onCustomCode, Checked: s.client.CustomCode}
choiceContent := container.NewGridWithColumns(1, fileChoice, directoryChoice, textChoice, codeChoice)
s.contentPicker = dialog.NewCustom("Pick a content type", "Cancel", choiceContent, window)
s.contentPicker.Show()
}}
I'm not sure about the performance or how proper the behavior is, so kindly give feedbacks on this.
Many thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. The solution does look very good visually and from a usability standpoint. I will have a look at if the state problem you are talking about can be improved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just have a few suggestions :)
internal/ui/send.go
Outdated
contentToSend := &widget.Button{Text: "Add content to send", Icon: theme.ContentAddIcon(), OnTapped: func() { | ||
codeChoice := &widget.Check{Text: "Use a custom code", OnChanged: s.onCustomCode, Checked: s.client.CustomCode} | ||
choiceContent := container.NewGridWithColumns(1, fileChoice, directoryChoice, textChoice, codeChoice) | ||
s.contentPicker = dialog.NewCustom("Pick a content type", "Cancel", choiceContent, window) | ||
s.contentPicker.Show() | ||
}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be able to change back most of the code in this function and just update the state like this instead:
contentToSend := &widget.Button{Text: "Add content to send", Icon: theme.ContentAddIcon(), OnTapped: func() {
codeChoice.SetChecked(s.client.CustomCode)
s.contentPicker.Show()
}}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated, didn't know such simple function exists (and works well) 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem. I'll review this tomorrow and hopefully merge :)
internal/ui/tabs.go
Outdated
confirm := dialog.NewConfirm("Create using custom code", "Create using custom code?", func(custom bool) { | ||
send.client.CustomCode = custom | ||
send.newTransfer(uris) | ||
}, window) | ||
confirm.Show() | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be simplified (and we can avoid some duplicated wording):
confirm := dialog.NewConfirm("Create using custom code", "Create using custom code?", func(custom bool) { | |
send.client.CustomCode = custom | |
send.newTransfer(uris) | |
}, window) | |
confirm.Show() | |
}) | |
dialog.ShowConfirm("Custom Code", "Use a custom code?", func(custom bool) { | |
send.client.CustomCode = custom | |
send.newTransfer(uris) | |
}, window) | |
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the wait. Thanks for working on this. It looks great. I'll merge :)
Description:
When file is being dropped into the window, instead of using default generated code, a prompt is shown whether user wants to use his own or use the default (generated) code. The prompt is very similar when custom code option is ticked when trying to send the file using default
Add content to send
button.Example:
Fixes: #108
Checklist: