Skip to content
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

Closed
wants to merge 15 commits into from
Closed

Added date_input_widget #67

wants to merge 15 commits into from

Conversation

heejit
Copy link

@heejit heejit commented Jun 25, 2023

No description provided.

@Jacalz
Copy link
Member

Jacalz commented Jun 25, 2023

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?

@heejit
Copy link
Author

heejit commented Jun 25, 2023

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.

@heejit
Copy link
Author

heejit commented Jun 25, 2023

I will stick to one item per PR for now on.

@Jacalz
Copy link
Member

Jacalz commented Jun 25, 2023

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

@heejit
Copy link
Author

heejit commented Jun 25, 2023

okay let me just add the date input widget

@heejit
Copy link
Author

heejit commented Jun 25, 2023

I have remove the layout code.

@Jacalz
Copy link
Member

Jacalz commented Jun 25, 2023

Thanks. I'll try to review the code some day going forward

@andydotxyz andydotxyz changed the title Added date_input_widget and hbox_ratio_layout Added date_input_widget Jun 26, 2023
Copy link
Member

@andydotxyz andydotxyz left a 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?


const ConstDefaultDateFormat = "02-Jan-2006"

var DayPos = []int{0, 2}
Copy link
Member

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?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No

var MonthPos = []int{3, 6}
var YearPos = []int{7, 11}

type MyDateEntry struct {
Copy link
Member

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay

// 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() {
Copy link
Member

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay

Copy link
Author

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

@andydotxyz
Copy link
Member

I just came back to this (sorry for the delay) and notice that MyDateEntry is still a fairly strange name ;).
Also if you can rebase onto latest main the tests should all pass again.

@heejit
Copy link
Author

heejit commented Oct 5, 2023

I just came back to this (sorry for the delay) and notice that MyDateEntry is still a fairly strange name ;). Also if you can rebase onto latest main the tests should all pass again.

I have rewrite the whole widget this time using /richtext : https://github.com/heejit/fyne_codes/blob/main/widget_date_input.go

Copy link
Member

@Jacalz Jacalz left a 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.

var _ fyne.Tappable = (*JDateInputWidget)(nil)

// Custom Date Input Widget using RichText
type JDateInputWidget struct {
Copy link
Member

@Jacalz Jacalz Oct 5, 2023

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)?

Copy link
Author

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

Copy link
Member

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.

}

func (t *JDateInputWidget) TypedRune(k rune) {
// needed
Copy link
Member

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


// End: implement focusable interface

// Start: implemnet Tappable
Copy link
Member

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

}

// constructor
func NewJDateInputWidget(app fyne.App, window fyne.Window) *JDateInputWidget {
Copy link
Member

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.

Copy link
Member

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.

@andydotxyz
Copy link
Member

I just wanted to see the status of this and tried to resolve the conflict but as it was a PR from your master branch GitHub warned me not to, so I didn't - but it's a simple change.

I am sorry it took so long to get back to this - I hadn't noticed that there were commits since the last feedback.
However the naming is still not resolved as requested by Jacalz and there are references to your fork in the README.

Also it seems like you're looking to behave like an Entry but it isn't an Entry - so why not just extend Entry?
I have been working on an alternative picker based on the Calendar here and a simple Entry widget with an accessory for popping up the calendar, changes to the Entry theming made this fairly simple - not sure if this changes your thoughts?

Screenshot 2024-09-07 at 18 30 15

@heejit
Copy link
Author

heejit commented Sep 8, 2024

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.

@andydotxyz
Copy link
Member

The keyboard input could be a great extension of what has landed in fyne - if you would consider basing such a feature on top of the new widget that would be amazing, thanks.
However closing this PR so we can focus over there now.

@andydotxyz andydotxyz closed this Sep 24, 2024
@heejit
Copy link
Author

heejit commented Sep 24, 2024

okay

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants