init
This commit is contained in:
commit
8e54cfffc5
91 changed files with 2686 additions and 0 deletions
35
lib/features/core/data/constants/const_colors.dart
Normal file
35
lib/features/core/data/constants/const_colors.dart
Normal file
|
@ -0,0 +1,35 @@
|
|||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
abstract class ConstColours {
|
||||
/// Smoke Gray => a neutral grey with neutral warmth/cold
|
||||
static const imageBackgroundColour = Color.fromRGBO(127, 127, 125, 1.0);
|
||||
|
||||
static const white = Colors.white;
|
||||
static const black = Colors.black;
|
||||
}
|
||||
|
||||
abstract class ConstThemes {
|
||||
static ThemeData get materialLightTheme => ThemeData(
|
||||
useMaterial3: true,
|
||||
brightness: Brightness.light,
|
||||
colorSchemeSeed: ConstColours.white,
|
||||
);
|
||||
|
||||
static ThemeData get materialDarkTheme => ThemeData(
|
||||
useMaterial3: true,
|
||||
brightness: Brightness.dark,
|
||||
colorSchemeSeed: ConstColours.white,
|
||||
);
|
||||
|
||||
static CupertinoThemeData get cupertinoLightTheme => const CupertinoThemeData(
|
||||
brightness: Brightness.light,
|
||||
);
|
||||
static CupertinoThemeData get cupertinoDarkTheme => const CupertinoThemeData(
|
||||
brightness: Brightness.dark,
|
||||
);
|
||||
static ThemeData get cupertinoThemeLightHack =>
|
||||
materialLightTheme.copyWith(cupertinoOverrideTheme: cupertinoLightTheme);
|
||||
static ThemeData get cupertinoThemeDarkHack =>
|
||||
materialDarkTheme.copyWith(cupertinoOverrideTheme: cupertinoDarkTheme);
|
||||
}
|
0
lib/features/core/data/constants/const_text.dart
Normal file
0
lib/features/core/data/constants/const_text.dart
Normal file
0
lib/features/core/data/constants/const_values.dart
Normal file
0
lib/features/core/data/constants/const_values.dart
Normal file
6
lib/features/core/data/enums/view_model_state.dart
Normal file
6
lib/features/core/data/enums/view_model_state.dart
Normal file
|
@ -0,0 +1,6 @@
|
|||
enum ViewModelState {
|
||||
isInitialising,
|
||||
isInitialised,
|
||||
isBusy,
|
||||
hasError;
|
||||
}
|
13
lib/features/core/data/extensions/context_extensions.dart
Normal file
13
lib/features/core/data/extensions/context_extensions.dart
Normal file
|
@ -0,0 +1,13 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
extension DarkMode on BuildContext {
|
||||
/// is dark mode currently enabled?
|
||||
///
|
||||
/// Using the context version in release throws exception.
|
||||
bool get isDarkMode =>
|
||||
WidgetsBinding.instance.platformDispatcher.platformBrightness == Brightness.dark;
|
||||
|
||||
double get width => MediaQuery.of(this).size.width;
|
||||
double get height => MediaQuery.of(this).size.height;
|
||||
}
|
6
lib/features/core/data/extensions/dio_extensions.dart
Normal file
6
lib/features/core/data/extensions/dio_extensions.dart
Normal file
|
@ -0,0 +1,6 @@
|
|||
import 'package:dio/dio.dart';
|
||||
|
||||
extension ResponseExtensions on Response {
|
||||
/// Shorthand for getting response's successful state.
|
||||
bool get isSuccessful => (data as Map)['response'];
|
||||
}
|
3
lib/features/core/data/extensions/list_extensions.dart
Normal file
3
lib/features/core/data/extensions/list_extensions.dart
Normal file
|
@ -0,0 +1,3 @@
|
|||
extension ListExtensions<T> on List<T> {
|
||||
List<T> get deepCopy => [...this];
|
||||
}
|
3
lib/features/core/data/extensions/map_extensions.dart
Normal file
3
lib/features/core/data/extensions/map_extensions.dart
Normal file
|
@ -0,0 +1,3 @@
|
|||
extension MapExtensions<A, B> on Map<A, B> {
|
||||
Map<A, B> get deepCopy => {...this};
|
||||
}
|
37
lib/features/core/data/extensions/stream_extensions.dart
Normal file
37
lib/features/core/data/extensions/stream_extensions.dart
Normal file
|
@ -0,0 +1,37 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
|
||||
extension StreamExtensions<T> on Stream<T> {
|
||||
ValueListenable<T> toValueNotifier(
|
||||
T initialValue, {
|
||||
bool Function(T previous, T current)? notifyWhen,
|
||||
}) {
|
||||
final notifier = ValueNotifier<T>(initialValue);
|
||||
listen((value) {
|
||||
if (notifyWhen == null || notifyWhen(notifier.value, value)) {
|
||||
notifier.value = value;
|
||||
}
|
||||
});
|
||||
return notifier;
|
||||
}
|
||||
|
||||
ValueListenable<T?> toNullableValueNotifier({
|
||||
bool Function(T? previous, T? current)? notifyWhen,
|
||||
}) {
|
||||
final notifier = ValueNotifier<T?>(null);
|
||||
listen((value) {
|
||||
if (notifyWhen == null || notifyWhen(notifier.value, value)) {
|
||||
notifier.value = value;
|
||||
}
|
||||
});
|
||||
return notifier;
|
||||
}
|
||||
|
||||
Listenable toListenable() {
|
||||
final notifier = ChangeNotifier();
|
||||
listen((_) {
|
||||
// ignore: invalid_use_of_protected_member, invalid_use_of_visible_for_testing_member
|
||||
notifier.notifyListeners();
|
||||
});
|
||||
return notifier;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue