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

[BUG] Navigation bar's color unable to restored after the picker was dismissed #35

Closed
fangshengfy opened this issue Jun 28, 2020 · 21 comments
Labels
b: flutter This is a flutter issue. p: Android This issue only happens on Android platform. s: bug Something isn't working.

Comments

@fangshengfy
Copy link

Describe the bug (描述)
BottomNavigationBar color was changed after picker closed
How to reproduce (如何复现)
close picker

Steps to reproduce the behavior (描述复现步骤):

close picker

Expected behavior (期望行为)

Screenshots (If contains) (是否有截图可以提供)
If applicable, add screenshots to help explain your problem.

Device information (设备信息)

  • Device: Android

Additional context (附加信息)
Add any other context about the problem here. 在此提供更多的内容。

@fangshengfy fangshengfy added await investigate The issue is waiting for further investigation. s: bug Something isn't working. labels Jun 28, 2020
@github-actions github-actions bot added the await triage The issue is waiting for triage. label Jun 28, 2020
@AlexV525
Copy link
Member

Please provide the usage of your code.

@AlexV525 AlexV525 added i: lack of information Further information is requested. and removed s: bug Something isn't working. labels Jun 28, 2020
@fangshengfy
Copy link
Author

fangshengfy commented Jun 28, 2020

Please provide the usage of your code.

  action(String name) async {
    if (name == '相册') {
      final List<AssetEntity> assets = await AssetPicker.pickAssets(context);
    } else if (name == '拍摄') {
      File file = await Navigator.push(
          context,
          MaterialPageRoute(
              builder: (context) => Camera(mode: CameraMode.fullscreen)));
    } else{
    }
  }

@fangshengfy
Copy link
Author

BottomNavigationBar color from white to black

@fangshengfy
Copy link
Author

it‘s ok after Lock screen

@fangshengfy
Copy link
Author

test phone is redmi 7

@AlexV525
Copy link
Member

Can you provide a smallest demo to reproduce the issue?

@fangshengfy
Copy link
Author

fangshengfy commented Jun 28, 2020

Can you provide a smallest demo to reproduce the issue?

import 'package:flutter/material.dart';
import 'package:wechat_assets_picker/wechat_assets_picker.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);


  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {


  @override
  Widget build(BuildContext context) {

    return Scaffold(
      appBar: AppBar(

        title: Text(widget.title),
      ),
      body: Center(),
      floatingActionButton: FloatingActionButton(
        onPressed: ()async{
          final List<AssetEntity> assets = await AssetPicker.pickAssets(context);
        },
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}

@fangshengfy
Copy link
Author

lock screen didn't fix it

@AlexV525
Copy link
Member

I didn't found any BottomNavigationBar in here.

Before First Select After Second Select
image image image
image

@fangshengfy
Copy link
Author

fangshengfy commented Jun 28, 2020

Screenshot_2020-06-28-19-30-15-505_com example fl

@fangshengfy
Copy link
Author

Screenshot_2020-06-28-19-32-38-685_com example fl

@fangshengfy
Copy link
Author

because your BottomNavigationBar is black

@AlexV525 AlexV525 added s: UI This issue is related with UI or layout. and removed await triage The issue is waiting for triage. i: lack of information Further information is requested. labels Jun 28, 2020
@AlexV525
Copy link
Member

Cannot reproduce, because the code you have provided starts with a black navigator on my side.

@AlexV525 AlexV525 removed the await investigate The issue is waiting for further investigation. label Jun 28, 2020
@fangshengfy
Copy link
Author

but redme 7 defalut color is white

@AlexV525
Copy link
Member

Oh now it takes effect.

@AlexV525 AlexV525 added s: bug Something isn't working. s: developing This issue in under development. labels Jun 28, 2020
@AlexV525
Copy link
Member

Finish investigation, ref flutter/40590 .

Add below line into the main method which will be:

void main() {
  runApp(MyApp());
  WidgetsBinding.instance.renderView.automaticSystemUiAdjustment = false;
}

@AlexV525 AlexV525 added b: flutter This is a flutter issue. and removed s: UI This issue is related with UI or layout. s: developing This issue in under development. labels Jun 28, 2020
@fangshengfy
Copy link
Author

fangshengfy commented Jun 28, 2020

Screenshot_2020-06-28-21-27-11-692_com example pr
Screenshot_2020-06-28-21-25-35-463_com example pr

to be honest,it is not a best solution

@AlexV525
Copy link
Member

You can use a light theme to implement your picker, rather than a dark version.

@AlexV525
Copy link
Member

Though, it's not an issue from the picker. :-)

@fangshengfy
Copy link
Author

fangshengfy commented Jun 28, 2020

void main()  {
  WidgetsBinding.instance.renderView.automaticSystemUiAdjustment = false;
  runApp(createApp());
}

Color barColor;
  @override
  initState() {
    super.initState();
    FlutterStatusbarcolor.getNavigationBarColor().then((value) {
  if(value!=null)
      barColor = value;
    });
  }

   if(barColor!=null){
        //android
      if(barColor.value==Colors.white.value){
        //底部为白色
        await FlutterStatusbarcolor.setNavigationBarColor(Colors.black);
        await FlutterStatusbarcolor.setNavigationBarWhiteForeground(true);
        //状态栏的前景色需要区别,我的状态栏是白底黑字
        await FlutterStatusbarcolor.setStatusBarWhiteForeground(true);
        final List<AssetEntity> assets = await AssetPicker.pickAssets(context);
        //状态栏的前景色需要区别,我的状态栏是白底黑字
        await FlutterStatusbarcolor.setStatusBarWhiteForeground(false);
        await FlutterStatusbarcolor.setNavigationBarColor(barColor);
        await FlutterStatusbarcolor.setNavigationBarWhiteForeground(false);
      }else{
        //底部为黑色
        await FlutterStatusbarcolor.setNavigationBarColor(Colors.white);
        await FlutterStatusbarcolor.setNavigationBarWhiteForeground(false);
        //状态栏的前景色需要区别
        await FlutterStatusbarcolor.setStatusBarWhiteForeground(true);
        final List<AssetEntity> assets = await AssetPicker.pickAssets(context);
        //状态栏的前景色需要区别
        await FlutterStatusbarcolor.setStatusBarWhiteForeground(false);
        await FlutterStatusbarcolor.setNavigationBarColor(barColor);
        await FlutterStatusbarcolor.setNavigationBarWhiteForeground(true);
      }
      }else{
        //ios或回调未完成
        await FlutterStatusbarcolor.setStatusBarWhiteForeground(true);
        final List<AssetEntity> assets = await AssetPicker.pickAssets(context);
        //状态栏的前景色需要区别,我的状态栏是白底黑字
        await FlutterStatusbarcolor.setStatusBarWhiteForeground(false);
      }

it is my current solution

@AlexV525
Copy link
Member

The pickerTheme property provided the ability to set the brightness to the status bar and the navigation bar.

Locking this until the official one is resolved.

@fluttercandies fluttercandies locked as too heated and limited conversation to collaborators Jun 28, 2020
@AlexV525 AlexV525 changed the title [BUG] BottomNavigationBar color was changed after picker closed [BUG] Navigation bar's color unable to restored after the picker was dismissed Jun 28, 2020
@AlexV525 AlexV525 added the p: Android This issue only happens on Android platform. label Nov 16, 2020
@fluttercandies fluttercandies unlocked this conversation Nov 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
b: flutter This is a flutter issue. p: Android This issue only happens on Android platform. s: bug Something isn't working.
Projects
None yet
Development

No branches or pull requests

2 participants