teste gráfico

This commit is contained in:
2021-09-01 18:18:35 -03:00
parent 2900361025
commit c995325ba7
5 changed files with 509 additions and 1 deletions
+314
View File
@@ -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 = <Control>[];
// sampleList = <SubItem>[];
// searchResults = <SubItem>[];
// searchSampleItems = <SubItem>[];
// 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<String, Function> sampleWidget = getSampleWidget();
//ignore:prefer_final_fields
// static List<Control> _controlList = <Control>[];
// //ignore:prefer_final_fields
// static List<WidgetCategory> _categoryList = <WidgetCategory>[];
// /// Holds the category list
// late List<WidgetCategory> categoryList;
// /// Holds the sorted control list
// late List<Control> controlList;
// /// Holds the searched control list
// late List<Control> searchControlItems;
// ///List of all the samples
// late List<SubItem> sampleList;
// /// To handle search
// late List<SubItem> searchSampleItems;
// /// To handle search
// late List<SubItem> 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<SampleRoute> _routes = <SampleRoute>[];
/// List of navigation routes text and appropriate subitem
//late List<SampleRoute>? 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<Color>? paletteColors;
/// Contains the pallete's border colors
late List<Color>? paletteBorderColors;
/// Contains dark theme theme palatte colors
late List<Color>? 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<State> 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<SampleRoute> sampleRoutes = <SampleRoute>[];
/// 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<VoidCallback> _listeners = Set<VoidCallback>();
@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<SampleView> {
/// 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;
}
}
+167
View File
@@ -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>[
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>[
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: <GaugePointer>[
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>[Color(0xFF4DACF7), Color(0xFF426ED6)],
stops: <double>[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;
}
+13 -1
View File
@@ -1,10 +1,13 @@
import 'package:decpisos/charts/radial_gauge.dart';
import 'package:decpisos/funcoes_gerais.dart'; import 'package:decpisos/funcoes_gerais.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:line_icons/line_icons.dart'; import 'package:line_icons/line_icons.dart';
import 'package:syncfusion_flutter_gauges/gauges.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
import 'package:webview_flutter/webview_flutter.dart'; import 'package:webview_flutter/webview_flutter.dart';
class HomeScreen extends StatefulWidget { class HomeScreen extends StatefulWidget {
@override @override
_HomeScreenState createState() => _HomeScreenState(); _HomeScreenState createState() => _HomeScreenState();
@@ -32,7 +35,16 @@ class _HomeScreenState extends State<HomeScreen> with AutomaticKeepAliveClientMi
}, },
tooltip: 'Alternar modo dark/light', tooltip: 'Alternar modo dark/light',
icon: Icon(LineIcons.palette) 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( body: SafeArea(
+14
View File
@@ -579,6 +579,20 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" 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: term_glyph:
dependency: transitive dependency: transitive
description: description:
+1
View File
@@ -53,6 +53,7 @@ dependencies:
#advance_pdf_viewer: ^2.0.0 #advance_pdf_viewer: ^2.0.0
path_provider: ^2.0.2 path_provider: ^2.0.2
flutter_pdfview: ^1.1.0 flutter_pdfview: ^1.1.0
syncfusion_flutter_gauges: ^19.2.59
dev_dependencies: dev_dependencies:
flutter_test: flutter_test: