Merge pull request #3 from LEG-Industries/steps-page

Steps page
This commit is contained in:
Benjamin Ramhorst 2022-02-09 19:32:20 +00:00 committed by GitHub
commit cdcd7d6d6b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 133 additions and 14 deletions

View file

@ -1,8 +1,8 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:leg_barkr_app/data.dart'; import 'package:leg_barkr_app/view/steps/steps_page.dart';
import 'package:leg_barkr_app/steps.dart'; import 'package:leg_barkr_app/view/data_page.dart';
import 'package:leg_barkr_app/map.dart'; import 'package:leg_barkr_app/view/map_page.dart';
import 'package:leg_barkr_app/settings.dart'; import 'package:leg_barkr_app/view/settings_page.dart';
class HomeScreen extends StatefulWidget { class HomeScreen extends StatefulWidget {
const HomeScreen({Key? key}) : super(key: key); const HomeScreen({Key? key}) : super(key: key);
@ -25,6 +25,7 @@ class _HomeScreenState extends State<HomeScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
backgroundColor: Colors.white,
body: PageView( body: PageView(
controller: _pageController, controller: _pageController,
children: const <Widget>[ children: const <Widget>[

View file

@ -1,7 +1,9 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:leg_barkr_app/home.dart'; import 'package:leg_barkr_app/home.dart';
import 'package:flutter/services.dart';
void main() { void main() {
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(statusBarColor: Colors.black12));
runApp(const Main()); runApp(const Main());
} }

View file

@ -0,0 +1,6 @@
class StepsSeries {
final DateTime date;
final int steps;
StepsSeries(this.date, this.steps);
}

View file

@ -1,10 +0,0 @@
import 'package:flutter/material.dart';
class StepsPage extends StatelessWidget {
const StepsPage({ Key? key }) : super(key: key);
@override
Widget build(BuildContext context) {
return Text("Data Page");
}
}

View file

@ -0,0 +1,29 @@
import 'package:flutter/material.dart';
import 'package:charts_flutter/flutter.dart' as charts;
import 'package:leg_barkr_app/model/steps_series.dart';
class StepsChart extends StatelessWidget {
List<StepsSeries> data;
StepsChart(this.data);
@override
Widget build(BuildContext context) {
List<charts.Series<StepsSeries, String>> series = [
charts.Series(
id: "Steps",
data: data,
domainFn: (StepsSeries series, _) => series.date.day.toString() + "/" + series.date.month.toString(),
measureFn: (StepsSeries series, _) => series.steps,
colorFn: (StepsSeries series, _) => charts.ColorUtil.fromDartColor(Colors.green)
)
];
return Container(
height: 600,
width: double.infinity,
child: charts.BarChart(series, animate: true)
);
}
}

View file

@ -0,0 +1,40 @@
import 'package:charts_flutter/flutter.dart' as charts;
import 'package:flutter/material.dart';
import 'package:leg_barkr_app/model/steps_series.dart';
import 'package:leg_barkr_app/view/steps/steps_chart.dart';
import 'package:leg_barkr_app/view/steps/steps_today.dart';
class StepsPage extends StatefulWidget {
const StepsPage({ Key? key }) : super(key: key);
@override
_StepsPageState createState() => _StepsPageState();
}
class _StepsPageState extends State<StepsPage> {
// Dummy data
final List<StepsSeries> data = [
StepsSeries(DateTime.utc(2022, 2, 9), 9867),
StepsSeries(DateTime.utc(2022, 2, 8), 8123),
StepsSeries(DateTime.utc(2022, 2, 7), 10234),
StepsSeries(DateTime.utc(2022, 2, 6), 6521),
StepsSeries(DateTime.utc(2022, 2, 5), 1021),
StepsSeries(DateTime.utc(2022, 2, 4), 10567),
StepsSeries(DateTime.utc(2022, 2, 3), 7500)
];
@override
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.fromLTRB(0.0, 50.0, 10.0, 0.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
StepsToday(5123),
new Expanded(child: StepsChart(data))
],
)
);
}
}

View file

@ -0,0 +1,22 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class StepsToday extends StatelessWidget {
int count;
StepsToday(this.count);
@override
Widget build(BuildContext context) {
return Container(
child: Column(
children: [
Text("Steps today", style: TextStyle(color: Colors.black, fontWeight: FontWeight.bold, fontSize: 20), textAlign: TextAlign.center),
Text(count.toString(), style: TextStyle(color: Colors.green, fontWeight: FontWeight.bold, fontSize: 40), textAlign: TextAlign.center)
],
)
);
}
}

View file

@ -29,6 +29,20 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.1" version: "1.3.1"
charts_common:
dependency: transitive
description:
name: charts_common
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.0"
charts_flutter:
dependency: "direct main"
description:
name: charts_flutter
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.0"
clock: clock:
dependency: transitive dependency: transitive
description: description:
@ -128,6 +142,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.15.0" version: "0.15.0"
intl:
dependency: transitive
description:
name: intl
url: "https://pub.dartlang.org"
source: hosted
version: "0.17.0"
js: js:
dependency: transitive dependency: transitive
description: description:
@ -149,6 +170,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.1" version: "1.0.1"
logging:
dependency: transitive
description:
name: logging
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
matcher: matcher:
dependency: transitive dependency: transitive
description: description:

View file

@ -36,6 +36,7 @@ dependencies:
cupertino_icons: ^1.0.2 cupertino_icons: ^1.0.2
google_maps_flutter: ^2.1.1 google_maps_flutter: ^2.1.1
google_maps_flutter_web: ^0.3.2+1 google_maps_flutter_web: ^0.3.2+1
charts_flutter: ^0.12.0
dev_dependencies: dev_dependencies:
flutter_test: flutter_test: