34 lines
1.0 KiB
Dart
34 lines
1.0 KiB
Dart
// needed for web horizontal scroll behavior
|
|
import 'dart:convert' show jsonDecode;
|
|
import 'dart:ui';
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:json_theme/json_theme.dart';
|
|
import 'package:fotodocumentation/main.dart' show logger;
|
|
|
|
class MyCustomScrollBehavior extends MaterialScrollBehavior {
|
|
// Override behavior methods and getters like dragDevices
|
|
@override
|
|
Set<PointerDeviceKind> get dragDevices => {
|
|
PointerDeviceKind.touch,
|
|
PointerDeviceKind.mouse,
|
|
};
|
|
}
|
|
|
|
class ThemeLoader {
|
|
static Future<ThemeData> loadTheme() async {
|
|
try {
|
|
String prefix = kDebugMode && kIsWeb ? "" : "assets/";
|
|
String url = "${prefix}theme/appainter_theme.json";
|
|
final themeStr = await rootBundle.loadString(url);
|
|
final themeJson = jsonDecode(themeStr);
|
|
return ThemeDecoder.decodeThemeData(themeJson)!;
|
|
} catch (e) {
|
|
logger.e("Failed to load theme $e", error: e);
|
|
return ThemeData.light();
|
|
}
|
|
}
|
|
}
|