Commit 03a96768 authored by Administrator's avatar Administrator

lap and activity tagging with staggered tile view finally working

parent 518f2f15
{"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":"path_provider","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.8/","dependencies":[]},{"name":"shared_preferences","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.7+2/","dependencies":[]},{"name":"sqflite","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.0+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.4.7/","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":"path_provider","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.8/","dependencies":[]},{"name":"shared_preferences","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.7+2/","dependencies":[]},{"name":"sqflite","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.0+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.4.7/","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-0.0.4+2/","dependencies":[]},{"name":"shared_preferences_macos","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_macos-0.0.1+8/","dependencies":[]},{"name":"sqflite","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.0+1/","dependencies":[]},{"name":"url_launcher_macos","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_macos-0.0.1+5/","dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"shared_preferences_web","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_web-0.1.2+5/","dependencies":[]},{"name":"url_launcher_web","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_web-0.1.1+5/","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_secure_storage","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos"]},{"name":"path_provider_macos","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_macos","shared_preferences_web"]},{"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_macos"]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]}],"date_created":"2020-05-15 19:45:41.979156","version":"1.17.1"}
\ 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":"path_provider","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.8/","dependencies":[]},{"name":"shared_preferences","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.7+2/","dependencies":[]},{"name":"sqflite","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.0+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.4.7/","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":"path_provider","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.8/","dependencies":[]},{"name":"shared_preferences","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.7+2/","dependencies":[]},{"name":"sqflite","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.0+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.4.7/","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-0.0.4+2/","dependencies":[]},{"name":"shared_preferences_macos","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_macos-0.0.1+8/","dependencies":[]},{"name":"sqflite","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.0+1/","dependencies":[]},{"name":"url_launcher_macos","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_macos-0.0.1+5/","dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"shared_preferences_web","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_web-0.1.2+5/","dependencies":[]},{"name":"url_launcher_web","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_web-0.1.1+5/","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_secure_storage","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos"]},{"name":"path_provider_macos","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_macos","shared_preferences_web"]},{"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_macos"]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]}],"date_created":"2020-05-15 21:31:05.479197","version":"1.17.1"}
\ No newline at end of file
......@@ -55,8 +55,7 @@ class LapTagging extends ChangeNotifier {
.tagsId
.equals(tag.db.id)
.toSingle();
if (dbLapTagging != null)
return LapTagging.fromDb(dbLapTagging);
if (dbLapTagging != null) return LapTagging.fromDb(dbLapTagging);
}
static deleteBy({
......
......@@ -4,7 +4,7 @@ import 'package:encrateia/models/tag_group.dart';
class Tag extends ChangeNotifier {
DbTag db;
bool selected;
bool selected = false;
Tag({
@required TagGroup tagGroup,
......
......@@ -74,11 +74,11 @@ class TagGroup extends ChangeNotifier {
.equals(activity.db.id)
.toList();
var selectedTagIds = dbActivityTaggings
.map((DbActivityTagging dbActivityTagging) => dbActivityTagging.id);
.map((DbActivityTagging dbActivityTagging) => dbActivityTagging.tagsId);
for (TagGroup tagGroup in tagGroups) {
var tags = await tagGroup.tags;
for (Tag tag in tags) {
tagGroup.cachedTags = await tagGroup.tags;
for (Tag tag in tagGroup.cachedTags) {
tag.selected = selectedTagIds.contains(tag.db.id) ? true : false;
}
}
......@@ -96,12 +96,13 @@ class TagGroup extends ChangeNotifier {
.lapsId
.equals(lap.db.id)
.toList();
var selectedTagIds = dbLapTaggings
.map((DbLapTagging dbLapTagging) => dbLapTagging.id);
.map((DbLapTagging dbLapTagging) => dbLapTagging.tagsId);
for (TagGroup tagGroup in tagGroups) {
var tags = await tagGroup.tags;
for (Tag tag in tags) {
tagGroup.cachedTags = await tagGroup.tags;
for (Tag tag in tagGroup.cachedTags) {
tag.selected = selectedTagIds.contains(tag.db.id) ? true : false;
}
}
......
......@@ -65,7 +65,7 @@ class MyColor {
static Color textColor({
@required Color backgroundColor,
bool selected: true,
bool selected:true,
}) {
if (selected) {
if (ThemeData.estimateBrightnessForColor(backgroundColor) ==
......
......@@ -6,6 +6,7 @@ import 'package:encrateia/models/tag_group.dart';
import 'package:encrateia/utils/my_color.dart';
import 'package:flutter/material.dart';
import 'package:encrateia/models/activity.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
class ActivityTagWidget extends StatefulWidget {
final Activity activity;
......@@ -34,61 +35,59 @@ class _ActivityTagWidgetState extends State<ActivityTagWidget> {
if (tagGroups == null)
return Center(child: Text("Loading ..."));
else
return ListTileTheme(
iconColor: MyColor.tag,
child: ListView.builder(
itemCount: tagGroups?.length ?? 0,
itemBuilder: (context, index) {
TagGroup tagGroup = tagGroups[index];
return Card(
child: ListTile(
contentPadding: EdgeInsets.all(20),
subtitle: Wrap(
spacing: 15,
children: [
for (Tag tag in tagGroup.cachedTags)
InputChip(
label: Text(
tag.db.name,
style: TextStyle(
color: MyColor.textColor(
selected: tag.selected,
backgroundColor: Color(tag.db.color),
),
),
),
avatar: CircleAvatar(
return StaggeredGridView.countBuilder(
crossAxisCount:
MediaQuery.of(context).orientation == Orientation.portrait ? 2 : 3,
itemCount: tagGroups.length,
itemBuilder: (BuildContext context, int index) => Card(
child: ListTile(
title: Text(tagGroups[index].db.name + "\n"),
subtitle: Wrap(
spacing: 15,
children: [
for (Tag tag in tagGroups[index].cachedTags)
InputChip(
label: Text(
tag.db.name,
style: TextStyle(
color: MyColor.textColor(
selected: tag.selected,
backgroundColor: Color(tag.db.color),
),
onSelected: (selected) {
setState(() {
if (selected) {
ActivityTagging.createBy(
activity: widget.activity,
tag: tag,
);
} else {
ActivityTagging.deleteBy(
activity: widget.activity,
tag: tag,
);
}
tag.selected = selected;
});
},
selected: tag.selected,
selectedColor: Color(tag.db.color),
backgroundColor: MyColor.white,
elevation: 3,
padding: EdgeInsets.all(10),
)
],
),
title: Text(tagGroup.db.name + "\n"),
),
);
},
),
),
avatar: CircleAvatar(
backgroundColor: Color(tag.db.color),
),
onSelected: (selected) {
setState(() {
if (selected) {
ActivityTagging.createBy(
activity: widget.activity,
tag: tag,
);
} else {
ActivityTagging.deleteBy(
activity: widget.activity,
tag: tag,
);
}
tag.selected = selected;
});
},
selected: tag.selected,
selectedColor: Color(tag.db.color),
backgroundColor: MyColor.white,
elevation: 3,
padding: EdgeInsets.all(10),
)
],
),
),
),
staggeredTileBuilder: (_) => StaggeredTile.fit(1),
mainAxisSpacing: 3,
crossAxisSpacing: 3,
);
}
......
......@@ -6,6 +6,7 @@ import 'package:encrateia/models/tag_group.dart';
import 'package:encrateia/utils/my_color.dart';
import 'package:flutter/material.dart';
import 'package:encrateia/models/lap.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
class LapTagWidget extends StatefulWidget {
final Lap lap;
......@@ -34,61 +35,53 @@ class _LapTagWidgetState extends State<LapTagWidget> {
if (tagGroups == null)
return Center(child: Text("Loading ..."));
else
return ListTileTheme(
iconColor: MyColor.tag,
child: ListView.builder(
itemCount: tagGroups?.length ?? 0,
itemBuilder: (context, index) {
TagGroup tagGroup = tagGroups[index];
return Card(
child: ListTile(
contentPadding: EdgeInsets.all(20),
subtitle: Wrap(
spacing: 15,
children: [
for (Tag tag in tagGroup.cachedTags)
InputChip(
label: Text(
tag.db.name,
style: TextStyle(
color: MyColor.textColor(
selected: tag.selected,
backgroundColor: Color(tag.db.color),
),
),
),
avatar: CircleAvatar(
return StaggeredGridView.countBuilder(
crossAxisCount:
MediaQuery.of(context).orientation == Orientation.portrait ? 2 : 3,
itemCount: tagGroups.length,
itemBuilder: (BuildContext context, int index) => Card(
child: ListTile(
title: Text(tagGroups[index].db.name + "\n"),
subtitle: Wrap(
spacing: 15,
children: [
for (Tag tag in tagGroups[index].cachedTags)
InputChip(
label: Text(
tag.db.name,
style: TextStyle(
color: MyColor.textColor(
selected: tag.selected,
backgroundColor: Color(tag.db.color),
),
onSelected: (selected) {
setState(() {
if (selected) {
LapTagging.createBy(
lap: widget.lap,
tag: tag,
);
} else {
LapTagging.deleteBy(
lap: widget.lap,
tag: tag,
);
}
tag.selected = selected;
});
},
selected: tag.selected,
selectedColor: Color(tag.db.color),
backgroundColor: MyColor.white,
elevation: 3,
padding: EdgeInsets.all(10),
)
],
),
title: Text(tagGroup.db.name + "\n"),
),
);
},
),
),
avatar: CircleAvatar(
backgroundColor: Color(tag.db.color),
),
onSelected: (selected) {
setState(() {
if (selected) {
LapTagging.createBy(lap: widget.lap, tag: tag);
} else {
LapTagging.deleteBy(lap: widget.lap, tag: tag);
}
tag.selected = selected;
});
},
selected: tag.selected,
selectedColor: Color(tag.db.color),
backgroundColor: MyColor.white,
elevation: 3,
padding: EdgeInsets.all(10),
)
],
),
),
),
staggeredTileBuilder: (_) => StaggeredTile.fit(1),
mainAxisSpacing: 3,
crossAxisSpacing: 3,
);
}
......
......@@ -272,6 +272,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "3.3.3"
flutter_staggered_grid_view:
dependency: "direct main"
description:
name: flutter_staggered_grid_view
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.0"
flutter_test:
dependency: "direct dev"
description: flutter
......
......@@ -30,6 +30,8 @@ dependencies:
datetime_picker_formfield: ^1.0.0
flutter_material_color_picker: ^1.0.5
flutter_staggered_grid_view: 0.3.0
dev_dependencies:
flutter_test:
sdk: flutter
......
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