mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 09:28:41 +00:00
fix #305
Some checks are pending
Flutter analyze & test / flutter_analyze_and_test (push) Waiting to run
Some checks are pending
Flutter analyze & test / flutter_analyze_and_test (push) Waiting to run
This commit is contained in:
parent
230809290a
commit
57c73a86ac
7 changed files with 134 additions and 19 deletions
|
|
@ -459,5 +459,7 @@
|
||||||
"linkPubkeyDoesNotMatch": "Der öffentliche Schlüssel im Link stimmt nicht mit dem für diesen Kontakt gespeicherten öffentlichen Schlüssel überein. Triff die Person persönlich und scanne den QR-Code direkt!",
|
"linkPubkeyDoesNotMatch": "Der öffentliche Schlüssel im Link stimmt nicht mit dem für diesen Kontakt gespeicherten öffentlichen Schlüssel überein. Triff die Person persönlich und scanne den QR-Code direkt!",
|
||||||
"startWithCameraOpen": "Mit geöffneter Kamera starten",
|
"startWithCameraOpen": "Mit geöffneter Kamera starten",
|
||||||
"showImagePreviewWhenSending": "Bildvorschau bei der Auswahl von Empfängern anzeigen",
|
"showImagePreviewWhenSending": "Bildvorschau bei der Auswahl von Empfängern anzeigen",
|
||||||
"verifiedPublicKey": "Der öffentliche Schlüssel von {username} wurde überprüft und ist gültig."
|
"verifiedPublicKey": "Der öffentliche Schlüssel von {username} wurde überprüft und ist gültig.",
|
||||||
|
"memoriesAYearAgo": "Vor einem Jahr",
|
||||||
|
"memoriesXYearsAgo": "Vor {years} Jahren"
|
||||||
}
|
}
|
||||||
|
|
@ -489,5 +489,7 @@
|
||||||
"linkPubkeyDoesNotMatch": "The public key in the link does not match the public key stored for this contact. Try to meet your friend in person and scan the QR code directly!",
|
"linkPubkeyDoesNotMatch": "The public key in the link does not match the public key stored for this contact. Try to meet your friend in person and scan the QR code directly!",
|
||||||
"startWithCameraOpen": "Start with camera open",
|
"startWithCameraOpen": "Start with camera open",
|
||||||
"showImagePreviewWhenSending": "Display image preview when selecting recipients",
|
"showImagePreviewWhenSending": "Display image preview when selecting recipients",
|
||||||
"verifiedPublicKey": "The public key of {username} has been verified and is valid."
|
"verifiedPublicKey": "The public key of {username} has been verified and is valid.",
|
||||||
|
"memoriesAYearAgo": "One year ago",
|
||||||
|
"memoriesXYearsAgo": "{years} years ago"
|
||||||
}
|
}
|
||||||
|
|
@ -2857,6 +2857,18 @@ abstract class AppLocalizations {
|
||||||
/// In en, this message translates to:
|
/// In en, this message translates to:
|
||||||
/// **'The public key of {username} has been verified and is valid.'**
|
/// **'The public key of {username} has been verified and is valid.'**
|
||||||
String verifiedPublicKey(Object username);
|
String verifiedPublicKey(Object username);
|
||||||
|
|
||||||
|
/// No description provided for @memoriesAYearAgo.
|
||||||
|
///
|
||||||
|
/// In en, this message translates to:
|
||||||
|
/// **'One year ago'**
|
||||||
|
String get memoriesAYearAgo;
|
||||||
|
|
||||||
|
/// No description provided for @memoriesXYearsAgo.
|
||||||
|
///
|
||||||
|
/// In en, this message translates to:
|
||||||
|
/// **'{years} years ago'**
|
||||||
|
String memoriesXYearsAgo(Object years);
|
||||||
}
|
}
|
||||||
|
|
||||||
class _AppLocalizationsDelegate
|
class _AppLocalizationsDelegate
|
||||||
|
|
|
||||||
|
|
@ -1582,4 +1582,12 @@ class AppLocalizationsDe extends AppLocalizations {
|
||||||
String verifiedPublicKey(Object username) {
|
String verifiedPublicKey(Object username) {
|
||||||
return 'Der öffentliche Schlüssel von $username wurde überprüft und ist gültig.';
|
return 'Der öffentliche Schlüssel von $username wurde überprüft und ist gültig.';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get memoriesAYearAgo => 'Vor einem Jahr';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String memoriesXYearsAgo(Object years) {
|
||||||
|
return 'Vor $years Jahren';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1572,4 +1572,12 @@ class AppLocalizationsEn extends AppLocalizations {
|
||||||
String verifiedPublicKey(Object username) {
|
String verifiedPublicKey(Object username) {
|
||||||
return 'The public key of $username has been verified and is valid.';
|
return 'The public key of $username has been verified and is valid.';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get memoriesAYearAgo => 'One year ago';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String memoriesXYearsAgo(Object years) {
|
||||||
|
return '$years years ago';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -254,10 +254,10 @@ class _ShareImageView extends State<ShareImageView> {
|
||||||
border:
|
border:
|
||||||
Border.all(color: context.color.primary, width: 3),
|
Border.all(color: context.color.primary, width: 3),
|
||||||
color: context.color.primary,
|
color: context.color.primary,
|
||||||
borderRadius: BorderRadius.circular(10),
|
borderRadius: BorderRadius.circular(12),
|
||||||
),
|
),
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(7),
|
borderRadius: BorderRadius.circular(12),
|
||||||
child: Image.memory(_imageBytes!),
|
child: Image.memory(_imageBytes!),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,13 @@ class MemoriesView extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class MemoriesViewState extends State<MemoriesView> {
|
class MemoriesViewState extends State<MemoriesView> {
|
||||||
bool verticalGallery = false;
|
|
||||||
List<MemoryItem> galleryItems = [];
|
List<MemoryItem> galleryItems = [];
|
||||||
Map<String, List<int>> orderedByMonth = {};
|
Map<String, List<int>> orderedByMonth = {};
|
||||||
List<String> months = [];
|
List<String> months = [];
|
||||||
StreamSubscription<List<MediaFile>>? messageSub;
|
StreamSubscription<List<MediaFile>>? messageSub;
|
||||||
|
|
||||||
|
final Map<int, List<MemoryItem>> _galleryItemsLastYears = {};
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
@ -46,6 +47,9 @@ class MemoriesViewState extends State<MemoriesView> {
|
||||||
months = [];
|
months = [];
|
||||||
var lastMonth = '';
|
var lastMonth = '';
|
||||||
galleryItems = [];
|
galleryItems = [];
|
||||||
|
|
||||||
|
final now = DateTime.now();
|
||||||
|
|
||||||
for (final mediaFile in mediaFiles) {
|
for (final mediaFile in mediaFiles) {
|
||||||
final mediaService = MediaFileService(mediaFile);
|
final mediaService = MediaFileService(mediaFile);
|
||||||
if (!mediaService.imagePreviewAvailable) continue;
|
if (!mediaService.imagePreviewAvailable) continue;
|
||||||
|
|
@ -54,12 +58,21 @@ class MemoriesViewState extends State<MemoriesView> {
|
||||||
await mediaService.createThumbnail();
|
await mediaService.createThumbnail();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
galleryItems.add(
|
final item = MemoryItem(
|
||||||
MemoryItem(
|
mediaService: mediaService,
|
||||||
mediaService: mediaService,
|
messages: [],
|
||||||
messages: [],
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
galleryItems.add(item);
|
||||||
|
if (mediaFile.createdAt.month == now.month &&
|
||||||
|
mediaFile.createdAt.day == now.day) {
|
||||||
|
final diff = now.year - mediaFile.createdAt.year;
|
||||||
|
if (diff > 0) {
|
||||||
|
if (!_galleryItemsLastYears.containsKey(diff)) {
|
||||||
|
_galleryItemsLastYears[diff] = [];
|
||||||
|
}
|
||||||
|
_galleryItemsLastYears[diff]!.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
galleryItems.sort(
|
galleryItems.sort(
|
||||||
(a, b) => b.mediaService.mediaFile.createdAt.compareTo(
|
(a, b) => b.mediaService.mediaFile.createdAt.compareTo(
|
||||||
|
|
@ -94,8 +107,83 @@ class MemoriesViewState extends State<MemoriesView> {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: ListView.builder(
|
: ListView.builder(
|
||||||
itemCount: months.length * 2,
|
itemCount: (months.length * 2) +
|
||||||
|
(_galleryItemsLastYears.isEmpty ? 0 : 1),
|
||||||
itemBuilder: (context, mIndex) {
|
itemBuilder: (context, mIndex) {
|
||||||
|
if (_galleryItemsLastYears.isNotEmpty && mIndex == 0) {
|
||||||
|
return SizedBox(
|
||||||
|
height: 140,
|
||||||
|
width: MediaQuery.sizeOf(context).width,
|
||||||
|
child: ListView(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
children: _galleryItemsLastYears.entries.map(
|
||||||
|
(item) {
|
||||||
|
var text = context.lang.memoriesAYearAgo;
|
||||||
|
if (item.key > 1) {
|
||||||
|
text = context.lang.memoriesXYearsAgo(item.key);
|
||||||
|
}
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: () async {
|
||||||
|
await open(context, item.value, 0);
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
boxShadow: const [
|
||||||
|
BoxShadow(
|
||||||
|
spreadRadius: -12,
|
||||||
|
blurRadius: 12,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
clipBehavior: Clip.hardEdge,
|
||||||
|
height: 150,
|
||||||
|
width: 120,
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
Positioned.fill(
|
||||||
|
child: ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
child: Image.file(
|
||||||
|
item.value.first.mediaService
|
||||||
|
.storedPath,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
bottom: 10,
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
child: Text(
|
||||||
|
text,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 20,
|
||||||
|
shadows: [
|
||||||
|
Shadow(
|
||||||
|
color:
|
||||||
|
Color.fromARGB(122, 0, 0, 0),
|
||||||
|
blurRadius: 5,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
).toList(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (_galleryItemsLastYears.isNotEmpty) {
|
||||||
|
mIndex -= 1;
|
||||||
|
}
|
||||||
if (mIndex.isEven) {
|
if (mIndex.isEven) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.all(8),
|
padding: const EdgeInsets.all(8),
|
||||||
|
|
@ -117,7 +205,7 @@ class MemoriesViewState extends State<MemoriesView> {
|
||||||
return MemoriesItemThumbnail(
|
return MemoriesItemThumbnail(
|
||||||
galleryItem: galleryItems[gaIndex],
|
galleryItem: galleryItems[gaIndex],
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
await open(context, gaIndex);
|
await open(context, galleryItems, gaIndex);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
@ -128,7 +216,8 @@ class MemoriesViewState extends State<MemoriesView> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> open(BuildContext context, int index) async {
|
Future<void> open(
|
||||||
|
BuildContext context, List<MemoryItem> galleryItems, int index) async {
|
||||||
await Navigator.push(
|
await Navigator.push(
|
||||||
context,
|
context,
|
||||||
PageRouteBuilder(
|
PageRouteBuilder(
|
||||||
|
|
@ -136,13 +225,7 @@ class MemoriesViewState extends State<MemoriesView> {
|
||||||
pageBuilder: (context, a1, a2) => MemoriesPhotoSliderView(
|
pageBuilder: (context, a1, a2) => MemoriesPhotoSliderView(
|
||||||
galleryItems: galleryItems,
|
galleryItems: galleryItems,
|
||||||
initialIndex: index,
|
initialIndex: index,
|
||||||
scrollDirection: verticalGallery ? Axis.vertical : Axis.horizontal,
|
|
||||||
),
|
),
|
||||||
// transitionsBuilder: (context, animation, secondaryAnimation, child) {
|
|
||||||
// return child;
|
|
||||||
// },
|
|
||||||
// transitionDuration: Duration.zero,
|
|
||||||
// reverseTransitionDuration: Duration.zero,
|
|
||||||
),
|
),
|
||||||
) as bool?;
|
) as bool?;
|
||||||
if (mounted) setState(() {});
|
if (mounted) setState(() {});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue