Change status bar icons color Flutter - ios

Is it possible to change these icons color in IOS?

You can use SystemChrome
systemOverlayStyle: SystemUiOverlayStyle(
statusBarBrightness: Brightness.light, // For iOS: (dark icons)
statusBarIconBrightness: Brightness.dark, // For Android: (dark icons)
),

There are several ways to change the appearance of the status bar. If the application has an AppBar, you can set the backgroundColor and brightness arguments of the AppBar to change the style. If the application doesn't have an AppBar, you can use SystemChrome.setSystemUIOverlayStyle or AnnotatedRegion<SystemUiOverlayStyle>

Related

I want to convert the code below into Cupertino, IOS style. But I Can't Use Drawer Menu for IOS style. Why? How can I use?

I want to make android and IOS style.
I want to convert the code below into Cupertino, IOS style.
But I Can't Use Drawer Menu for IOS style. Why?
How can I use?
return Scaffold(
key: _scaffoldKey,
drawer: Drawer(),
appBar: AppBar(
leading: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: Icon(
Icons.arrow_back_ios,
color: MyColors.blue,
),
),
centerTitle: true,
title: Text('Test', style: MyTextStyles.appBarTitle(deviceType) ),
actions: <Widget>[
Builder(
builder: (BuildContext context) => PlatformIconButton(
onPressed: () {
Scaffold.of(context).openDrawer();
},
icon: Icon(
Icons.menu,
)))])
body: .........
The Drawer widget is a Material-exclusive widget, and you can't use it directly on iOS.
You could build your own "Drawer-like" widget for iOS by replicating the build construction of a Drawer widget, but I would not recommend that, because drawers don't have that iOS "look and feel". As an iOS user myself, I know some very influential apps like Twitter have something that looks like a Drawer, but I think that is not the way a native iOS app would handle that kind of navigation.
What you can do instead, is having a Drawer widget for Android, and a bottom tab bar for iOS, which is a component that is way more common in iOS-styled apps. You can use the Platform class to check if your code is being executed on Android or iOS, and choose the right widget based on that.
Here is one example of such a build logic that you might find useful. I am very sorry I can't paste the code directly, I had this screenshot from a presentation I made and I don't remember where did I place the code for this project, but I hope you find it useful.

TouchableOpacity border radius breaks background color on Android - React Native

I have a button that's styled as a TouchableOpacity.
On iOS this button has a white background and round corners, but in Android the background color doesn't get applied when there's a border-radius, it does when I take it out. border-radius also doesn't appear to have any effect regardless of whether there's a background color or not in Android.
I know I can use some conditional based on the platform, but I'd like to know if it's possible to have the same between the two platforms with the same code.
export const SomeButton = styled.TouchableOpacity`
flex: 1;
border-radius: 4
background: white;
`
I had exactly the same problem. I had to roll back the react-native to 0.60.5

Flutter change color of drawer scrim

Is it possible o change the color or transparency of the drawer's scrim in flutter? Something like is Java's drawerLayout.setScrimColor(Color.TRANSPARENT);?
Thanks.
Flutter now includes a drawerScrimColor parameter in the Scaffold widget.
For example:
Scaffold(
drawerScrimColor: Colors.black,
);
Although I answered the question, #diegoveloper deserves the credit for submitting the PR
Following the same ideia brought by #diegoveloper and for that who might wonder how to make transparency just use the transparent color drawerScrimColor: Colors.transparent
https://api.flutter.dev/flutter/material/Colors/transparent-constant.html
You can change drawerTheme like this:
return ThemeData(
drawerTheme: DrawerThemeData(
scrimColor: Colors.transparent,
),
);

Change gray overlay background of BottomSheet

Is there a way to change the overlay background color when using showModalBottomSheet?
Right now the color is always a gray color, but I want to use a different color like green as shown below.
Here is the code used in the demo for reference
showModalBottomSheet<void>(context: context, builder: (BuildContext context) {
return Container(
child: Padding(
padding: const EdgeInsets.all(32.0),
child: Text('This is the modal bottom sheet. Tap anywhere to dismiss.',
textAlign: TextAlign.center,
style: TextStyle(
color: Theme.of(context).accentColor,
fontSize: 24.0
)
)
)
);
});
New Flutter UPDATE allows you to change the barrierColor in showModalBottomSheet()
showModalBottomSheet(
barrierColor: Colors.yellow.withOpacity(0.5),
You can actually change this but in order to do so you have to create a copy of this widget file in order to customize it. (steps below are for vscode)
However, by doing this, the widget won't be automatically updated by Flutter because it'd no longer be part of the SDK.
Create A Copy of A Widget To Customize
Right-click widget and select Go to definition - this will bring you to the widget's original file
Copy all of the code and paste it into a new .dart file with the same name - you'll notice there will now be errors due to a lack of dependencies.
In the case of BottomSheet you just need to add import 'package:flutter/material.dart';
Now import it like so import 'package:projectname/bottom_sheet.dart' as my; - the as my allows it to use the same .dart file name
Now when referencing it just add my. prior like so
my.showModalBottomSheet(
context: (context),
isScrollControlled: false,...
Customize Background Overlay Color
Now in bottom_sheet.dart just search for barrierColor and change Colors.black54 to whatever color you want!
I hope this will help anyone in the future!
Related Question
How to change the background color of BottomSheet in Flutter?
Short answer : you can't.
The color is hardcoded into the _ModalBottomSheetRoute class (as linked by #pskink) and there is no way to change its value.

Unable to change $cordovaStatusbar text color

I'm having issues with the status bar of my Ionic app. More specifically I'm not able to change the bar default color, no matter what style I apply.
I already checked ngCordova and the cordovaStatusbar plugin are already installed correctly.
CODE SNIPPET
app.run(function ($ionicPlatform, $cordovaStatusbar) {
$ionicPlatform.ready(function () {
// Color the iOS status bar
if (window.StatusBar) {
$cordovaStatusbar.overlaysWebView(true);
$cordovaStatusbar.styleHex('#f50');
}
});
});
This is the result I get in xCode simulator with ionic emulate ios command.
EDIT:
After many tests I think the problem is more in depth. Neither .show() or .hide() methods are working.
app.run(function ($ionicPlatform, $cordovaStatusbar) {
$ionicPlatform.ready(function () {
$cordovaStatusbar.hide(); //not hiding the status bar
});
});
From the plugin github page
On iOS 7, when you set StatusBar.statusBarOverlaysWebView to false,
you can set the background color of the statusbar by a hex string
(#RRGGBB).
So I got this working by doing the following:
Making sure ngCordova is installed
Set OverlaysWebView to false and set the color.
if(window.StatusBar) {
$cordovaStatusbar.overlaysWebView(false);
$cordovaStatusbar.styleHex('#FF0000') //red
}
The text can only be white or black
This will use black color:
$cordovaStatusbar.styleDefault();
Any of this will use white color:
$cordovaStatusbar.styleLightContent();
$cordovaStatusbar.styleBlackTranslucent();
$cordovaStatusbar.styleBlackOpaque();
That styles made sense before iOS 7, now they all do the same.
To change the statusbar color you have to set the overlaysWebView to false first.
$cordovaStatusbar.overlaysWebView(false);
If it's true it will be transparent and you won't be able to change the color.
I had the same issue in one of the apps i am developing. The following plugin worked for us https://github.com/apache/cordova-plugin-statusbar
if (window.StatusBar) {
StatusBar.styleLightContent();
}
Edit: for hiding the status bar you can use window.StatusBar.hide();

Resources