Skip to content

Commit

Permalink
[NASA] titlebar updates to work better on android
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofKekesi committed May 15, 2022
1 parent 8ed74e7 commit 4f875e0
Show file tree
Hide file tree
Showing 13 changed files with 121 additions and 99 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion NASA-Mira/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>9.0</string>
<string>11.0</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion NASA-Mira/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
# platform :ios, '11.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
4 changes: 2 additions & 2 deletions NASA-Mira/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/integration_test/ios"

SPEC CHECKSUMS:
Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a
Flutter: 405776dd0763d7e32a8f989d4e271ca1317d080c
integration_test: a1e7d09bd98eca2fc37aefd79d4f41ad37bdbbe5

PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3

COCOAPODS: 1.11.2
2 changes: 2 additions & 0 deletions NASA-Mira/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,7 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
</dict>
</plist>
2 changes: 0 additions & 2 deletions NASA-Mira/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import "package:flutter_localizations/flutter_localizations.dart";
import "utils/orientation_lock.dart";
import "utils/no_material_glow.dart";
import "utils/material_color.dart";
import "utils/dark_titlebar.dart";
import "utils/localization.dart";
import "pass.dart";

Expand All @@ -16,7 +15,6 @@ import "pages/splash_screen.dart";
import "pages/home_page.dart";

