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 Fix as proposed in #6 and added Fixed Mode and Textcolor #16

Merged
merged 5 commits into from
Oct 23, 2016

Conversation

escamoteur
Copy link

#6 Added the proposed fix

Space above bottom navigation bar dewango#6
…use FixedMode.

When selecting FixedMode also the TabText and Icon color can be set by setting BarTextColor
@escamoteur escamoteur changed the title Added Fix as proposed in #6 Added Fix as proposed in #6 and added Fixed Mode and Textcolor Oct 12, 2016
@escamoteur
Copy link
Author

Added a property FixedMode to BottombarPage so that you now can also use FixedMode.

When selecting FixedMode also the TabText and Icon color can be set by setting BarTextColor

You can only select a the Text and Icon Color of the active Tab when using Fixed Mode

@andreinitescu
Copy link
Contributor

andreinitescu commented Oct 12, 2016

Thank you for your contribution!
Can you please remove the changes which are not really part of the PR?
Please just keep the actual code, not changes due to opening solution in a different IDE.
Just look to the changes of BottomBar.Droid/BottomBar.Droid.csproj and BottomBarXF.sln to see what I mean.
There's also some code indentation\formatting issues...
Thanks!

@@ -21,7 +21,9 @@ namespace BottomBar.XamarinForms
{
public class BottomBarPage : TabbedPage
{
public void RaiseCurrentPageChanged()
public bool FixedMode { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

code is not formatted....

@@ -132,7 +132,11 @@ protected override void OnElementChanged (ElementChangedEventArgs<BottomBarPage>
// create bottomBar control
_bottomBar = BottomNavigationBar.BottomBar.Attach (_frameLayout, null);
_bottomBar.NoTabletGoodness ();
_bottomBar.LayoutParameters = new LayoutParams (LayoutParams.MatchParent, LayoutParams.MatchParent);
if (bottomBarPage.FixedMode)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please format the code?

@@ -227,7 +231,8 @@ void UpdateBarTextColor ()
return;
}

// haven't found yet how to set text color for tab items on_bottomBar, doesn't seem to have a direct way
_bottomBar.SetActiveTabColor(Element.BarTextColor.ToAndroid());
Copy link
Contributor

Choose a reason for hiding this comment

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

same here...

Copy link
Author

Choose a reason for hiding this comment

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

Strange it's formated at my side.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

Ah, I see, seems a problem with tabs vs / spaces. had to switch to tabs yesterday. will change it.

Should I create a new branch and make a new PR or what is the best way?

Also I have no idea why my VS is changing the project files. I did not change anything there

Copy link
Author

Choose a reason for hiding this comment

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

That's strange. must be another problem.
I create a new branch

Copy link
Author

Choose a reason for hiding this comment

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

This is my first PR to this project and I felt you comments quite harsh as if I'm an idiot who cannot format his code before pushing.

Copy link
Contributor

@andreinitescu andreinitescu Oct 12, 2016

Choose a reason for hiding this comment

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

I'm sorry if you feel that way. Please read again, I didn't have any harsh comments, I just asked if you could remove the unnecessary changes, which add a lot of noise to the PR. That's in order to maintain a clean code as possible.

Copy link
Author

Choose a reason for hiding this comment

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

Don't want to push this further. Perhaps the next time first welcome a new contributor. It's about motivation to contribute on a project.
I'm fine now, we found the reason.

Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't welcome you? I'm sorry for that. Welcome again!

Copy link
Author

Choose a reason for hiding this comment

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

Ahh written communication is so difficult if it comes to emotions :-(

@escamoteur
Copy link
Author

This is strange, when using FixedMode I can set the TextColor, but no longer the Bar Color. any idea?

@escamoteur
Copy link
Author

Ok, found out how it works. You have to set DarkTheme and then provide a colors.xml file. I added a property for the theming to BottomBarPage

@escamoteur
Copy link
Author

Found today that the CurrentPageChangedEvent was called twice because it was called due to the asignment of the new Page to CurrentPage which triggers an OnPropertyChanged event and on the following call to RaiseCurrentPageChanged.

I changed it to

        public void OnTabSelected (int position)
        {
            //Do we need this call? It's also done in OnElementPropertyChanged
            SwitchContent(Element.Children [position]);
            var bottomBarPage = Element as BottomBarPage;
            bottomBarPage.CurrentPage = Element.Children[position];
            //bottomBarPage.RaiseCurrentPageChanged();
        }

As I wrote in the comment I'm not sure if we need the first call to SwitchContent as it get called again when the CurrentPage property get's changed:

        protected override void OnElementPropertyChanged (object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged (sender, e);

            if (e.PropertyName == nameof (TabbedPage.CurrentPage)) {
                SwitchContent (Element.CurrentPage);
            } else if (e.PropertyName == NavigationPage.BarBackgroundColorProperty.PropertyName) {
                UpdateBarBackgroundColor ();
            } else if (e.PropertyName == NavigationPage.BarTextColorProperty.PropertyName) {
                UpdateBarTextColor ();
            }
        }

If you comment it out it still works.

@escamoteur
Copy link
Author

@sschmidt did you have a loom at my PR?

@nbsoftware
Copy link
Contributor

Hello @escamoteur !
Thanks for your contributions ;)
Actually you are right, I also just found out about the CurrentPageChangedEvent being called twice.
So your fix is correct, I did the same and I actually also removed the line that calls SwitchContent in OnTabSelected because it is indeed done in OnElementPropertyChanged.
So the function looks like that:

        public void OnTabSelected (int position)
        {
            var bottomBarPage = Element as BottomBarPage;
            // setting the CurrentPage on XF control will raise the corresponding OnElementPropertyChanged call
            // so no need to call SwitchContent from here
            bottomBarPage.CurrentPage = Element.Children[position];
        }

While I am at it I made another fix in SwitchContent for the following scenario: if the CurrentPage property was set programmatically in the PCL code, the correct tab view was indeed updated and shown, but not the corresponding button. Fixed by calling SelectTabAtPosition on native control.


    protected virtual void SwitchContent (Page view)
        {
            // when CurrentPage has been changed programmatically from Xamarin Form control,
            // we need to set the current active tab also on the native control
            _bottomBar.SelectTabAtPosition(Element.Children.IndexOf(Element.CurrentPage), false);

            Context.HideKeyboard (this);

            _frameLayout.RemoveAllViews ();

            if (view == null) {
                return;
            }

            if (Platform.GetRenderer (view) == null) {
                Platform.SetRenderer (view, Platform.CreateRenderer (view));
            }

            _frameLayout.AddView (Platform.GetRenderer (view).ViewGroup);
        }

If you want I can commit those changes to my master branch and send you the PR...
Or, as they are really simple, you could apply those 2 changes to yours directly.

Cheers

@escamoteur
Copy link
Author

Great, what about the other extensions? what do you think about them?

@sschmidt
Copy link
Member

Hi @escamoteur, thanks for the great contribution. Highly appreciated!

Do we really need the changes to the sln and csproj files (i.e. changes to visual studio version/target framework version)? In case those changes don't add to the solution, I'd like to leave those files as they are.

As I understand @nbsoftware and @andreinitescu already approved/tested this PR (thanks guys!). I'll test it tomorrow and we can go ahead and merge this in.

@escamoteur
Copy link
Author

escamoteur commented Oct 18, 2016

Sorry, this seems to be an effect of VS 2015 with Xamarin 4.2. It automatcially changes it when you first open an solution with it.
You don't need to merge them in.

@sschmidt sschmidt merged commit af7cf9c into dewango:master Oct 23, 2016
@escamoteur
Copy link
Author

Great, thanks. Do you built a new nuget?

@sschmidt
Copy link
Member

Sure, can you briefly test the master version before I update nuget please?

@nbsoftware
Copy link
Contributor

Hello,

Before releasing to nuget, could you please integrate the two small fixes I mentioned in #16 (comment) ?

Would you prefer I issue a PR from current master?

Thanks

@sschmidt
Copy link
Member

@nbsoftware sure. A PR would be more than welcome!

@escamoteur
Copy link
Author

Did anybody of you try to change the fond/fontsize of the Tabb Texts in fixed mode? One of my texts get's truncated while perfectly visible on iOS.

@escamoteur
Copy link
Author

Just checked the current version works fine.

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.

4 participants