Skip to content

Commit

Permalink
Merge branch 'master' into feature/dynamic-tooltip-bgcolor
Browse files Browse the repository at this point in the history
  • Loading branch information
apekshamehta authored Aug 10, 2023
2 parents b2471aa + 5d81d61 commit 2186b3f
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 37 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
github: [imaNNeo]
custom: ["https://www.buymeacoffee.com/fl_chart"]
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ You can simply run `make checkstyle`, and if you faced any formatting problem, r

##### Run `make checkstyle` to ensure that your code is formatted correctly
- It runs `flutter analyze` to verify that there is no any warning or error.
- It runs `flutter format --set-exit-if-changed --dry-run .` to verify that code has formatted correctly.
- It runs `dart format --set-exit-if-changed --dry-run .` to verify that code has formatted correctly.

#### Run `make format` to reformat the code
- It runs `flutter format .` to format your code.
- It runs `dart format .` to format your code.


#### Run `make runTests` to ensure that all tests are passing.
Expand Down
19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
💥 FL Chart is a highly customizable Flutter chart library that supports Line Chart, Bar Chart, Pie Chart, Scatter Chart, and Radar Chart. 💥
📊 FL Chart is a highly customizable Flutter chart library that supports **[Line Chart](https://app.flchart.dev/#/line)**, **[Bar Chart](https://app.flchart.dev/#/bar)**, **[Pie Chart](https://app.flchart.dev/#/pie)**, **[Scatter Chart](https://app.flchart.dev/#/scatter)**, and **[Radar Chart](https://app.flchart.dev/#/radar)**.

<a href="https://www.buymeacoffee.com/fl_chart"><img src="https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=&slug=fl_chart&button_colour=5F7FFF&font_colour=ffffff&font_family=Cookie&outline_colour=000000&coffee_colour=FFDD00" /></a>
✅ Do you want to **motivate me to work more on fl_chart?** You can **[donate me](https://github.com/imaNNeo/fl_chart/edit/master/README.md#donation)** ;)

![FL Chart Logo](https://github.com/imaNNeo/fl_chart/raw/master/repo_files/images/landing_logo.jpg)

[![pub package](https://img.shields.io/pub/v/fl_chart.svg)](https://pub.dartlang.org/packages/fl_chart)
[![codecov](https://codecov.io/gh/imaNNeo/fl_chart/branch/master/graph/badge.svg?token=XBhsIZBbZG)](https://codecov.io/gh/imaNNeo/fl_chart)
<a href="https://github.com/Solido/awesome-flutter#charts"><img src="https://img.shields.io/badge/awesome-flutter-blue.svg?longCache=true" alt="Awesome Flutter"></a>
<a href="https://pub.dev/packages/fl_chart"><img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/imaNNeo/fl_chart"></a>
<a href="https://github.com/imaNNeo/fl_chart/graphs/contributors"><img alt="GitHub contributors" src="https://img.shields.io/github/contributors/imaNNeo/fl_chart"></a>
<a href="https://githubc.com/imaNNeo/fl_chart/issues?q=is%3Aissue+is%3Aclosed"><img src="https://img.shields.io/github/issues-closed-raw/imaNNeo/fl_chart" alt="GitHub closed issues"></a>
![GitHub Sponsors](https://img.shields.io/github/sponsors/imaNNeo)
<span class="badge-buymeacoffee">
<a href="https://www.buymeacoffee.com/fl_chart" title="Donate to this project using Buy Me A Coffee"><img src="https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg" alt="Buy Me A Coffee donate button" /></a>
</span>

![FL Chart Logo](https://github.com/imaNNeo/fl_chart/raw/master/repo_files/images/landing_logo.jpg)

### Chart Types

|LineChart |BarChart |PieChart |
Expand Down Expand Up @@ -53,13 +54,11 @@ We suggest you to check samples source code.

### Donation
Your donation **motivates** me to work more on the **fl_chart** and resolve more issues.
You can <a href="https://www.buymeacoffee.com/fl_chart">buy me a coffee!</a>

<a href="https://www.buymeacoffee.com/fl_chart"><img src="https://github.com/imaNNeo/fl_chart/raw/master/repo_files/images/buy_me_a_coffee.jpeg" width=360 /></a>

Or if you are a fan of crypto, you can donate me Bitcoins here:
There are multiple ways to donate me:

`1L7ghKdcmgydmUJAnmYmMaiVjT1LoP4a45`
1. You can be my sponsor on [GitHub](https://github.com/sponsors/imaNNeo) (This is the most reliable way to donate me)
2. You can <a href="https://www.buymeacoffee.com/fl_chart">buy me a coffee!</a>
3. Or if you are a fan of crypto, you can donate me Bitcoins here: `1L7ghKdcmgydmUJAnmYmMaiVjT1LoP4a45`

### Contributing
##### :beer: Pull requests are welcome!
Expand Down
7 changes: 7 additions & 0 deletions example/lib/presentation/menu/app_menu.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:fl_chart_app/presentation/resources/app_resources.dart';
import 'package:fl_chart_app/util/app_helper.dart';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';

import 'fl_chart_banner.dart';
import 'menu_row.dart';
Expand Down Expand Up @@ -48,6 +49,12 @@ class AppMenuState extends State<AppMenu> {
onTap: () {
widget.onItemSelected(position, menuItem);
},
onDocumentsTap: () async {
final url = Uri.parse(menuItem.chartType.documentationUrl);
if (await canLaunchUrl(url)) {
await launchUrl(url);
}
},
);
},
itemCount: widget.menuItems.length,
Expand Down
53 changes: 48 additions & 5 deletions example/lib/presentation/menu/menu_row.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,42 @@ import 'package:fl_chart_app/presentation/resources/app_resources.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';

class MenuRow extends StatelessWidget {
class MenuRow extends StatefulWidget {
final String text;
final String svgPath;
final bool isSelected;
final VoidCallback onTap;
final VoidCallback onDocumentsTap;

const MenuRow({
Key? key,
required this.text,
required this.svgPath,
required this.isSelected,
required this.onTap,
required this.onDocumentsTap,
}) : super(key: key);

bool get _showSelectedState => isSelected;
@override
State<MenuRow> createState() => _MenuRowState();
}

class _MenuRowState extends State<MenuRow> {
bool get _showSelectedState => widget.isSelected;

bool isHovered = false;

@override
Widget build(BuildContext context) {
return Material(
color: Colors.transparent,
child: InkWell(
onTap: onTap,
onHover: (bool hovered) {
setState(() {
isHovered = hovered;
});
},
onTap: widget.onTap,
child: SizedBox(
height: AppDimens.menuRowHeight,
child: Row(
Expand All @@ -32,7 +46,7 @@ class MenuRow extends StatelessWidget {
width: 36,
),
SvgPicture.asset(
svgPath,
widget.svgPath,
width: AppDimens.menuIconSize,
height: AppDimens.menuIconSize,
colorFilter:
Expand All @@ -42,16 +56,45 @@ class MenuRow extends StatelessWidget {
width: 18,
),
Text(
text,
widget.text,
style: TextStyle(
color: _showSelectedState ? AppColors.primary : Colors.white,
fontSize: AppDimens.menuTextSize,
),
),
Expanded(child: Container()),
_DocumentationIcon(onTap: widget.onDocumentsTap),
const SizedBox(
width: 18,
),
],
),
),
),
);
}
}

class _DocumentationIcon extends StatelessWidget {
const _DocumentationIcon({
Key? key,
required this.onTap,
}) : super(key: key);
final VoidCallback onTap;

@override
Widget build(BuildContext context) {
return SizedBox(
width: AppDimens.menuDocumentationIconSize,
height: AppDimens.menuDocumentationIconSize,
child: IconButton(
onPressed: onTap,
icon: const Icon(
Icons.article,
color: AppColors.contentColorWhite,
),
tooltip: 'Documentation',
),
);
}
}
4 changes: 2 additions & 2 deletions example/lib/presentation/pages/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class HomePage extends StatelessWidget {
_menuItemsIndices[type] = index;
return ChartMenuItem(
type,
type.getSimpleName(),
type.displayName,
type.assetIcon,
);
},
Expand Down Expand Up @@ -78,7 +78,7 @@ class HomePage extends StatelessWidget {
? AppBar(
elevation: 0,
backgroundColor: Colors.transparent,
title: Text(showingChartType.getDisplayName()),
title: Text(showingChartType.displayName),
)
: null,
);
Expand Down
5 changes: 3 additions & 2 deletions example/lib/presentation/resources/app_dimens.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
class AppDimens {
static const double menuMaxNeededWidth = 304;
static const double menuRowHeight = 74;
static const double menuIconSize = 36;
static const double menuTextSize = 24;
static const double menuIconSize = 32;
static const double menuDocumentationIconSize = 44;
static const double menuTextSize = 20;

static const double chartBoxMinWidth = 350;

Expand Down
2 changes: 1 addition & 1 deletion example/lib/presentation/samples/chart_sample.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ abstract class ChartSample {
final int number;
final WidgetBuilder builder;
ChartType get type;
String get name => '${type.getDisplayName()} Sample $number';
String get name => '${type.displayName} Sample $number';
String get url => Urls.getChartSourceCodeUrl(type, number);
ChartSample(this.number, this.builder);
}
Expand Down
5 changes: 5 additions & 0 deletions example/lib/urls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@ class Urls {
final chartDir = chartType.name.toLowerCase();
return 'https://github.com/imaNNeo/fl_chart/blob/master/example/lib/presentation/samples/$chartDir/${chartDir}_chart_sample$sampleNumber.dart';
}

static String getChartDocumentationUrl(ChartType chartType) {
final chartDir = chartType.name.toLowerCase();
return 'https://github.com/imaNNeo/fl_chart/blob/master/repo_files/documentations/${chartDir}_chart.md';
}
}
26 changes: 11 additions & 15 deletions example/lib/util/app_helper.dart
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
import 'package:fl_chart_app/presentation/resources/app_resources.dart';
import 'package:fl_chart_app/urls.dart';

enum ChartType { line, bar, pie, scatter, radar }

extension ChartTypeExtension on ChartType {
String getDisplayName() => '${getSimpleName()} Chart';
String get displayName => '$simpleName Chart';

String getSimpleName() {
switch (this) {
case ChartType.line:
return 'Line';
case ChartType.bar:
return 'Bar';
case ChartType.pie:
return 'Pie';
case ChartType.scatter:
return 'Scatter';
case ChartType.radar:
return 'Radar';
}
}
String get simpleName => switch (this) {
ChartType.line => 'Line',
ChartType.bar => 'Bar',
ChartType.pie => 'Pie',
ChartType.scatter => 'Scatter',
ChartType.radar => 'Radar',
};

String get documentationUrl => Urls.getChartDocumentationUrl(this);

String get assetIcon => AppAssets.getChartIcon(this);
}
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ environment:
sdk: ^3.0.0

funding:
- https://github.com/sponsors/imaNNeo
- https://www.buymeacoffee.com/fl_chart

dependencies:
Expand Down

0 comments on commit 2186b3f

Please sign in to comment.