From c995325ba77c9d47feb25dd6d7fef7c2b178fe68 Mon Sep 17 00:00:00 2001 From: developer1054 Date: Wed, 1 Sep 2021 18:18:35 -0300 Subject: [PATCH] =?UTF-8?q?teste=20gr=C3=A1fico?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/charts/model.dart | 314 +++++++++++++++++++++++++++++++++++ lib/charts/radial_gauge.dart | 167 +++++++++++++++++++ lib/home/home.dart | 14 +- pubspec.lock | 14 ++ pubspec.yaml | 1 + 5 files changed, 509 insertions(+), 1 deletion(-) create mode 100644 lib/charts/model.dart create mode 100644 lib/charts/radial_gauge.dart diff --git a/lib/charts/model.dart b/lib/charts/model.dart new file mode 100644 index 0000000..2bb6601 --- /dev/null +++ b/lib/charts/model.dart @@ -0,0 +1,314 @@ +import 'package:flutter/material.dart'; +/// SampleModel class is the base of the Sample browser +/// It contains the category, control, theme information +class SampleModel extends Listenable { + /// Contains the category, control, theme information + SampleModel() { + // searchControlItems = []; + // sampleList = []; + // searchResults = []; + // searchSampleItems = []; + // categoryList = SampleModel._categoryList; + // controlList = SampleModel._controlList; + // routes = SampleModel._routes; + // searchControlItems.addAll(controlList); + // for (int index = 0; index < controlList.length; index++) { + // if (controlList[index].sampleList != null) { + // for (int i = 0; i < controlList[index].sampleList!.length; i++) { + // searchSampleItems.add(controlList[index].sampleList![i]); + // } + // } else if (controlList[index].childList != null) { + // for (int i = 0; i < controlList[index].childList!.length; i++) { + // for (int j = 0; + // j < controlList[index].childList![i].subItems!.length; + // j++) { + // if (controlList[index].childList![i].subItems![j].type != 'child') { + // searchSampleItems + // .add(controlList[index].childList![i].subItems![j]); + // } else { + // //ignore: prefer_foreach + // for (final SubItem sample + // in controlList[index].childList![i].subItems![j].subItems) { + // searchSampleItems.add(sample); + // } + // } + // } + // } + // } else { + // for (int i = 0; i < controlList[index].subItems!.length; i++) { + // for (int j = 0; + // j < controlList[index].subItems![i].subItems.length; + // j++) { + // for (int k = 0; + // k < controlList[index].subItems![i].subItems[j].subItems.length; + // k++) { + // searchSampleItems + // .add(controlList[index].subItems![i].subItems[j].subItems[k]); + // } + // } + // } + // } + // } + } + + /// Used to create the instance of [SampleModel] + static SampleModel instance = SampleModel(); + + /// Contains the output widget of sample + /// appropriate key and output widget mapped + //final Map sampleWidget = getSampleWidget(); + //ignore:prefer_final_fields + // static List _controlList = []; + // //ignore:prefer_final_fields + // static List _categoryList = []; + + // /// Holds the category list + // late List categoryList; + + // /// Holds the sorted control list + // late List controlList; + + // /// Holds the searched control list + // late List searchControlItems; + + // ///List of all the samples + // late List sampleList; + + // /// To handle search + // late List searchSampleItems; + + // /// To handle search + // late List searchResults; + + /// holds theme based current palette color + Color backgroundColor = const Color.fromRGBO(0, 116, 227, 1); + + /// holds light theme current palette color + Color paletteColor = const Color.fromRGBO(0, 116, 227, 1); + + /// holds current palette color + /// on toggling the palette colors before or after apply settings + Color currentPrimaryColor = const Color.fromRGBO(0, 116, 227, 1); + + /// holds the current theme data + late ThemeData themeData; + + /// Holds theme baased color of web outputcontainer + Color textColor = const Color.fromRGBO(51, 51, 51, 1); + + /// Holds theme based drawer text color + Color drawerTextIconColor = Colors.black; + + /// Holds theme based bottom sheet color + Color bottomSheetBackgroundColor = Colors.white; + + /// Holds theme based card color + Color cardThemeColor = Colors.white; + + /// Holds theme based web page background color + Color webBackgroundColor = const Color.fromRGBO(246, 246, 246, 1); + + /// Holds theme based color of icon + Color webIconColor = const Color.fromRGBO(0, 0, 0, 0.54); + + /// Holds theme based input container color + Color webInputColor = const Color.fromRGBO(242, 242, 242, 1); + + /// Holds theme based web outputcontainer color + Color webOutputContainerColor = Colors.white; + + /// Holds the theme based card's color + Color cardColor = Colors.white; + + /// Holds the theme based divider color + Color dividerColor = const Color.fromRGBO(204, 204, 204, 1); + + /// Holds the old browser window's height and width + Size? oldWindowSize; + + /// Holds the current browser window's height and width + late Size currentWindowSize; + + //static List _routes = []; + + /// List of navigation routes text and appropriate subitem + //late List? routes; + + /// Holds the current visible sample, only for web + late dynamic currentRenderSample; + + /// Holds the current rendered sample's key, only for web + late String? currentSampleKey; + + /// Contains the light theme pallete colors + late List? paletteColors; + + /// Contains the pallete's border colors + late List? paletteBorderColors; + + /// Contains dark theme theme palatte colors + late List? darkPaletteColors; + + /// Holds current theme data + ThemeData? currentThemeData; + + /// Holds current pallete color + Color currentPaletteColor = const Color.fromRGBO(0, 116, 227, 1); + + /// holds the index to finding the current theme + /// In mobile sb - system 0, light 1, dark 2 + int selectedThemeIndex = 0; + + /// Holds the information of isCardView or not + bool isCardView = true; + + /// Holds the information of isMobileResolution or not + /// To render the appbar and search bar based on it + late bool isMobileResolution; + + /// Holds the current system theme + late ThemeData systemTheme; + + /// Editing controller which used in the search text field + TextEditingController editingController = TextEditingController(); + + /// Key of the property panel widget + late GlobalKey propertyPanelKey; + + /// Holds the information of to be maximize or not + bool needToMaximize = false; + + ///Storing state of current output container + late dynamic outputContainerState; + + ///Storing state of web output container + //late SampleOutputContainerState webOutputContainerState; + + ///check whether application is running on web/linuxOS/windowsOS/macOS + bool isWebFullView = false; + + ///Check whether application is running on a mobile device + bool isMobile = false; + + ///Check whether application is running on the web browser + bool isWeb = false; + + ///Check whether application is running on the desktop + bool isDesktop = false; + + ///Check whether application is running on the Android mobile device + bool isAndroid = false; + + ///Check whether application is running on the Windows desktop OS + bool isWindows = false; + + ///Check whether application is running on the iOS mobile device + bool isIOS = false; + + ///Check whether application is running on the Linux desktop OS + bool isLinux = false; + + ///Check whether application is running on the macOS desktop + bool isMacOS = false; + + /// This controls to open / hide the property panel + bool isPropertyPanelOpened = true; + + /// holds the current route of sample. + //late SampleRoute currentSampleRoute; + + /// holds the collection of all sample routes. + //static List sampleRoutes = []; + + /// Switching between light, dark, system themes + void changeTheme(ThemeData _themeData) { + themeData = _themeData; + switch (_themeData.brightness) { + case Brightness.dark: + { + dividerColor = const Color.fromRGBO(61, 61, 61, 1); + cardColor = const Color.fromRGBO(48, 48, 48, 1); + webIconColor = const Color.fromRGBO(255, 255, 255, 0.65); + webOutputContainerColor = const Color.fromRGBO(23, 23, 23, 1); + webInputColor = const Color.fromRGBO(44, 44, 44, 1); + webBackgroundColor = const Color.fromRGBO(33, 33, 33, 1); + drawerTextIconColor = Colors.white; + bottomSheetBackgroundColor = const Color.fromRGBO(34, 39, 51, 1); + textColor = const Color.fromRGBO(242, 242, 242, 1); + cardThemeColor = const Color.fromRGBO(33, 33, 33, 1); + break; + } + default: + { + dividerColor = const Color.fromRGBO(204, 204, 204, 1); + cardColor = Colors.white; + webIconColor = const Color.fromRGBO(0, 0, 0, 0.54); + webOutputContainerColor = Colors.white; + webInputColor = const Color.fromRGBO(242, 242, 242, 1); + webBackgroundColor = const Color.fromRGBO(246, 246, 246, 1); + drawerTextIconColor = Colors.black; + bottomSheetBackgroundColor = Colors.white; + textColor = const Color.fromRGBO(51, 51, 51, 1); + cardThemeColor = Colors.white; + break; + } + } + } + + //ignore: prefer_collection_literals + final Set _listeners = Set(); + @override + + /// [listener] will be invoked when the model changes. + void addListener(VoidCallback listener) { + _listeners.add(listener); + } + + @override + + /// [listener] will no longer be invoked when the model changes. + void removeListener(VoidCallback listener) { + _listeners.remove(listener); + } + + /// Should be called only by [Model] when the model has changed. + @protected + void notifyListeners() { + _listeners.toList().forEach((VoidCallback listener) => listener()); + } +} + +/// Base class of the sample's stateful widget class +abstract class SampleView extends StatefulWidget { + /// base class constructor of sample's stateful widget class + const SampleView({Key? key}) : super(key: key); +} + +/// Base class of the sample's state class +abstract class SampleViewState extends State { + /// Holds the SampleModel information + late SampleModel model; + + /// Holds the information of current page is card view or not + late bool isCardView; + + @override + void initState() { + model = SampleModel.instance; + isCardView = model.isCardView && !model.isWebFullView; + super.initState(); + } + + @override + + /// Must call super. + void dispose() { + model.isCardView = true; + super.dispose(); + } + + /// Get the settings panel content. + Widget? buildSettings(BuildContext context) { + return null; + } +} \ No newline at end of file diff --git a/lib/charts/radial_gauge.dart b/lib/charts/radial_gauge.dart new file mode 100644 index 0000000..69b2ec4 --- /dev/null +++ b/lib/charts/radial_gauge.dart @@ -0,0 +1,167 @@ +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_gauges/gauges.dart'; + +import 'model.dart'; +/// Renders the gauge pointer ease animation sample +class RadialEaseExample extends SampleView { + /// Creates gauge with ease animation + //const RadialEaseExample(Key key) : super(key: key); + + @override + _RadialEaseExampleState createState() => _RadialEaseExampleState(); +} + +class _RadialEaseExampleState extends SampleViewState { + _RadialEaseExampleState(); + + @override + Widget build(BuildContext context) { + return _buildRadialEaseExample(); + } + + /// Return the gauge pointer ease animation gauge + SfRadialGauge _buildRadialEaseExample() { + return SfRadialGauge( + axes: [ + RadialAxis( + startAngle: 300, + endAngle: 240, + showLabels: false, + showTicks: false, + radiusFactor: model.isWebFullView ? 0.8 : 0.9, + axisLineStyle: AxisLineStyle( + cornerStyle: CornerStyle.bothCurve, + thicknessUnit: GaugeSizeUnit.factor, + thickness: isCardView ? 0.1 : 0.1)), + RadialAxis( + startAngle: 300, + endAngle: 240, + showTicks: false, + labelFormat: '{value}M', + onLabelCreated: _handleLabelCreated, + showAxisLine: false, + radiusFactor: model.isWebFullView ? 0.8 : 0.9, + minimum: 0, + maximum: 15, + axisLabelStyle: GaugeTextStyle( + fontSize: isCardView ? 10 : 12, fontWeight: FontWeight.w500), + labelOffset: 25, + interval: isCardView ? 1 : _interval, + canRotateLabels: true, + annotations: [ + GaugeAnnotation( + positionFactor: 1, + axisValue: 0, + widget: Container( + height: isCardView ? 30 : 45, + width: isCardView ? 30 : 45, + // decoration: const BoxDecoration( + // image: DecorationImage( + // image: ExactAssetImage('assets/images/foguete.png'), + // fit: BoxFit.fitHeight, + // ), + // ) + ) + ), + GaugeAnnotation( + widget: Container( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + const Text('R\$', style: TextStyle(fontSize: 12)), + const Text('460', style: TextStyle(fontSize: 30)), + ], + ), + //const Text('21 a 28 de Nov', style: TextStyle(fontSize: 12,fontWeight: FontWeight.w300)), + ], + ), + )) + ], + pointers: [ + const RangePointer( + value: 11.5, + width: 0.1, + color: Color(0xFFF67280), + enableAnimation: true, + sizeUnit: GaugeSizeUnit.factor, + animationType: AnimationType.ease, + cornerStyle: CornerStyle.bothCurve, + gradient: SweepGradient( + colors: [Color(0xFF4DACF7), Color(0xFF426ED6)], + stops: [0.25, 0.75]), + ), + MarkerPointer( + value: 3, + markerType: MarkerType.image, + enableAnimation: true, + animationType: AnimationType.ease, + //imageUrl: 'https://github.com/syncfusion/flutter-examples/blob/master/images/ball_progressbar.png?raw=true', + imageUrl: 'assets/images/logo.png', + markerHeight: isCardView + ? 30 + : model.isWebFullView + ? 45 + : 40, + markerOffset: 4, + markerWidth: isCardView + ? 30 + : model.isWebFullView + ? 45 + : 40, + ), + MarkerPointer( + value: 7, + markerType: MarkerType.image, + enableAnimation: true, + animationType: AnimationType.ease, + //imageUrl: 'https://github.com/syncfusion/flutter-examples/blob/master/images/ball_progressbar.png?raw=true', + imageUrl: 'assets/images/logo.png', + markerHeight: isCardView + ? 30 + : model.isWebFullView + ? 45 + : 40, + markerOffset: 4, + markerWidth: isCardView + ? 30 + : model.isWebFullView + ? 45 + : 40, + ), + MarkerPointer( + value: 13, + markerType: MarkerType.image, + enableAnimation: true, + animationType: AnimationType.ease, + //imageUrl: 'https://github.com/syncfusion/flutter-examples/blob/master/images/ball_progressbar.png?raw=true', + imageUrl: 'assets/images/logo.png', + markerHeight: isCardView + ? 30 + : model.isWebFullView + ? 45 + : 40, + markerOffset: 4, + markerWidth: isCardView + ? 30 + : model.isWebFullView + ? 45 + : 40, + ) + ]) + ], + ); + } + + /// Handled callback to hide last label value. + void _handleLabelCreated(AxisLabelCreatedArgs args) { + if (args.text == '15M') { + args.text = '15M'; + } + } + + final double _interval = 1; +} \ No newline at end of file diff --git a/lib/home/home.dart b/lib/home/home.dart index 9e87e5c..a911ec5 100644 --- a/lib/home/home.dart +++ b/lib/home/home.dart @@ -1,10 +1,13 @@ +import 'package:decpisos/charts/radial_gauge.dart'; import 'package:decpisos/funcoes_gerais.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:line_icons/line_icons.dart'; +import 'package:syncfusion_flutter_gauges/gauges.dart'; import 'package:url_launcher/url_launcher.dart'; import 'package:webview_flutter/webview_flutter.dart'; + class HomeScreen extends StatefulWidget { @override _HomeScreenState createState() => _HomeScreenState(); @@ -32,7 +35,16 @@ class _HomeScreenState extends State with AutomaticKeepAliveClientMi }, tooltip: 'Alternar modo dark/light', icon: Icon(LineIcons.palette) - ) + ), + IconButton(onPressed: (){ + Get.bottomSheet(BottomSheet(onClosing: ()=>null, builder: (_){ + return Padding( + padding: const EdgeInsets.all(8.0), + child: RadialEaseExample(), + ); + })); + //Get.to(() => Scaffold(appBar: AppBar(),body: RadialEaseExample())); + }, icon: Icon(Icons.monetization_on_outlined)) ], ), body: SafeArea( diff --git a/pubspec.lock b/pubspec.lock index 11a4211..34c81d9 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -579,6 +579,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.0" + syncfusion_flutter_core: + dependency: transitive + description: + name: syncfusion_flutter_core + url: "https://pub.dartlang.org" + source: hosted + version: "19.2.59" + syncfusion_flutter_gauges: + dependency: "direct main" + description: + name: syncfusion_flutter_gauges + url: "https://pub.dartlang.org" + source: hosted + version: "19.2.59" term_glyph: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index b69d630..98916c2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -53,6 +53,7 @@ dependencies: #advance_pdf_viewer: ^2.0.0 path_provider: ^2.0.2 flutter_pdfview: ^1.1.0 + syncfusion_flutter_gauges: ^19.2.59 dev_dependencies: flutter_test: