-
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathapp.dart
More file actions
99 lines (92 loc) · 3.1 KB
/
app.dart
File metadata and controls
99 lines (92 loc) · 3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import 'package:baseflow_plugin_template/src/info_page.dart';
import 'package:baseflow_plugin_template/src/page.dart';
import 'package:flutter/material.dart';
import 'home.dart';
/// A Flutter application demonstrating the functionality of this plugin
class BaseflowPluginExample extends StatelessWidget {
final String pluginName;
final List<ExamplePage> pages;
final List<Widget>? appBarActions;
/// [MaterialColor] to be used in the app [ThemeData]
final MaterialColor themeMaterialColor =
createMaterialColor(const Color.fromRGBO(48, 49, 60, 1));
BaseflowPluginExample({
super.key,
required this.pluginName,
required String githubURL,
required String pubDevURL,
required this.pages,
this.appBarActions,
}) {
pages.add(InfoPage.createPage(pluginName, githubURL, pubDevURL));
}
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Baseflow $pluginName',
theme: ThemeData(
colorScheme: Theme.of(context).colorScheme.copyWith(
secondary: Colors.white60,
surface: const Color.fromRGBO(48, 49, 60, 0.8),
),
buttonTheme: ButtonThemeData(
buttonColor: themeMaterialColor.shade500,
disabledColor: themeMaterialColor.withRed(200),
splashColor: themeMaterialColor.shade50,
textTheme: ButtonTextTheme.primary,
),
bottomAppBarTheme: const BottomAppBarThemeData(
color: Color.fromRGBO(57, 58, 71, 1),
),
hintColor: themeMaterialColor.shade500,
primarySwatch: createMaterialColor(const Color.fromRGBO(48, 49, 60, 1)),
textTheme: const TextTheme(
bodyLarge: TextStyle(
color: Colors.white,
fontSize: 16,
height: 1.3,
),
bodyMedium: TextStyle(
color: Colors.white,
fontSize: 18,
height: 1.2,
),
labelLarge: TextStyle(color: Colors.white),
displayLarge: TextStyle(
color: Colors.white,
fontSize: 18,
),
),
visualDensity: VisualDensity.adaptivePlatformDensity,
inputDecorationTheme: const InputDecorationTheme(
fillColor: Color.fromRGBO(37, 37, 37, 1),
filled: true,
),
),
home: AppHome(
title: 'Baseflow $pluginName example app',
pages: pages,
appBarActions: appBarActions,
),
);
}
/// Creates a [MaterialColor] based on the supplied [Color]
static MaterialColor createMaterialColor(Color color) {
var strengths = <double>[.05];
var swatch = <int, Color>{};
final r = color.red, g = color.green, b = color.blue;
for (var i = 1; i < 10; i++) {
strengths.add(0.1 * i);
}
for (var strength in strengths) {
final ds = 0.5 - strength;
swatch[(strength * 1000).round()] = Color.fromRGBO(
r + ((ds < 0 ? r : (255 - r)) * ds).round(),
g + ((ds < 0 ? g : (255 - g)) * ds).round(),
b + ((ds < 0 ? b : (255 - b)) * ds).round(),
1,
);
}
return MaterialColor(color.value, swatch);
}
}