2023-04-20 15:32:50 +00:00
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
|
|
import 'package:stackwallet/models/isar/sw_theme.dart';
|
|
|
|
import 'package:stackwallet/themes/defaults/dark.dart';
|
2023-04-24 14:36:12 +00:00
|
|
|
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
2023-04-20 15:32:50 +00:00
|
|
|
|
|
|
|
final applicationThemesDirectoryPathProvider = StateProvider((ref) => "");
|
|
|
|
|
2023-04-24 14:36:12 +00:00
|
|
|
final colorProvider = StateProvider<StackColors>(
|
|
|
|
(ref) => StackColors.fromStackColorTheme(
|
|
|
|
ref.watch(themeProvider.state).state,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
2023-04-20 15:32:50 +00:00
|
|
|
final themeProvider = StateProvider<StackTheme>((ref) {
|
|
|
|
// Return default if no theme was properly loaded on startup. This should
|
|
|
|
// technically never actually be read but we don't want an optional.
|
|
|
|
// Ideally Riverpod would would give us some kind of 'late' provider option
|
|
|
|
return StackTheme.fromJson(
|
|
|
|
json: darkJson,
|
|
|
|
// Explicitly use ref.read here as we do not want any rebuild on this
|
|
|
|
// value change.
|
|
|
|
applicationThemesDirectoryPath:
|
|
|
|
ref.read(applicationThemesDirectoryPathProvider),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
/// example
|
|
|
|
class ExampleWidget extends ConsumerWidget {
|
|
|
|
const ExampleWidget({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
|
|
return Column(
|
|
|
|
children: [
|
|
|
|
const Text("Hello, world!"),
|
|
|
|
SvgPicture.file(
|
|
|
|
File(
|
2023-04-24 12:53:51 +00:00
|
|
|
ref.watch(themeProvider).assets.bellNew,
|
2023-04-20 15:32:50 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|