-
Notifications
You must be signed in to change notification settings - Fork 58
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
Added date_input_widget #67
Conversation
Can you please stick to one item per PR? I don’t we should land separate widgets and layouts within the same PR. Is the HBox layout not kind of a duplicate of #64? |
I wanted to layout widget horizontally and can't find any other layout if it is same then reject it. One difference is this layout only expand horizontally. |
I will stick to one item per PR for now on. |
In that case, can you please update the PR (or open a new one id you prefer) that only includes one of the features? I do think that the layout in question indeed is mostly the same as the one linked above. I'll try it complete that PR some time in the future. The full list of layouts in Fyne can be found here: https://developer.fyne.io/explore/layouts |
okay let me just add the date input widget |
I have remove the layout code. |
Thanks. I'll try to review the code some day going forward |
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 had a quick glance over and a few things stood out.
Also can you add an item to the README with an image to show it in action please?
widget/widget_date_input.go
Outdated
|
||
const ConstDefaultDateFormat = "02-Jan-2006" | ||
|
||
var DayPos = []int{0, 2} |
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.
Should these fields be part of the public API?
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
widget/widget_date_input.go
Outdated
var MonthPos = []int{3, 6} | ||
var YearPos = []int{7, 11} | ||
|
||
type MyDateEntry struct { |
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 think naming here could 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.
okay
widget/widget_date_input.go
Outdated
// we assume 1st part is always Day | ||
// input = 1 -> 1-CurMonth-CurYear | ||
// input = 1.5, 1/5, 1-5 -> 1-5-CurYear | ||
func (e *MyDateEntry) parse_and_update_date() { |
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.
Try to match the Go style for naming - your other methods are formatted correctly. parseAndUpdateData
would be more in-keeping
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.
okay
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 will update naming as per go naming rule
I just came back to this (sorry for the delay) and notice that |
I have rewrite the whole widget this time using /richtext : https://github.com/heejit/fyne_codes/blob/main/widget_date_input.go |
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 the update. I just did a very quick code inspection on my phone and probably missed some things but I hope the review is helpful either way.
widget/widget_date_input.go
Outdated
var _ fyne.Tappable = (*JDateInputWidget)(nil) | ||
|
||
// Custom Date Input Widget using RichText | ||
type JDateInputWidget struct { |
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.
Someone using this will get widget.JDateInputWidget
which stutters. No need to say "widget" again. Also, what is the "J" for?
The README mentions DateEntry
so why not call it that (or DateInput)?
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 want to prefix my widget names with J no special meaning
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.
We need our APIs to be consistent and be easy to understand. I would suggest DateInput
.
widget/widget_date_input.go
Outdated
} | ||
|
||
func (t *JDateInputWidget) TypedRune(k rune) { | ||
// needed |
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.
Not needed? I know it is needed for the interface but the comment makes that unclear. If you don't need this method for anything other than satisfying the interface, you can just remove the comment
widget/widget_date_input.go
Outdated
|
||
// End: implement focusable interface | ||
|
||
// Start: implemnet Tappable |
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.
Should be "implement". This comment applies to more places
widget/widget_date_input.go
Outdated
} | ||
|
||
// constructor | ||
func NewJDateInputWidget(app fyne.App, window fyne.Window) *JDateInputWidget { |
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.
All exported functions and methods should have a comment describing if them. See already existing code in this repo for examples.
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.
The comments also need to follow the Go standard starting with the name of the function.
I wanted dateinputwidget to used via keyboard(arrow keys) that is why designed like that and if you already working on it then there is no need of this again. |
The keyboard input could be a great extension of what has landed in |
okay |
No description provided.