mirror of
https://github.com/venera-app/venera.git
synced 2025-12-15 14:41:15 +00:00
* Optimize iOS full-screen back gesture implementation - Fix #613 and #617 * Fix setting page
53 lines
1.4 KiB
Dart
53 lines
1.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:venera/components/components.dart';
|
|
|
|
import 'app_page_route.dart';
|
|
|
|
extension Navigation on BuildContext {
|
|
void pop<T>([T? result]) {
|
|
if(mounted) {
|
|
Navigator.of(this).pop(result);
|
|
}
|
|
}
|
|
|
|
bool canPop() {
|
|
return Navigator.of(this).canPop();
|
|
}
|
|
|
|
Future<T?> to<T>(Widget Function() builder,) {
|
|
return Navigator.of(this).push<T>(AppPageRoute(
|
|
builder: (context) => builder()));
|
|
}
|
|
|
|
Future<void> toReplacement<T>(Widget Function() builder) {
|
|
return Navigator.of(this).pushReplacement(AppPageRoute(
|
|
builder: (context) => builder()));
|
|
}
|
|
|
|
double get width => MediaQuery.of(this).size.width;
|
|
|
|
double get height => MediaQuery.of(this).size.height;
|
|
|
|
EdgeInsets get padding => MediaQuery.of(this).padding;
|
|
|
|
EdgeInsets get viewInsets => MediaQuery.of(this).viewInsets;
|
|
|
|
ColorScheme get colorScheme => Theme.of(this).colorScheme;
|
|
|
|
Brightness get brightness => Theme.of(this).brightness;
|
|
|
|
bool get isDarkMode => brightness == Brightness.dark;
|
|
|
|
void showMessage({required String message}) {
|
|
showToast(message: message, context: this);
|
|
}
|
|
|
|
Color useBackgroundColor(MaterialColor color) {
|
|
return color[brightness == Brightness.light ? 100 : 800]!;
|
|
}
|
|
|
|
Color useTextColor(MaterialColor color) {
|
|
return color[brightness == Brightness.light ? 800 : 100]!;
|
|
}
|
|
}
|