Commit caba41fd authored by Administrator's avatar Administrator

create manual activity

parent 7709bcbd
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_secure_storage","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-3.3.3/","dependencies":[]},{"name":"package_info","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/package_info-0.4.1/","dependencies":[]},{"name":"path_provider","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.11/","dependencies":[]},{"name":"shared_preferences","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.8/","dependencies":[]},{"name":"sqflite","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.1/","dependencies":[]},{"name":"uni_links","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/uni_links-0.4.0/","dependencies":[]},{"name":"url_launcher","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.5.0/","dependencies":[]}],"android":[{"name":"flutter_secure_storage","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-3.3.3/","dependencies":[]},{"name":"package_info","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/package_info-0.4.1/","dependencies":[]},{"name":"path_provider","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.11/","dependencies":[]},{"name":"shared_preferences","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.8/","dependencies":[]},{"name":"sqflite","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.1/","dependencies":[]},{"name":"uni_links","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/uni_links-0.4.0/","dependencies":[]},{"name":"url_launcher","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.5.0/","dependencies":[]}],"macos":[{"name":"package_info","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/package_info-0.4.1/","dependencies":[]},{"name":"path_provider_macos","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-0.0.4+3/","dependencies":[]},{"name":"shared_preferences_macos","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_macos-0.0.1+10/","dependencies":[]},{"name":"sqflite","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.1/","dependencies":[]},{"name":"url_launcher_macos","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_macos-0.0.1+7/","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-0.0.1+2/","dependencies":[]},{"name":"shared_preferences_linux","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_linux-0.0.2+1/","dependencies":["path_provider_linux"]},{"name":"url_launcher_linux","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_linux-0.0.1+1/","dependencies":[]}],"windows":[],"web":[{"name":"shared_preferences_web","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_web-0.1.2+7/","dependencies":[]},{"name":"url_launcher_web","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_web-0.1.2/","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_secure_storage","dependencies":[]},{"name":"package_info","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_linux","shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"sqflite","dependencies":[]},{"name":"uni_links","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_web","url_launcher_linux","url_launcher_macos"]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]}],"date_created":"2020-09-03 09:27:55.252286","version":"1.20.2"}
\ No newline at end of file
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_secure_storage","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-3.3.3/","dependencies":[]},{"name":"package_info","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/package_info-0.4.1/","dependencies":[]},{"name":"path_provider","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.11/","dependencies":[]},{"name":"shared_preferences","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.8/","dependencies":[]},{"name":"sqflite","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.1/","dependencies":[]},{"name":"uni_links","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/uni_links-0.4.0/","dependencies":[]},{"name":"url_launcher","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.5.0/","dependencies":[]}],"android":[{"name":"flutter_secure_storage","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-3.3.3/","dependencies":[]},{"name":"package_info","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/package_info-0.4.1/","dependencies":[]},{"name":"path_provider","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.11/","dependencies":[]},{"name":"shared_preferences","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.8/","dependencies":[]},{"name":"sqflite","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.1/","dependencies":[]},{"name":"uni_links","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/uni_links-0.4.0/","dependencies":[]},{"name":"url_launcher","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.5.0/","dependencies":[]}],"macos":[{"name":"package_info","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/package_info-0.4.1/","dependencies":[]},{"name":"path_provider_macos","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-0.0.4+3/","dependencies":[]},{"name":"shared_preferences_macos","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_macos-0.0.1+10/","dependencies":[]},{"name":"sqflite","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.1/","dependencies":[]},{"name":"url_launcher_macos","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_macos-0.0.1+7/","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-0.0.1+2/","dependencies":[]},{"name":"shared_preferences_linux","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_linux-0.0.2+1/","dependencies":["path_provider_linux"]},{"name":"url_launcher_linux","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_linux-0.0.1+1/","dependencies":[]}],"windows":[],"web":[{"name":"shared_preferences_web","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_web-0.1.2+7/","dependencies":[]},{"name":"url_launcher_web","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_web-0.1.2/","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_secure_storage","dependencies":[]},{"name":"package_info","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_linux","shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"sqflite","dependencies":[]},{"name":"uni_links","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_web","url_launcher_linux","url_launcher_macos"]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]}],"date_created":"2020-09-03 14:35:40.046882","version":"1.20.2"}
\ No newline at end of file
......@@ -36,8 +36,8 @@ class Activity {
Activity._fromDb(this._db);
Activity.fromStrava({
strava_activity.SummaryActivity summaryActivity,
Athlete athlete,
@required strava_activity.SummaryActivity summaryActivity,
@required Athlete athlete,
}) {
_db = DbActivity()
..athletesId = athlete.id
......@@ -48,13 +48,20 @@ class Activity {
..movingTime = summaryActivity.movingTime;
}
Activity.fromLocalDirectory({Athlete athlete}) {
Activity.fromLocalDirectory({@required Athlete athlete}) {
_db = DbActivity()
..athletesId = athlete.id
..stravaId = DateTime.now().millisecondsSinceEpoch
..name = 'new activity';
}
Activity.manual({@required Athlete athlete}){
_db = DbActivity()
..athletesId = athlete.id
..stravaId = DateTime.now().millisecondsSinceEpoch
..timeCreated = DateTime.now();
}
DbActivity _db;
List<Event> cachedRecords = <Event>[];
List<Lap> cachedLaps = <Lap>[];
......@@ -208,6 +215,16 @@ class Activity {
set name(String value) => _db.name = value;
set nonParsable(bool value) => _db.nonParsable = value;
set state(String value) => _db.state = value;
set timeStamp(DateTime value) => _db.timeStamp = value;
set timeCreated(DateTime value) => _db.timeCreated = value;
set totalDistance(int value) => _db.totalDistance = value;
set totalAscent(int value) => _db.totalAscent = value;
set totalDescent(int value) => _db.totalDescent = value;
set avgHeartRate(int value) => _db.avgHeartRate = value;
set avgPower(double value) => _db.avgPower = value;
set sport(String value) => _db.sport = value;
set subSport(String value) => _db.subSport = value;
set movingTime(int value) => _db.movingTime = value;
Future<BoolResult> delete() async => await _db.delete();
Future<int> save() async => await _db.save();
......
import 'package:datetime_picker_formfield/datetime_picker_formfield.dart';
import 'package:encrateia/utils/my_button.dart';
import 'package:encrateia/utils/my_color.dart';
import 'package:flutter/material.dart';
import 'package:encrateia/utils/date_time_utils.dart';
import 'package:encrateia/models/activity.dart';
import 'package:intl/intl.dart';
class EditActivityScreen extends StatefulWidget {
const EditActivityScreen({
Key key,
@required this.activity,
}) : super(key: key);
final Activity activity;
@override
_EditActivityScreenState createState() => _EditActivityScreenState();
}
class _EditActivityScreenState extends State<EditActivityScreen> {
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: MyColor.activity,
title: const Text('Edit Record'),
),
body: SafeArea(
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Form(
key: formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
TextFormField(
decoration: const InputDecoration(labelText: 'Title'),
onChanged: (String value) => widget.activity.name = value,
initialValue: widget.activity.event,
),
TextFormField(
decoration: const InputDecoration(
labelText: 'Total Distance',
helperText: 'in m',
),
onChanged: (String value) =>
widget.activity.totalDistance = int.parse(value),
initialValue:
(widget.activity.totalDistance ?? 0).toString(),
keyboardType: TextInputType.number,
),
DateTimeField(
decoration: const InputDecoration(
labelText: 'Time Stamp',
helperText: 'Tap to open Selector',
),
format: DateFormat('yyyy-MM-dd HH:mm:SS'),
initialValue: widget.activity.timeStamp,
resetIcon: null,
onShowPicker:
(BuildContext context, DateTime currentValue) async {
final DateTime date = await showDatePicker(
context: context,
firstDate: DateTime(1969),
initialDate: currentValue ?? DateTime.now(),
lastDate: DateTime(2100));
if (date != null) {
final TimeOfDay time = await showTimePicker(
context: context,
initialTime: TimeOfDay.fromDateTime(
currentValue ?? DateTime.now()),
);
return DateTimeField.combine(date, time);
} else {
return currentValue;
}
},
onChanged: (DateTime value) {
widget.activity.timeStamp = value;
widget.activity.timeCreated = value;
}),
TextFormField(
decoration: const InputDecoration(
labelText: 'Total Ascent',
helperText: 'in m',
),
onChanged: (String value) =>
widget.activity.totalAscent = int.parse(value),
initialValue: (widget.activity.totalAscent ?? 0).toString(),
keyboardType: TextInputType.number,
),
TextFormField(
decoration: const InputDecoration(
labelText: 'Total Descent',
helperText: 'in m',
),
onChanged: (String value) =>
widget.activity.totalDescent = int.parse(value),
initialValue:
(widget.activity.totalDescent ?? 0).toString(),
keyboardType: TextInputType.number,
),
TextFormField(
decoration: const InputDecoration(
labelText: 'Average Heart Rate',
helperText: 'in bpm',
),
onChanged: (String value) =>
widget.activity.avgHeartRate = int.parse(value),
initialValue:
(widget.activity.avgHeartRate ?? 0).toString(),
keyboardType: TextInputType.number,
),
TextFormField(
decoration: const InputDecoration(
labelText: 'Average Power',
helperText: 'in W',
),
onChanged: (String value) =>
widget.activity.avgPower = double.parse(value),
initialValue: (widget.activity.avgPower ?? 0).toString(),
keyboardType: TextInputType.number,
),
Row(
children: <Widget>[
const Text('Sport'),
const SizedBox(width: 20),
DropdownButton<String>(
value: widget.activity.sport ?? 'Running',
icon: const Icon(Icons.arrow_downward),
onChanged: (String value) =>
widget.activity.sport = value,
items: <String>[
'Running',
'Cycling',
'Swimming',
'Other'
].map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
),
],
),
TextFormField(
decoration: const InputDecoration(labelText: 'Sub Sport'),
onChanged: (String value) => widget.activity.name = value,
initialValue: widget.activity.event,
),
Row(
children: <Widget>[
Flexible(
child: TextFormField(
decoration: const InputDecoration(
labelText: 'Moving Time',
helperText: 'hours',
),
onChanged: (String value) =>
widget.activity.movingTime = widget
.activity.movingTime
.setHours(int.parse(value)),
initialValue: (widget.activity.movingTime ?? 0)
.fullHours
.toString(),
keyboardType: TextInputType.number,
),
),
Flexible(
child: TextFormField(
decoration: const InputDecoration(
labelText: 'Moving Time',
helperText: 'minutes',
),
onChanged: (String value) =>
widget.activity.movingTime =
(widget.activity.movingTime ?? 0)
.setMinutes(int.parse(value)),
initialValue: (widget.activity.movingTime ?? 0)
.fullMinutes
.toString(),
keyboardType: TextInputType.number,
),
),
Flexible(
child: TextFormField(
decoration: const InputDecoration(
labelText: 'Moving Time',
helperText: 'seconds',
),
onChanged: (String value) =>
widget.activity.movingTime = widget
.activity.movingTime
.setSeconds(int.parse(value)),
initialValue: (widget.activity.movingTime ?? 0)
.fullSeconds
.toString(),
keyboardType: TextInputType.number,
),
),
const Spacer(flex: 2),
],
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0),
child: MyButton.save(
onPressed: () async {
await widget.activity.save();
Navigator.of(context).pop();
},
),
),
],
),
),
),
),
),
);
}
}
......@@ -88,43 +88,40 @@ class _EditEventScreenState extends State<EditEventScreen> {
onChanged: (DateTime value) =>
widget.record.timeStamp = value,
),
Row(children: <Widget>[
Flexible(
child: TextFormField(
decoration:
const InputDecoration(labelText: 'Latitude Degrees'),
decoration: const InputDecoration(
labelText: 'Latitude Degrees'),
onChanged: (String value) => widget.record.positionLat =
widget.record.positionLat
.setDegrees(int.parse(value)),
initialValue: widget.record.positionLat
.semicirclesDegreePortion()
.toString(),
initialValue:
widget.record.positionLat.fullDegrees.toString(),
keyboardType: TextInputType.number,
),
),
Flexible(
child: TextFormField(
decoration:
const InputDecoration(labelText: 'Latitude Minutes'),
decoration: const InputDecoration(
labelText: 'Latitude Minutes'),
onChanged: (String value) => widget.record.positionLat =
widget.record.positionLat
.setMinutes(int.parse(value)),
initialValue: widget.record.positionLat
.semicirclesMinutesPortion()
.toString(),
initialValue:
widget.record.positionLat.fullMinutes.toString(),
keyboardType: TextInputType.number,
),
),
Flexible(
child: TextFormField(
decoration:
const InputDecoration(labelText: 'Latitude Seconds'),
decoration: const InputDecoration(
labelText: 'Latitude Seconds'),
onChanged: (String value) => widget.record.positionLat =
widget.record.positionLat.setSeconds(double.parse(value)),
initialValue: widget.record.positionLat
.semicirclesSecondsPortion()
.toString(),
widget.record.positionLat
.setSeconds(double.parse(value)),
initialValue:
widget.record.positionLat.seconds.toString(),
keyboardType: TextInputType.number,
),
),
......@@ -132,39 +129,40 @@ class _EditEventScreenState extends State<EditEventScreen> {
Row(children: <Widget>[
Flexible(
child: TextFormField(
decoration:
const InputDecoration(labelText: 'Longitude Degrees'),
onChanged: (String value) => widget.record.positionLong =
widget.record.positionLong
decoration: const InputDecoration(
labelText: 'Longitude Degrees'),
onChanged: (String value) =>
widget.record.positionLong = widget
.record.positionLong
.setDegrees(int.parse(value)),
initialValue: widget.record.positionLong
.semicirclesDegreePortion()
.toString(),
initialValue:
widget.record.positionLong.fullDegrees.toString(),
keyboardType: TextInputType.number,
),
),
Flexible(
child: TextFormField(
decoration:
const InputDecoration(labelText: 'Longitude Minutes'),
onChanged: (String value) => widget.record.positionLong =
widget.record.positionLong
decoration: const InputDecoration(
labelText: 'Longitude Minutes'),
onChanged: (String value) =>
widget.record.positionLong = widget
.record.positionLong
.setMinutes(int.parse(value)),
initialValue: widget.record.positionLong
.semicirclesMinutesPortion()
.toString(),
initialValue:
widget.record.positionLong.fullMinutes.toString(),
keyboardType: TextInputType.number,
),
),
Flexible(
child: TextFormField(
decoration:
const InputDecoration(labelText: 'Longitude Seconds'),
onChanged: (String value) => widget.record.positionLong =
widget.record.positionLong.setSeconds(double.parse(value)),
initialValue: widget.record.positionLong
.semicirclesSecondsPortion()
.toString(),
decoration: const InputDecoration(
labelText: 'Longitude Seconds'),
onChanged: (String value) =>
widget.record.positionLong = widget
.record.positionLong
.setSeconds(double.parse(value)),
initialValue:
widget.record.positionLong.seconds.toString(),
keyboardType: TextInputType.number,
),
),
......
......@@ -415,7 +415,7 @@ class _ShowActivityScreenState extends State<ShowActivityScreen> {
appBar: AppBar(
backgroundColor: MyColor.activity,
title: Text(
widget.activity.name,
widget.activity.name ?? '',
overflow: TextOverflow.ellipsis,
),
),
......
......@@ -13,6 +13,7 @@ import 'package:encrateia/widgets/athlete_widgets/athlete_stryd_cadence_widget.d
import 'package:encrateia/widgets/athlete_widgets/athlete_tag_group_widget.dart';
import 'package:flutter/material.dart';
import 'package:encrateia/models/athlete.dart';
import 'package:encrateia/models/activity.dart';
import 'package:encrateia/actions/auto_tagging.dart';
import 'package:encrateia/actions/delete_athlete.dart';
import 'package:encrateia/actions/download_demo_data.dart';
......@@ -29,6 +30,7 @@ import 'package:encrateia/screens/show_athlete_detail_screen.dart';
import 'package:encrateia/utils/icon_utils.dart';
import 'package:flushbar/flushbar.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'edit_activity_screen.dart';
import 'edit_athlete_screen.dart';
class ShowAthleteScreen extends StatefulWidget {
......@@ -163,6 +165,14 @@ class _ShowAthleteScreenState extends State<ShowAthleteScreen> {
icon: MyIcon.tag,
nextWidget: AthleteTagGroupWidget(athlete: widget.athlete),
),
RaisedButton.icon(
icon: MyIcon.addActivity,
color: MyColor.activity,
onPressed: () => goToEditActivityScreen(athlete: widget.athlete),
label: const Expanded(
child: Text('Create Activity manually'),
),
),
RaisedButton.icon(
icon: MyIcon.secrets,
color: MyColor.settings,
......@@ -322,7 +332,7 @@ class _ShowAthleteScreenState extends State<ShowAthleteScreen> {
);
}
Future<void> goToEditAthleteScreen({Athlete athlete}) async {
Future<void> goToEditAthleteScreen({@required Athlete athlete}) async {
await athlete.readCredentials();
await Navigator.push(
context,
......@@ -331,4 +341,14 @@ class _ShowAthleteScreenState extends State<ShowAthleteScreen> {
),
);
}
Future<void> goToEditActivityScreen({@required Athlete athlete}) async {
final Activity activity = Activity.manual(athlete: athlete);
await Navigator.push(
context,
MaterialPageRoute<BuildContext>(
builder: (BuildContext context) => EditActivityScreen(activity: activity),
),
);
}
}
......@@ -35,48 +35,29 @@ extension DegreeFormatters on double {
return '$degrees° $minutes\' ${seconds.toStringAsFixed(2)}"';
}
int semicirclesDegreePortion() {
final double fractionalDegrees = this * (180 / pow(2, 31));
return fractionalDegrees.floor();
}
double get sem2deg => this * 180 / pow(2, 31);
double get deg2sem => this / 180 * pow(2, 31);
int semicirclesMinutesPortion() {
final double fractionalDegrees = this * (180 / pow(2, 31));
final int degrees = fractionalDegrees.floor();
return ((fractionalDegrees - degrees) * 60).floor();
}
int get fullDegrees => sem2deg.floor();
int get fullMinutes => (sem2deg % 1 * 60).floor();
double get seconds => sem2deg * 3600 % 60;
double semicirclesSecondsPortion() {
final double fractionalDegrees = this * (180 / pow(2, 31));
final int degrees = fractionalDegrees.floor();
final int minutes = ((fractionalDegrees - degrees) * 60).floor();
return (((fractionalDegrees - degrees) * 60) - minutes) * 60;
}
double setDegrees(int newDegrees) =>
(sem2deg - fullDegrees + newDegrees).deg2sem;
double setDegrees(int newDegrees) {
final double fractionalDegrees = this * (180 / pow(2, 31));
final double newFractionalDegrees =
fractionalDegrees - fractionalDegrees.floor() + newDegrees;
return newFractionalDegrees / (180 / pow(2, 31));
}
double setMinutes(int newMinutes) =>
(sem2deg + (newMinutes - fullMinutes) / 60).deg2sem;
double setMinutes(int newMinutes) {
final double fractionalDegrees = this * (180 / pow(2, 31));
final int degrees = fractionalDegrees.floor();
final int minutes = ((fractionalDegrees - degrees) * 60).floor();
final double newFractionalDegrees =
fractionalDegrees + (newMinutes - minutes) / 60;
return newFractionalDegrees / (180 / pow(2, 31));
}
double setSeconds(double newSeconds) =>
(sem2deg + (newSeconds - seconds) / 3600).deg2sem;
}
double setSeconds(double newSeconds) {
final double fractionalDegrees = this * (180 / pow(2, 31));
final int degrees = fractionalDegrees.floor();
final int minutes = ((fractionalDegrees - degrees) * 60).floor();
final double seconds =
(((fractionalDegrees - degrees) * 60) - minutes) * 60;
final double newFractionalDegrees =
fractionalDegrees + (newSeconds - seconds) / 3600;
return newFractionalDegrees / (180 / pow(2, 31));
}
extension MovingTimeFormatters on int {
int get fullHours => this ~/ 3600;
int get fullMinutes => (this - this % 60) ~/ 60 % 60;
int get fullSeconds => this % 60;
int setHours(int newHours) => this + (newHours - fullHours) * 3600;
int setMinutes(int newMinutes) => this + (newMinutes - fullMinutes) * 60;
int setSeconds(int newSeconds) => this + (newSeconds - fullSeconds);
}
......@@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
// ignore: avoid_classes_with_only_static_members
class MyIcon {
// A
static const Icon addActivity = Icon(Icons.add_circle_outline);
static const Icon activities = Icon(Icons.view_list);
static const Icon amount = Icon(Icons.playlist_add);
static const Icon altitude = Icon(Icons.landscape);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment