Skip to content

Commit

Permalink
Remove deprecated member calls
Browse files Browse the repository at this point in the history
  • Loading branch information
root458 committed Aug 4, 2024
1 parent bf5845c commit d601e5a
Show file tree
Hide file tree
Showing 20 changed files with 41 additions and 65 deletions.
10 changes: 5 additions & 5 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -217,17 +217,17 @@ class _TimeCopAppState extends State<TimeCopApp> with WidgetsBindingObserver {
brightness: Brightness.light,
colors: lightDynamic ?? ThemeUtil.lightColors,
appBarBackground:
lightDynamic?.background ?? ThemeUtil.lightColors.background,
appBarForeground: lightDynamic?.onBackground ??
ThemeUtil.lightColors.onBackground);
lightDynamic?.surface ?? ThemeUtil.lightColors.surface,
appBarForeground:
lightDynamic?.onSurface ?? ThemeUtil.lightColors.onSurface);
case ThemeType.darkMaterialYou:
return ThemeUtil.getThemeFromColors(
brightness: Brightness.dark,
colors: darkDynamic ?? ThemeUtil.darkColors,
appBarBackground:
darkDynamic?.background ?? ThemeUtil.darkColors.background,
darkDynamic?.surface ?? ThemeUtil.darkColors.surface,
appBarForeground:
darkDynamic?.onBackground ?? ThemeUtil.darkColors.onBackground);
darkDynamic?.onSurface ?? ThemeUtil.darkColors.onSurface);
case ThemeType.auto:
default:
return brightness == Brightness.dark
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/dashboard/DashboardScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class DashboardScreen extends StatelessWidget {
const RunningTimers(),
Material(
elevation: 8.0,
color: Theme.of(context).colorScheme.surfaceVariant,
color: Theme.of(context).colorScheme.surfaceContainerHighest,
child: Padding(
padding: EdgeInsets.fromLTRB(8 + screenBorders.left, 8,
8 + screenBorders.right, 8 + screenBorders.bottom),
Expand Down
2 changes: 0 additions & 2 deletions lib/screens/dashboard/components/CollapsibleDayGrouping.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:timecop/models/timer_entry.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
Expand Down Expand Up @@ -120,7 +118,7 @@ class _GroupedStoppedTimersRowNarrowSimpleState
const SizedBox(width: 4),
Text(TimerEntry.formatDuration(widget.totalDuration),
style: theme.textTheme.bodyMedium?.copyWith(
color: theme.colorScheme.onBackground,
color: theme.colorScheme.onSurface,
fontFeatures: const [FontFeature.tabularFigures()],
)),
if (_isHovering && !_expanded) const SizedBox(width: 4),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/dashboard/components/ProjectTag.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ProjectTag extends StatelessWidget {
style: theme.textTheme.bodyMedium?.copyWith(
color: project == null
? ThemeUtil.getOnBackgroundLighter(context)
: theme.colorScheme.onBackground),
: theme.colorScheme.onSurface),
)
]);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/dashboard/components/RowSeparator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class RowSeparator extends StatelessWidget {
margin: const EdgeInsets.symmetric(horizontal: 8),
height: 32,
width: 1,
color: Theme.of(context).colorScheme.onBackground.withAlpha(31),
color: Theme.of(context).colorScheme.onSurface.withAlpha(31),
);
}
}
2 changes: 0 additions & 2 deletions lib/screens/dashboard/components/RunningTimerRow.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
Expand Down
6 changes: 2 additions & 4 deletions lib/screens/dashboard/components/RunningTimers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:timecop/blocs/timers/bloc.dart';
Expand Down Expand Up @@ -54,7 +52,7 @@ class RunningTimers extends StatelessWidget {

return Material(
elevation: 4,
color: theme.colorScheme.surfaceVariant,
color: theme.colorScheme.surfaceContainerHighest,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisSize: MainAxisSize.min,
Expand Down Expand Up @@ -90,7 +88,7 @@ class RunningTimers extends StatelessWidget {
data: Theme.of(context).copyWith(
scrollbarTheme: ScrollbarThemeData(
thumbVisibility:
MaterialStateProperty.all<bool>(true))),
WidgetStateProperty.all<bool>(true))),
child: ConstrainedBox(
constraints: BoxConstraints(
maxHeight: MediaQuery.sizeOf(context).height / 4),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
Expand Down
2 changes: 0 additions & 2 deletions lib/screens/dashboard/components/StoppedTimerRowWide.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
Expand Down
3 changes: 1 addition & 2 deletions lib/screens/dashboard/components/StoppedTimers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// limitations under the License.

import 'dart:collection';
import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
Expand Down Expand Up @@ -139,7 +138,7 @@ class _DayGroupingRows extends StatelessWidget {
Container(
height: 16,
width: 1,
color: theme.colorScheme.onBackground.withAlpha(31),
color: theme.colorScheme.onSurface.withAlpha(31),
),
if (isWidescreen)
const SizedBox(
Expand Down
4 changes: 1 addition & 3 deletions lib/screens/dashboard/components/TimerDenseTrailing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:timecop/screens/dashboard/components/RowSeparator.dart';
Expand Down Expand Up @@ -57,7 +55,7 @@ class TimerDenseTrailing extends StatelessWidget {
children: <Widget>[
Text(durationString,
style: theme.textTheme.bodyMedium?.copyWith(
color: theme.colorScheme.onBackground,
color: theme.colorScheme.onSurface,
fontFeatures: const [
FontFeature.tabularFigures()
],
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/projects/ProjectsScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class ProjectsScreen extends StatelessWidget {
FontAwesomeIcons.boxArchive,
color: Theme.of(context)
.colorScheme
.onBackground,
.onSurface,
size: 20,
),
const SizedBox(width: 8),
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/reports/ReportsScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class _ReportsScreenState extends State<ReportsScreen> {
? SwiperControl(
iconPrevious: Icons.arrow_back_ios_new,
iconNext: Icons.arrow_forward_ios,
color: Theme.of(context).colorScheme.onBackground)
color: Theme.of(context).colorScheme.onSurface)
: null,
),
),
Expand Down
3 changes: 1 addition & 2 deletions lib/screens/timer/TimerEditor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import 'dart:async';
import 'dart:math';
import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
Expand Down Expand Up @@ -138,7 +137,7 @@ class _TimerEditorState extends State<TimerEditor> {
false;
if (delete) {
timersBloc.add(DeleteTimer(widget.timer));
if (!mounted) return;
if (!context.mounted) return;
Navigator.of(context).pop();
}
},
Expand Down
48 changes: 21 additions & 27 deletions lib/themes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,29 @@ class ThemeUtil {
static final lightColors = ColorScheme.light(
primary: Colors.cyan.shade600,
onPrimary: Colors.white,
background: Colors.white,
onBackground: Colors.black87,
surface: Colors.grey.shade50,
onSurface: Colors.black87,
surfaceVariant: Colors.blueGrey.shade50,
surfaceContainerHighest: Colors.blueGrey.shade50,
onSurfaceVariant: Colors.black87,
error: Colors.red,
onError: Colors.white);

static final darkColors = ColorScheme.dark(
primary: Colors.cyan.shade600,
onPrimary: Colors.white,
background: Colors.grey.shade800,
onBackground: Colors.white,
surface: Colors.grey.shade900,
onSurface: Colors.white,
surfaceVariant: const Color(0xFF303030),
surfaceContainerHighest: const Color(0xFF303030),
onSurfaceVariant: Colors.white,
error: Colors.red,
onError: Colors.white);

static final _blackColors = ColorScheme.dark(
primary: Colors.cyan.shade600,
onPrimary: Colors.white,
background: Colors.black,
onBackground: Colors.white,
surface: Colors.black,
onSurface: Colors.white,
surfaceVariant: Colors.grey.shade900,
surfaceContainerHighest: Colors.grey.shade900,
onSurfaceVariant: Colors.white,
error: Colors.red,
onError: Colors.white);
Expand Down Expand Up @@ -88,7 +82,7 @@ class ThemeUtil {
appBarScrolledUnderElevation: 4);

static Color getOnBackgroundLighter(BuildContext context) =>
Theme.of(context).colorScheme.onBackground.withOpacity(0.62);
Theme.of(context).colorScheme.onSurface.withOpacity(0.62);

static ThemeData getThemeFromColors(
{required Brightness brightness,
Expand All @@ -103,7 +97,7 @@ class ThemeUtil {
brightness: brightness,
pageTransitionsTheme: _pageTransitionsTheme,
primarySwatch: primarySwatch,
scaffoldBackgroundColor: colors.background,
scaffoldBackgroundColor: colors.surface,
appBarTheme: AppBarTheme(
centerTitle: !Platform.isAndroid,
elevation: appBarElevation,
Expand All @@ -119,13 +113,13 @@ class ThemeUtil {
expansionTileTheme: ExpansionTileThemeData(
collapsedBackgroundColor: Colors.transparent,
backgroundColor: Colors.transparent,
collapsedTextColor: colors.onBackground,
collapsedTextColor: colors.onSurface,
textColor: colors.onSurface,
iconColor: colors.onSurfaceVariant,
collapsedIconColor: colors.onSurfaceVariant),
dividerColor: colors.onBackground.withAlpha(31),
dividerColor: colors.onSurface.withAlpha(31),
dividerTheme:
DividerThemeData(color: colors.onBackground.withAlpha(31)),
DividerThemeData(color: colors.onSurface.withAlpha(31)),
floatingActionButtonTheme: FloatingActionButtonThemeData(
shape: const StadiumBorder(),
backgroundColor: colors.primary,
Expand All @@ -135,30 +129,30 @@ class ThemeUtil {
textSelectionTheme:
TextSelectionThemeData(cursorColor: colors.primary),
switchTheme: SwitchThemeData(
thumbColor: MaterialStateProperty.resolveWith<Color?>((states) =>
(!states.contains(MaterialState.disabled) && states.contains(MaterialState.selected))
thumbColor: WidgetStateProperty.resolveWith<Color?>((states) =>
(!states.contains(WidgetState.disabled) && states.contains(WidgetState.selected))
? colors.primary
: null),
trackColor: MaterialStateProperty.resolveWith<Color?>((states) =>
(!states.contains(MaterialState.disabled) && states.contains(MaterialState.selected))
trackColor: WidgetStateProperty.resolveWith<Color?>((states) =>
(!states.contains(WidgetState.disabled) && states.contains(WidgetState.selected))
? colors.primary.withAlpha(80)
: null)),
radioTheme: RadioThemeData(
fillColor: MaterialStateProperty.resolveWith<Color?>((states) =>
(!states.contains(MaterialState.disabled) &&
states.contains(MaterialState.selected))
fillColor: WidgetStateProperty.resolveWith<Color?>((states) =>
(!states.contains(WidgetState.disabled) &&
states.contains(WidgetState.selected))
? colors.primary
: null),
),
checkboxTheme: CheckboxThemeData(
fillColor: MaterialStateProperty.resolveWith<Color?>((states) =>
(!states.contains(MaterialState.disabled) &&
states.contains(MaterialState.selected))
fillColor: WidgetStateProperty.resolveWith<Color?>((states) =>
(!states.contains(WidgetState.disabled) &&
states.contains(WidgetState.selected))
? colors.primary
: null),
checkColor: MaterialStateProperty.resolveWith<Color?>((states) =>
(!states.contains(MaterialState.disabled) &&
states.contains(MaterialState.selected))
checkColor: WidgetStateProperty.resolveWith<Color?>((states) =>
(!states.contains(WidgetState.disabled) &&
states.contains(WidgetState.selected))
? colors.onPrimary
: null),
));
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/timer_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class TimerUtils {
return Theme.of(context)
.textTheme
.titleMedium!
.copyWith(color: Theme.of(context).colorScheme.onBackground);
.copyWith(color: Theme.of(context).colorScheme.onSurface);
}
}
}
4 changes: 3 additions & 1 deletion test_driver/integration_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ Future<void> main() async {
return true;
},
);
} catch (e) {}
} catch (e) {
// Do nothing
}
}

0 comments on commit d601e5a

Please sign in to comment.