Skip to content

Commit

Permalink
Merge pull request #110 from a-mabe/fix-ios-statusbar-text
Browse files Browse the repository at this point in the history
Fix ios statusbar text
  • Loading branch information
a-mabe authored Dec 2, 2023
2 parents d154e07 + d813187 commit 0516e9a
Show file tree
Hide file tree
Showing 7 changed files with 280 additions and 248 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.1
1.1.2
2 changes: 1 addition & 1 deletion ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<true/>
</dict>
</plist>
86 changes: 47 additions & 39 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -212,46 +212,54 @@ class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
/// Pushes to [CreateWorkout()]
floatingActionButton: FloatingActionButton(
onPressed: pushSelectTimerPage,
tooltip: 'Create workout',
child: const Icon(Icons.add),
),
appBar: AppBar(
toolbarHeight: 0,
),
body: SafeArea(
child: Container(
padding: const EdgeInsets.all(8.0),
child: SizedBox(
height: MediaQuery.of(context).size.height * 0.882,
child: FutureBuilder(
future: workouts,
builder: (BuildContext context, AsyncSnapshot snapshot) {
/// When [workouts] has successfully loaded.
if (snapshot.hasData) {
if (snapshot.data!.isEmpty) {
return workoutEmpty();
} else {
reorderableWorkoutList = snapshot.data;
reorderableWorkoutList.sort((a, b) =>
a.workoutIndex.compareTo(b.workoutIndex));
return workoutListView(snapshot);
}
}
WidgetsBinding.instance.renderViews.first.automaticSystemUiAdjustment =
false;

/// When there was an error loading [workouts].
else if (snapshot.hasError) {
return workoutFetchError(snapshot);
}
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
statusBarBrightness: Theme.of(context).brightness,
));

/// While still waiting to load [workouts].
else {
return workoutLoading();
}
})))),
);
return Container(
color: Theme.of(context).scaffoldBackgroundColor,
child: SafeArea(
child: Scaffold(

/// Pushes to [CreateWorkout()]
floatingActionButton: FloatingActionButton(
onPressed: pushSelectTimerPage,
tooltip: 'Create workout',
child: const Icon(Icons.add),
),
body: Container(
padding: const EdgeInsets.all(8.0),
child: SizedBox(
height: MediaQuery.of(context).size.height * 0.882,
child: FutureBuilder(
future: workouts,
builder:
(BuildContext context, AsyncSnapshot snapshot) {
/// When [workouts] has successfully loaded.
if (snapshot.hasData) {
if (snapshot.data!.isEmpty) {
return workoutEmpty();
} else {
reorderableWorkoutList = snapshot.data;
reorderableWorkoutList.sort((a, b) =>
a.workoutIndex.compareTo(b.workoutIndex));
return workoutListView(snapshot);
}
}

/// When there was an error loading [workouts].
else if (snapshot.hasError) {
return workoutFetchError(snapshot);
}

/// While still waiting to load [workouts].
else {
return workoutLoading();
}
})))),
));
}
}
35 changes: 28 additions & 7 deletions lib/start_workout/view_workout.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:sqflite/sqflite.dart';
import '../create_workout/create_timer.dart';
import '../create_workout/create_workout.dart';
Expand Down Expand Up @@ -132,8 +133,25 @@ class ViewWorkoutState extends State<ViewWorkout> {
});
}

Color iconColor() {
final darkMode =
WidgetsBinding.instance.platformDispatcher.platformBrightness;
if (darkMode == Brightness.dark) {
return Colors.white;
} else {
return Colors.black;
}
}

@override
Widget build(BuildContext context) {
WidgetsBinding.instance.renderViews.first.automaticSystemUiAdjustment =
false;

SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
statusBarBrightness: Theme.of(context).brightness,
));

Workout workoutArgument =
ModalRoute.of(context)!.settings.arguments as Workout;

Expand Down Expand Up @@ -164,12 +182,8 @@ class ViewWorkoutState extends State<ViewWorkout> {
backgroundColor: Color(workoutArgument.colorInt),
actions: <Widget>[
IconButton(
icon: const Icon(Icons.delete),
icon: Icon(Icons.delete, color: iconColor()),
tooltip: 'Show Snackbar',
// onPressed: () async {
// await deleteList(workoutArgument, database)
// .then((value) => Navigator.pop(context));
// },
onPressed: () {
showDialog(
context: context,
Expand Down Expand Up @@ -206,7 +220,7 @@ class ViewWorkoutState extends State<ViewWorkout> {
},
),
IconButton(
icon: const Icon(Icons.edit),
icon: Icon(Icons.edit, color: iconColor()),
onPressed: () {
if (exercises.isEmpty) {
pushCreateTimer(workoutArgument);
Expand All @@ -232,7 +246,14 @@ class ViewWorkoutState extends State<ViewWorkout> {
arguments: workoutArgument,
),
),
);
).then((value) {
WidgetsBinding.instance.renderViews.first
.automaticSystemUiAdjustment = false;

SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
statusBarBrightness: Theme.of(context).brightness,
));
});
},
child: Ink(
height: 80.0,
Expand Down
Loading

0 comments on commit 0516e9a

Please sign in to comment.