void main() {
darkTitlebar();
runApp(
const MiraApp(
home: SplashScreenPage(
Expand Down
4 changes: 2 additions & 2 deletions NASA-Mira/lib/pages/date_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class DatePickerPageState extends State<DatePickerPage> {

@override
Widget build(BuildContext context) {
void _changeValue(bool value) {
void changeValue(bool value) {
setState(() => timeFormat = value);
}

Expand Down Expand Up @@ -405,7 +405,7 @@ class DatePickerPageState extends State<DatePickerPage> {
inactiveThumbColor: Colors.white,
activeColor: Colors.white,
splashRadius: 0,
onChanged: _changeValue,
onChanged: changeValue,
),
),
Text(
Expand Down
127 changes: 66 additions & 61 deletions NASA-Mira/lib/pages/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import "drawer.dart";

// utils
import "../utils/localization.dart";
import "../utils/dark_titlebar.dart";

// widgets
import "../widgets/apod.dart";
Expand All @@ -19,66 +20,70 @@ class HomePage extends StatelessWidget {
const HomePage({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) => Scaffold(
backgroundColor: Colors.white,
body: SpaceJamPage(
title: "NASA Mira",
appBarRightAction: SpaceJamAppBarAction(
Icons.menu,
tooltip: AppLocalizations.of(context).translate("selectors"),
action: () {
showSelectors(context);
},
),
animated: "off",
locale: AppLocalizations.of(context).locale,
children: <Widget>[
Padding(
padding: EdgeInsets.only(
left: MediaQuery.of(context).size.width * .05,
right: MediaQuery.of(context).size.width * .05,
),
child: Column(
children: <Widget>[
const ApodWidget(),
Collection(
isVisible: notifierAreHelicoptersVisible,
inputType: "type",
filter: "helicopter",
outputType: "type",
),
Collection(
isVisible: notifierAreRoversVisible,
inputType: "type",
filter: "rover",
outputType: "type",
),
Collection(
isVisible: notifierAreOrbitersVisible,
inputType: "type",
filter: "orbiter",
outputType: "type",
),
Collection(
isVisible: notifierAreLandersVisible,
inputType: "type",
filter: "lander",
outputType: "type",
),
Collection(
isVisible: notifierAreFlybysVisible,
inputType: "type",
filter: "flyby",
outputType: "type",
),
Container(
height: MediaQuery.of(context).size.width * .05,
),
],
),
),
],
Widget build(BuildContext context) {
setTitlebar("dark");

return Scaffold(
backgroundColor: Colors.white,
body: SpaceJamPage(
title: "NASA Mira",
appBarRightAction: SpaceJamAppBarAction(
Icons.menu,
tooltip: AppLocalizations.of(context).translate("selectors"),
action: () {
showSelectors(context);
},
),
drawer: const SidebarDrawer(),
);
animated: "off",
locale: AppLocalizations.of(context).locale,
children: <Widget>[
Padding(
padding: EdgeInsets.only(
left: MediaQuery.of(context).size.width * .05,
right: MediaQuery.of(context).size.width * .05,
),
child: Column(
children: <Widget>[
const ApodWidget(),
Collection(
isVisible: notifierAreHelicoptersVisible,
inputType: "type",
filter: "helicopter",
outputType: "type",
),
Collection(
isVisible: notifierAreRoversVisible,
inputType: "type",
filter: "rover",
outputType: "type",
),
Collection(
isVisible: notifierAreOrbitersVisible,
inputType: "type",
filter: "orbiter",
outputType: "type",
),
Collection(
isVisible: notifierAreLandersVisible,
inputType: "type",
filter: "lander",
outputType: "type",
),
Collection(
isVisible: notifierAreFlybysVisible,
inputType: "type",
filter: "flyby",
outputType: "type",
),
Container(
height: MediaQuery.of(context).size.width * .05,
),
],
),
),
],
),
drawer: const SidebarDrawer(),
);
}
}
16 changes: 3 additions & 13 deletions NASA-Mira/lib/pages/splash_screen.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Flutter
import "package:flutter/services.dart";
import "package:spacejam/spacejam.dart";
import "package:flutter/material.dart";
import "package:splashscreen/splashscreen.dart";

// utils
import "../utils/dark_titlebar.dart";
import "../utils/localization.dart";
import "../pass.dart";

Expand All @@ -27,24 +27,14 @@ class SplashScreenPage extends StatefulWidget {
class SplashScreenState extends State<SplashScreenPage> {
@override
void initState() {
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle.dark.copyWith(
statusBarColor: Colors.white,
statusBarBrightness: Brightness.dark,
),
);
super.initState();
setTitlebar("dark");
}

@override
void dispose() {
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle.dark.copyWith(
statusBarColor: Colors.black,
statusBarBrightness: Brightness.light,
),
);
super.dispose();
setTitlebar("light");
}

@override
Expand Down
33 changes: 30 additions & 3 deletions NASA-Mira/lib/utils/dark_titlebar.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,35 @@
// Dart
import "dart:io" show Platform;

// Flutter
import "package:flutter/material.dart";
import "package:flutter/services.dart";

/// Utility function to darken the title bar.
void darkTitlebar() {
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark.copyWith(
statusBarColor: Colors.black, statusBarBrightness: Brightness.light,),);
void setTitlebar(String theme) {
Brightness dark = Brightness.dark;
Brightness light = Brightness.light;

if (Platform.isIOS) {
dark = Brightness.light;
light = Brightness.dark;
}

if (theme == "light") {
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle.dark.copyWith(
systemNavigationBarColor: Colors.black,
statusBarColor: Colors.transparent,
statusBarBrightness: dark,
),
);
} else {
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle.light.copyWith(
systemNavigationBarColor: Colors.black,
statusBarColor: Colors.transparent,
statusBarBrightness: light,
),
);
}
}
4 changes: 2 additions & 2 deletions NASA-Mira/lib/widgets/collection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class CollectionState extends State<Collection> {
@override
Widget build(BuildContext context) => ValueListenableBuilder<bool>(
builder: (BuildContext context, bool value, Widget? child) {
Widget _roverGridInnerWithSort(String title) {
Widget roverGridInnerWithSort(String title) {
if (notifierIsReverse.value) {
return _CollectionInner(
data: hardCodeData.reversed.toList(),
Expand Down Expand Up @@ -213,7 +213,7 @@ class CollectionState extends State<Collection> {
}
});
}
return _roverGridInnerWithSort(
return roverGridInnerWithSort(
AppLocalizations.of(context).translateWithoutNullSafety(
"${widget.filter}s",
) ??
Expand Down
4 changes: 2 additions & 2 deletions NASA-Mira/lib/widgets/promo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class PromoWidget extends StatelessWidget {

@override
Widget build(BuildContext context) {
Future<bool> _widgetOpacity() async {
Future<bool> widgetOpacity() async {
try {
final List<InternetAddress> result =
await InternetAddress.lookup("google.com");
Expand All @@ -132,7 +132,7 @@ class PromoWidget extends StatelessWidget {
}

return FutureBuilder<bool>(
future: _widgetOpacity(),
future: widgetOpacity(),
builder: (BuildContext context, AsyncSnapshot<bool> snapshot) {
if (snapshot.hasData) {
if (snapshot.data ?? false) {
Expand Down
Loading

0 comments on commit 4f875e0

Please sign in to comment.