duplication
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
c7c2cb2f83
commit
624993f516
@ -1,430 +0,0 @@
|
|||||||
import 'package:fl_chart/fl_chart.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
import '../../common/colo_extension.dart';
|
|
||||||
import '../../common_widget/today_target_cell.dart';
|
|
||||||
|
|
||||||
class ActivityTrackerView extends StatefulWidget {
|
|
||||||
const ActivityTrackerView({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<ActivityTrackerView> createState() => _ActivityTrackerViewState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ActivityTrackerViewState extends State<ActivityTrackerView> {
|
|
||||||
int touchedIndex = -1;
|
|
||||||
|
|
||||||
List latestArr = [
|
|
||||||
{
|
|
||||||
"image": "assets/img/workout1.svg",
|
|
||||||
"title": "Drinking 300ml Water",
|
|
||||||
"time": "About 1 minutes ago"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"image": "assets/img/workout1.svg",
|
|
||||||
"title": "Eat Snack (Fitbar)",
|
|
||||||
"time": "About 3 hours ago"
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
var media = MediaQuery.of(context).size;
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
backgroundColor: TColor.white,
|
|
||||||
centerTitle: true,
|
|
||||||
elevation: 0,
|
|
||||||
leading: InkWell(
|
|
||||||
onTap: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
child: Container(
|
|
||||||
margin: const EdgeInsets.all(8),
|
|
||||||
height: 40,
|
|
||||||
width: 40,
|
|
||||||
alignment: Alignment.center,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: TColor.lightGray,
|
|
||||||
borderRadius: BorderRadius.circular(10)),
|
|
||||||
child: Image.asset(
|
|
||||||
"assets/img/black_btn.png",
|
|
||||||
width: 15,
|
|
||||||
height: 15,
|
|
||||||
fit: BoxFit.contain,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
title: Text(
|
|
||||||
"Suivi d'activité",
|
|
||||||
style: TextStyle(
|
|
||||||
color: TColor.black, fontSize: 16, fontWeight: FontWeight.w700),
|
|
||||||
),
|
|
||||||
actions: [
|
|
||||||
InkWell(
|
|
||||||
onTap: () {},
|
|
||||||
child: Container(
|
|
||||||
margin: const EdgeInsets.all(8),
|
|
||||||
height: 40,
|
|
||||||
width: 40,
|
|
||||||
alignment: Alignment.center,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: TColor.lightGray,
|
|
||||||
borderRadius: BorderRadius.circular(10)),
|
|
||||||
child: Image.asset(
|
|
||||||
"assets/img/more_btn.png",
|
|
||||||
width: 15,
|
|
||||||
height: 15,
|
|
||||||
fit: BoxFit.contain,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
backgroundColor: TColor.white,
|
|
||||||
body: SingleChildScrollView(
|
|
||||||
child: Container(
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 25, horizontal: 25),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
padding:
|
|
||||||
const EdgeInsets.symmetric(vertical: 15, horizontal: 15),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
gradient: LinearGradient(colors: [
|
|
||||||
TColor.primaryColor2.withOpacity(0.3),
|
|
||||||
TColor.primaryColor1.withOpacity(0.3)
|
|
||||||
]),
|
|
||||||
borderRadius: BorderRadius.circular(15),
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
"Objectif d'aujourd'hui",
|
|
||||||
style: TextStyle(
|
|
||||||
color: TColor.black,
|
|
||||||
fontSize: 14,
|
|
||||||
fontWeight: FontWeight.w700),
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
width: 30,
|
|
||||||
height: 30,
|
|
||||||
child: Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
gradient: LinearGradient(
|
|
||||||
colors: TColor.primaryG,
|
|
||||||
),
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
),
|
|
||||||
child: MaterialButton(
|
|
||||||
onPressed: () {},
|
|
||||||
padding: EdgeInsets.zero,
|
|
||||||
height: 30,
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(25)),
|
|
||||||
textColor: TColor.primaryColor1,
|
|
||||||
minWidth: double.maxFinite,
|
|
||||||
elevation: 0,
|
|
||||||
color: Colors.transparent,
|
|
||||||
child: const Icon(
|
|
||||||
Icons.add,
|
|
||||||
color: Colors.white,
|
|
||||||
size: 15,
|
|
||||||
)),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 15,
|
|
||||||
),
|
|
||||||
const Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: TodayTargetCell(
|
|
||||||
icon: "assets/img/workout1.svg",
|
|
||||||
value: "800",
|
|
||||||
title: "Calories",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
width: 15,
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: TodayTargetCell(
|
|
||||||
icon: "assets/img/workout1.svg",
|
|
||||||
value: "2400",
|
|
||||||
title: "Nombre pas",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: media.width * 0.1,
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
"Activité journalière",
|
|
||||||
style: TextStyle(
|
|
||||||
color: TColor.black,
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.w700),
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
height: 30,
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
gradient: LinearGradient(colors: TColor.primaryG),
|
|
||||||
borderRadius: BorderRadius.circular(15),
|
|
||||||
),
|
|
||||||
child: DropdownButtonHideUnderline(
|
|
||||||
child: DropdownButton(
|
|
||||||
items: ["Semaine", "Mois"]
|
|
||||||
.map((name) => DropdownMenuItem(
|
|
||||||
value: name,
|
|
||||||
child: Text(
|
|
||||||
name,
|
|
||||||
style: TextStyle(
|
|
||||||
color: TColor.gray, fontSize: 14),
|
|
||||||
),
|
|
||||||
))
|
|
||||||
.toList(),
|
|
||||||
onChanged: (value) {},
|
|
||||||
icon: Icon(Icons.expand_more, color: TColor.white),
|
|
||||||
hint: Text(
|
|
||||||
"Semaine",
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(color: TColor.white, fontSize: 12),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: media.width * 0.05,
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
height: media.width * 0.5,
|
|
||||||
padding:
|
|
||||||
const EdgeInsets.symmetric(vertical: 15, horizontal: 0),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: TColor.white,
|
|
||||||
borderRadius: BorderRadius.circular(15),
|
|
||||||
boxShadow: const [
|
|
||||||
BoxShadow(color: Colors.black12, blurRadius: 3)
|
|
||||||
]),
|
|
||||||
child: BarChart(BarChartData(
|
|
||||||
barTouchData: BarTouchData(
|
|
||||||
touchTooltipData: BarTouchTooltipData(
|
|
||||||
tooltipBgColor: Colors.grey,
|
|
||||||
tooltipHorizontalAlignment: FLHorizontalAlignment.right,
|
|
||||||
tooltipMargin: 10,
|
|
||||||
getTooltipItem: (group, groupIndex, rod, rodIndex) {
|
|
||||||
String weekDay;
|
|
||||||
switch (group.x) {
|
|
||||||
case 0:
|
|
||||||
weekDay = 'Monday';
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
weekDay = 'Tuesday';
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
weekDay = 'Wednesday';
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
weekDay = 'Thursday';
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
weekDay = 'Friday';
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
weekDay = 'Saturday';
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
weekDay = 'Sunday';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw Error();
|
|
||||||
}
|
|
||||||
return BarTooltipItem(
|
|
||||||
'$weekDay\n',
|
|
||||||
const TextStyle(
|
|
||||||
color: Colors.white,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontSize: 14,
|
|
||||||
),
|
|
||||||
children: <TextSpan>[
|
|
||||||
TextSpan(
|
|
||||||
text: (rod.toY - 1).toString(),
|
|
||||||
style: TextStyle(
|
|
||||||
color: TColor.white,
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
touchCallback: (FlTouchEvent event, barTouchResponse) {
|
|
||||||
setState(() {
|
|
||||||
if (!event.isInterestedForInteractions ||
|
|
||||||
barTouchResponse == null ||
|
|
||||||
barTouchResponse.spot == null) {
|
|
||||||
touchedIndex = -1;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
touchedIndex =
|
|
||||||
barTouchResponse.spot!.touchedBarGroupIndex;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
titlesData: FlTitlesData(
|
|
||||||
show: true,
|
|
||||||
rightTitles: AxisTitles(
|
|
||||||
sideTitles: SideTitles(showTitles: false),
|
|
||||||
),
|
|
||||||
topTitles: AxisTitles(
|
|
||||||
sideTitles: SideTitles(showTitles: false),
|
|
||||||
),
|
|
||||||
bottomTitles: AxisTitles(
|
|
||||||
sideTitles: SideTitles(
|
|
||||||
showTitles: true,
|
|
||||||
getTitlesWidget: getTitles,
|
|
||||||
reservedSize: 38,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
leftTitles: AxisTitles(
|
|
||||||
sideTitles: SideTitles(
|
|
||||||
showTitles: false,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
borderData: FlBorderData(
|
|
||||||
show: false,
|
|
||||||
),
|
|
||||||
barGroups: showingGroups(),
|
|
||||||
gridData: FlGridData(show: false),
|
|
||||||
)),
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: media.width * 0.05,
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: media.width * 0.1,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget getTitles(double value, TitleMeta meta) {
|
|
||||||
var style = TextStyle(
|
|
||||||
color: TColor.gray,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
fontSize: 12,
|
|
||||||
);
|
|
||||||
Widget text;
|
|
||||||
switch (value.toInt()) {
|
|
||||||
case 0:
|
|
||||||
text = Text('Dim', style: style);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
text = Text('Lun', style: style);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
text = Text('Mar', style: style);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
text = Text('Mer', style: style);
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
text = Text('Jeu', style: style);
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
text = Text('Ven', style: style);
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
text = Text('Sam', style: style);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
text = Text('', style: style);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return SideTitleWidget(
|
|
||||||
axisSide: meta.axisSide,
|
|
||||||
space: 16,
|
|
||||||
child: text,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<BarChartGroupData> showingGroups() => List.generate(7, (i) {
|
|
||||||
switch (i) {
|
|
||||||
case 0:
|
|
||||||
return makeGroupData(0, 5, TColor.primaryG,
|
|
||||||
isTouched: i == touchedIndex);
|
|
||||||
case 1:
|
|
||||||
return makeGroupData(1, 10.5, TColor.secondaryG,
|
|
||||||
isTouched: i == touchedIndex);
|
|
||||||
case 2:
|
|
||||||
return makeGroupData(2, 5, TColor.primaryG,
|
|
||||||
isTouched: i == touchedIndex);
|
|
||||||
case 3:
|
|
||||||
return makeGroupData(3, 7.5, TColor.secondaryG,
|
|
||||||
isTouched: i == touchedIndex);
|
|
||||||
case 4:
|
|
||||||
return makeGroupData(4, 15, TColor.primaryG,
|
|
||||||
isTouched: i == touchedIndex);
|
|
||||||
case 5:
|
|
||||||
return makeGroupData(5, 5.5, TColor.secondaryG,
|
|
||||||
isTouched: i == touchedIndex);
|
|
||||||
case 6:
|
|
||||||
return makeGroupData(6, 8.5, TColor.primaryG,
|
|
||||||
isTouched: i == touchedIndex);
|
|
||||||
default:
|
|
||||||
return throw Error();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
BarChartGroupData makeGroupData(
|
|
||||||
int x,
|
|
||||||
double y,
|
|
||||||
List<Color> barColor, {
|
|
||||||
bool isTouched = false,
|
|
||||||
double width = 22,
|
|
||||||
List<int> showTooltips = const [],
|
|
||||||
}) {
|
|
||||||
return BarChartGroupData(
|
|
||||||
x: x,
|
|
||||||
barRods: [
|
|
||||||
BarChartRodData(
|
|
||||||
toY: isTouched ? y + 1 : y,
|
|
||||||
gradient: LinearGradient(
|
|
||||||
colors: barColor,
|
|
||||||
begin: Alignment.topCenter,
|
|
||||||
end: Alignment.bottomCenter),
|
|
||||||
width: width,
|
|
||||||
borderSide: isTouched
|
|
||||||
? const BorderSide(color: Colors.green)
|
|
||||||
: const BorderSide(color: Colors.white, width: 0),
|
|
||||||
backDrawRodData: BackgroundBarChartRodData(
|
|
||||||
show: true,
|
|
||||||
toY: 20,
|
|
||||||
color: TColor.lightGray,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
showingTooltipIndicators: showTooltips,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,131 +0,0 @@
|
|||||||
import 'dart:async';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
|
||||||
import 'package:location/location.dart';
|
|
||||||
import 'package:smartfit_app_mobile/common/colo_extension.dart';
|
|
||||||
|
|
||||||
class MobileMyMaps extends StatefulWidget {
|
|
||||||
const MobileMyMaps({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<MobileMyMaps> createState() => _MobileMyMaps();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _MobileMyMaps extends State<MobileMyMaps> {
|
|
||||||
Completer<GoogleMapController> _googleMapController = Completer();
|
|
||||||
CameraPosition? _cameraPosition;
|
|
||||||
Location? _location;
|
|
||||||
LocationData? _currentLocation;
|
|
||||||
List<LatLng> _polylineCoordinates = [];
|
|
||||||
Set<Polyline> _polylines = {};
|
|
||||||
Set<Marker> _markers = {}; // Add a set to store markers
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
_init();
|
|
||||||
super.initState();
|
|
||||||
}
|
|
||||||
|
|
||||||
_init() async {
|
|
||||||
_location = Location();
|
|
||||||
_cameraPosition = const CameraPosition(
|
|
||||||
target: LatLng(
|
|
||||||
0, 0), // this is just the example lat and lng for initializing
|
|
||||||
zoom: 20);
|
|
||||||
_initLocation();
|
|
||||||
}
|
|
||||||
|
|
||||||
//function to listen when we move position
|
|
||||||
_initLocation() {
|
|
||||||
_location?.getLocation().then((location) {
|
|
||||||
_currentLocation = location;
|
|
||||||
});
|
|
||||||
|
|
||||||
_location?.onLocationChanged.listen((newLocation) {
|
|
||||||
setState(() {
|
|
||||||
_currentLocation = newLocation;
|
|
||||||
_polylineCoordinates.add(LatLng(
|
|
||||||
_currentLocation?.latitude ?? 0,
|
|
||||||
_currentLocation?.longitude ?? 0,
|
|
||||||
));
|
|
||||||
_updatePolyline();
|
|
||||||
});
|
|
||||||
|
|
||||||
moveToPosition(LatLng(
|
|
||||||
_currentLocation?.latitude ?? 0, _currentLocation?.longitude ?? 0));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
_updatePolyline() {
|
|
||||||
setState(() {
|
|
||||||
_polylines.clear();
|
|
||||||
_polylines.add(Polyline(
|
|
||||||
polylineId: PolylineId("polyline"),
|
|
||||||
color: TColor.primaryColor1,
|
|
||||||
points: _polylineCoordinates,
|
|
||||||
width: 10,
|
|
||||||
));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
// Updated _updateMarker to use the custom marker
|
|
||||||
_updateMarker(LatLng position) async {
|
|
||||||
final markerId = MarkerId('marker');
|
|
||||||
final marker = Marker(markerId: markerId, position: position);
|
|
||||||
_markers.clear();
|
|
||||||
_markers.add(marker);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
moveToPosition(LatLng latLng) async {
|
|
||||||
GoogleMapController mapController = await _googleMapController.future;
|
|
||||||
mapController.animateCamera(CameraUpdate.newCameraPosition(
|
|
||||||
CameraPosition(target: latLng, zoom: 15)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
body: _getMap(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _getMarker() {
|
|
||||||
return Container(
|
|
||||||
width: 25,
|
|
||||||
height: 25,
|
|
||||||
padding: EdgeInsets.all(2),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.white,
|
|
||||||
borderRadius: BorderRadius.circular(100),
|
|
||||||
boxShadow: [
|
|
||||||
BoxShadow(
|
|
||||||
color: Colors.grey,
|
|
||||||
offset: Offset(0, 3),
|
|
||||||
spreadRadius: 4,
|
|
||||||
blurRadius: 6)
|
|
||||||
]),
|
|
||||||
child: ClipOval(child: Image.asset("assets/img/u1.png")),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _getMap() {
|
|
||||||
return Stack(
|
|
||||||
children: [
|
|
||||||
GoogleMap(
|
|
||||||
initialCameraPosition: _cameraPosition!,
|
|
||||||
mapType: MapType.normal,
|
|
||||||
onMapCreated: (GoogleMapController controller) {
|
|
||||||
if (!_googleMapController.isCompleted) {
|
|
||||||
_googleMapController.complete(controller);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
polylines: _polylines,
|
|
||||||
markers: _markers,
|
|
||||||
),
|
|
||||||
Positioned.fill(
|
|
||||||
child: Align(alignment: Alignment.center, child: _getMarker()))
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in new issue