diff --git a/example/lib/main.dart b/example/lib/main.dart index 15a52e0..64c4fa6 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -136,6 +136,29 @@ class MyHomePage extends StatelessWidget { child: const Text('Action 2')) ], ), + Text( + 'Classic Admonitions', + style: Theme.of(context).textTheme.headline6, + ), + const ClassicAdmonition.note( + text: '(Note) You might read this, you might not.', + ), + const ClassicAdmonition.tip( + text: '(Tip) You want to read this.', + ), + const ClassicAdmonition.info( + text: '(Info/Important) You should read this.', + ), + const ClassicAdmonition.caution( + text: '(Caution) I hope you read this.', + ), + const ClassicAdmonition.danger( + text: '(Danger) You need to read this.', + ), + const ClassicAdmonition( + text: + '(Raw) Background colour is defaulted to your app primary colour.', + ), ], ), ), diff --git a/example/linux/flutter/generated_plugins.cmake b/example/linux/flutter/generated_plugins.cmake index 51436ae..2e1de87 100644 --- a/example/linux/flutter/generated_plugins.cmake +++ b/example/linux/flutter/generated_plugins.cmake @@ -5,6 +5,9 @@ list(APPEND FLUTTER_PLUGIN_LIST ) +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + set(PLUGIN_BUNDLED_LIBRARIES) foreach(plugin ${FLUTTER_PLUGIN_LIST}) @@ -13,3 +16,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST}) list(APPEND PLUGIN_BUNDLED_LIBRARIES $) list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/example/windows/flutter/generated_plugins.cmake b/example/windows/flutter/generated_plugins.cmake index 4d10c25..b93c4c3 100644 --- a/example/windows/flutter/generated_plugins.cmake +++ b/example/windows/flutter/generated_plugins.cmake @@ -5,6 +5,9 @@ list(APPEND FLUTTER_PLUGIN_LIST ) +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + set(PLUGIN_BUNDLED_LIBRARIES) foreach(plugin ${FLUTTER_PLUGIN_LIST}) @@ -13,3 +16,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST}) list(APPEND PLUGIN_BUNDLED_LIBRARIES $) list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/lib/admonitions.dart b/lib/admonitions.dart index a31729f..76cc21b 100644 --- a/lib/admonitions.dart +++ b/lib/admonitions.dart @@ -2,3 +2,4 @@ library admonitions; export 'src/solid.dart'; export 'src/pastel.dart'; +export 'src/classic.dart'; diff --git a/lib/src/classic.dart b/lib/src/classic.dart new file mode 100644 index 0000000..aaa9406 --- /dev/null +++ b/lib/src/classic.dart @@ -0,0 +1,139 @@ +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; + +class ClassicAdmonition extends StatelessWidget { + /// Classic admonitions (solid line on the left, pastel colour on the right) + const ClassicAdmonition( + {Key? key, + this.child, + this.text, + this.color = Colors.blue, + this.icon, + this.opacity = .3, + this.actions, + this.primaryColor}) + : assert(child == null || text == null, + 'Either child or text is allowed to exist'), + super(key: key); + + const ClassicAdmonition.note({ + Key? key, + this.child, + this.text, + this.color = const Color(0xffebedf0), + this.icon = const FaIcon(FontAwesomeIcons.circleInfo), + this.opacity = .3, + this.actions, + this.primaryColor, + }) : super(key: key); + + const ClassicAdmonition.tip({ + Key? key, + this.child, + this.text, + this.color = const Color(0xff00a400), + this.icon = const FaIcon(FontAwesomeIcons.lightbulb), + this.opacity = .3, + this.actions, + this.primaryColor, + }) : super(key: key); + + const ClassicAdmonition.info({ + Key? key, + this.child, + this.text, + this.color = const Color(0xff54c7ec), + this.icon = const FaIcon(FontAwesomeIcons.circleExclamation), + this.opacity = .3, + this.actions, + this.primaryColor, + }) : super(key: key); + const ClassicAdmonition.caution({ + Key? key, + this.child, + this.text, + this.color = const Color(0xffffba00), + this.icon = const FaIcon(FontAwesomeIcons.triangleExclamation), + this.opacity = .3, + this.actions, + this.primaryColor, + }) : super(key: key); + const ClassicAdmonition.danger({ + Key? key, + this.child, + this.text, + this.color = const Color(0xfffa383e), + this.icon = const FaIcon(FontAwesomeIcons.fire), + this.opacity = .3, + this.actions, + this.primaryColor, + }) : super(key: key); + + final String? text; + + final Widget? child; + + final Color? color; + + final Widget? icon; + + final double opacity; + + final Color? primaryColor; + + final List? actions; + + @override + Widget build(BuildContext context) { + return Container( + margin: const EdgeInsets.all(4), + child: ClipRRect( + borderRadius: BorderRadius.circular(16), + child: Stack(children: [ + Positioned.fromRect( + rect: Rect.fromLTRB(0, 0, 8, 400), + child: Container( + color: color, + // constraints: BoxConstraints.expand(), + ), + ), + Container( + padding: const EdgeInsets.all(14), + color: + (color ?? Theme.of(context).primaryColor).withOpacity(opacity), + child: Column( + children: [ + Row( + children: [ + if (icon != null) ...[ + IconTheme( + data: IconThemeData( + color: primaryColor ?? + Theme.of(context).iconTheme.color, + size: 18), + child: icon!), + const SizedBox(width: 10) + ], + if (text != null) + DefaultTextStyle( + style: TextStyle( + color: primaryColor ?? + Theme.of(context).textTheme.bodyText1!.color), + child: Flexible(child: Text(text!))) + else + child! + ], + ), + if (actions != null) + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: actions!, + ) + ], + ), + ), + ]), + ), + ); + } +}