Merge branch 'clean_up_memories' into memory_improvement
This commit is contained in:
@@ -741,6 +741,7 @@ class _MemoriesZoomWidgetState extends State<MemoriesZoomWidget>
|
||||
: ClipRect(
|
||||
child: AnimatedBuilder(
|
||||
animation: _controller,
|
||||
child: widget.child,
|
||||
builder: (context, child) {
|
||||
return Transform.scale(
|
||||
scale: _scaleAnimation.value,
|
||||
@@ -749,7 +750,7 @@ class _MemoriesZoomWidgetState extends State<MemoriesZoomWidget>
|
||||
_panAnimation.value.dx * 100,
|
||||
_panAnimation.value.dy * 100,
|
||||
),
|
||||
child: widget.child,
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -20,12 +20,11 @@ class MemoriesWidget extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _MemoriesWidgetState extends State<MemoriesWidget> {
|
||||
late ScrollController _controller;
|
||||
late StreamSubscription<MemoriesSettingChanged> _memoriesSettingSubscription;
|
||||
late StreamSubscription<MemoriesChangedEvent> _memoriesChangedSubscription;
|
||||
late StreamSubscription<MemorySeenEvent> _memorySeenSubscription;
|
||||
late double _maxHeight;
|
||||
late double _maxWidth;
|
||||
late double _memoryheight;
|
||||
late double _memoryWidth;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -48,7 +47,6 @@ class _MemoriesWidgetState extends State<MemoriesWidget> {
|
||||
setState(() {});
|
||||
}
|
||||
});
|
||||
_controller = ScrollController();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -57,8 +55,8 @@ class _MemoriesWidgetState extends State<MemoriesWidget> {
|
||||
final screenWidth = MediaQuery.sizeOf(context).width;
|
||||
//factor will be 2 for most phones in portrait mode
|
||||
final factor = (screenWidth / 220).ceil();
|
||||
_maxWidth = screenWidth / (factor * 2);
|
||||
_maxHeight = _maxWidth / MemoryCoverWidget.aspectRatio;
|
||||
_memoryWidth = screenWidth / (factor * 2);
|
||||
_memoryheight = _memoryWidth / MemoryCoverWidget.aspectRatio;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -66,7 +64,6 @@ class _MemoriesWidgetState extends State<MemoriesWidget> {
|
||||
_memoriesSettingSubscription.cancel();
|
||||
_memoriesChangedSubscription.cancel();
|
||||
_memorySeenSubscription.cancel();
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -84,7 +81,7 @@ class _MemoriesWidgetState extends State<MemoriesWidget> {
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasError || !snapshot.hasData) {
|
||||
return SizedBox(
|
||||
height: _maxHeight + 12 + 10,
|
||||
height: _memoryheight + 12 + 10,
|
||||
child: const EnteLoadingWidget(),
|
||||
);
|
||||
} else {
|
||||
@@ -121,21 +118,19 @@ class _MemoriesWidgetState extends State<MemoriesWidget> {
|
||||
collatedMemories.addAll(seenMemories.map((e) => (e.memories, e.title)));
|
||||
|
||||
return SizedBox(
|
||||
height: _maxHeight + MemoryCoverWidget.outerStrokeWidth * 2,
|
||||
height: _memoryheight + MemoryCoverWidget.outerStrokeWidth * 2,
|
||||
child: ListView.builder(
|
||||
physics: const AlwaysScrollableScrollPhysics(
|
||||
parent: BouncingScrollPhysics(),
|
||||
),
|
||||
scrollDirection: Axis.horizontal,
|
||||
controller: _controller,
|
||||
itemCount: collatedMemories.length,
|
||||
itemBuilder: (context, itemIndex) {
|
||||
return MemoryCoverWidget(
|
||||
memories: collatedMemories[itemIndex].$1,
|
||||
allMemories: collatedMemories.map((e) => e.$1).toList(),
|
||||
controller: _controller,
|
||||
maxHeight: _maxHeight,
|
||||
maxWidth: _maxWidth,
|
||||
maxHeight: _memoryheight,
|
||||
maxWidth: _memoryWidth,
|
||||
title: collatedMemories[itemIndex].$2,
|
||||
allTitle: collatedMemories.map((e) => e.$2).toList(),
|
||||
currentMemoryIndex: itemIndex,
|
||||
|
||||
@@ -12,7 +12,6 @@ import "package:photos/utils/navigation_util.dart";
|
||||
class MemoryCoverWidget extends StatefulWidget {
|
||||
final List<Memory> memories;
|
||||
final List<List<Memory>> allMemories;
|
||||
final ScrollController controller;
|
||||
final double maxHeight;
|
||||
final double maxWidth;
|
||||
static const outerStrokeWidth = 1.0;
|
||||
@@ -25,7 +24,6 @@ class MemoryCoverWidget extends StatefulWidget {
|
||||
const MemoryCoverWidget({
|
||||
required this.memories,
|
||||
required this.allMemories,
|
||||
required this.controller,
|
||||
required this.maxHeight,
|
||||
required this.maxWidth,
|
||||
required this.title,
|
||||
@@ -61,160 +59,162 @@ class _MemoryCoverWidgetState extends State<MemoryCoverWidget> {
|
||||
final brightness =
|
||||
SchedulerBinding.instance.platformDispatcher.platformBrightness;
|
||||
|
||||
return AnimatedBuilder(
|
||||
animation: widget.controller,
|
||||
builder: (context, child) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: MemoryCoverWidget.horizontalPadding,
|
||||
),
|
||||
child: GestureDetector(
|
||||
onTap: () async {
|
||||
await routeToPage(
|
||||
context,
|
||||
forceCustomPageRoute: true,
|
||||
AllMemoriesPage(
|
||||
initialPageIndex: widget.currentMemoryIndex,
|
||||
allMemories: widget.allMemories,
|
||||
allTitles: widget.allTitle,
|
||||
),
|
||||
);
|
||||
setState(() {});
|
||||
}, //Adding this row is a workaround for making height of memory cover
|
||||
//render as [MemoryCoverWidgetNew.height] * scale. Without this, height of rendered memory
|
||||
//cover will be [MemoryCoverWidgetNew.height].
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
height: widget.maxHeight,
|
||||
width: widget.maxWidth,
|
||||
decoration: BoxDecoration(
|
||||
boxShadow: brightness == Brightness.dark
|
||||
? [
|
||||
const BoxShadow(
|
||||
color: strokeFainterDark,
|
||||
spreadRadius: MemoryCoverWidget.outerStrokeWidth,
|
||||
blurRadius: 0,
|
||||
),
|
||||
]
|
||||
: [...shadowFloatFaintestLight],
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
child: isSeen
|
||||
? ColorFiltered(
|
||||
colorFilter: const ColorFilter.mode(
|
||||
Color(0xFFBFBFBF),
|
||||
BlendMode.hue,
|
||||
),
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
alignment: Alignment.bottomCenter,
|
||||
children: [
|
||||
child!,
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
Colors.black.withOpacity(0.5),
|
||||
Colors.transparent,
|
||||
],
|
||||
stops: const [0, 1],
|
||||
begin: Alignment.bottomCenter,
|
||||
end: Alignment.topCenter,
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 8,
|
||||
child: SizedBox(
|
||||
width: widget.maxWidth,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8.0,
|
||||
),
|
||||
child: Hero(
|
||||
tag: title,
|
||||
child: Center(
|
||||
child: Text(
|
||||
title,
|
||||
style: getEnteTextTheme(context)
|
||||
.miniBold
|
||||
.copyWith(
|
||||
color: isSeen
|
||||
? textFaintDark
|
||||
: Colors.white,
|
||||
),
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: Stack(
|
||||
fit: StackFit.expand,
|
||||
alignment: Alignment.bottomCenter,
|
||||
children: [
|
||||
child!,
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
Colors.black.withOpacity(0.5),
|
||||
Colors.transparent,
|
||||
],
|
||||
stops: const [0, 1],
|
||||
begin: Alignment.bottomCenter,
|
||||
end: Alignment.topCenter,
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 8,
|
||||
child: SizedBox(
|
||||
width: widget.maxWidth,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8.0,
|
||||
),
|
||||
child: Hero(
|
||||
tag: title,
|
||||
child: Center(
|
||||
child: Text(
|
||||
title,
|
||||
style: getEnteTextTheme(context)
|
||||
.miniBold
|
||||
.copyWith(
|
||||
color: Colors.white,
|
||||
),
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: MemoryCoverWidget.horizontalPadding,
|
||||
),
|
||||
child: GestureDetector(
|
||||
onTap: () async {
|
||||
await routeToPage(
|
||||
context,
|
||||
forceCustomPageRoute: true,
|
||||
AllMemoriesPage(
|
||||
initialPageIndex: widget.currentMemoryIndex,
|
||||
allMemories: widget.allMemories,
|
||||
allTitles: widget.allTitle,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Hero(
|
||||
tag: "memories" + memory.file.tag,
|
||||
child: ThumbnailWidget(
|
||||
memory.file,
|
||||
shouldShowArchiveStatus: false,
|
||||
shouldShowSyncStatus: false,
|
||||
key: Key("memories" + memory.file.tag),
|
||||
);
|
||||
setState(() {});
|
||||
}, //Adding this row is a workaround for making height of memory cover
|
||||
//render as [MemoryCoverWidgetNew.height] * scale. Without this, height of rendered memory
|
||||
//cover will be [MemoryCoverWidgetNew.height].
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
height: widget.maxHeight,
|
||||
width: widget.maxWidth,
|
||||
decoration: BoxDecoration(
|
||||
boxShadow: brightness == Brightness.dark
|
||||
? [
|
||||
const BoxShadow(
|
||||
color: strokeFainterDark,
|
||||
spreadRadius: MemoryCoverWidget.outerStrokeWidth,
|
||||
blurRadius: 0,
|
||||
),
|
||||
]
|
||||
: [...shadowFloatFaintestLight],
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
child: isSeen
|
||||
? ColorFiltered(
|
||||
colorFilter: const ColorFilter.mode(
|
||||
Color(0xFFBFBFBF),
|
||||
BlendMode.hue,
|
||||
),
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
alignment: Alignment.bottomCenter,
|
||||
children: [
|
||||
Hero(
|
||||
tag: "memories" + memory.file.tag,
|
||||
child: ThumbnailWidget(
|
||||
memory.file,
|
||||
shouldShowArchiveStatus: false,
|
||||
shouldShowSyncStatus: false,
|
||||
key: Key("memories" + memory.file.tag),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
Colors.black.withOpacity(0.5),
|
||||
Colors.transparent,
|
||||
],
|
||||
stops: const [0, 1],
|
||||
begin: Alignment.bottomCenter,
|
||||
end: Alignment.topCenter,
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 8,
|
||||
child: SizedBox(
|
||||
width: widget.maxWidth,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8.0,
|
||||
),
|
||||
child: Hero(
|
||||
tag: title,
|
||||
child: Center(
|
||||
child: Text(
|
||||
title,
|
||||
style: getEnteTextTheme(context)
|
||||
.miniBold
|
||||
.copyWith(
|
||||
color: isSeen
|
||||
? textFaintDark
|
||||
: Colors.white,
|
||||
),
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: Stack(
|
||||
fit: StackFit.expand,
|
||||
alignment: Alignment.bottomCenter,
|
||||
children: [
|
||||
Hero(
|
||||
tag: "memories" + memory.file.tag,
|
||||
child: ThumbnailWidget(
|
||||
memory.file,
|
||||
shouldShowArchiveStatus: false,
|
||||
shouldShowSyncStatus: false,
|
||||
key: Key("memories" + memory.file.tag),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
Colors.black.withOpacity(0.5),
|
||||
Colors.transparent,
|
||||
],
|
||||
stops: const [0, 1],
|
||||
begin: Alignment.bottomCenter,
|
||||
end: Alignment.topCenter,
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 8,
|
||||
child: SizedBox(
|
||||
width: widget.maxWidth,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8.0,
|
||||
),
|
||||
child: Hero(
|
||||
tag: title,
|
||||
child: Center(
|
||||
child: Text(
|
||||
title,
|
||||
style: getEnteTextTheme(context)
|
||||
.miniBold
|
||||
.copyWith(
|
||||
color: Colors.white,
|
||||
),
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -222,11 +222,13 @@ class _MemoryCoverWidgetState extends State<MemoryCoverWidget> {
|
||||
|
||||
void _preloadFirstUnseenMemory() {
|
||||
Future.delayed(const Duration(seconds: 5), () {
|
||||
if (widget.memories.isEmpty) return;
|
||||
if (mounted) {
|
||||
if (widget.memories.isEmpty) return;
|
||||
|
||||
final index = _getNextMemoryIndex();
|
||||
preloadThumbnail(widget.memories[index].file);
|
||||
preloadFile(widget.memories[index].file);
|
||||
final index = _getNextMemoryIndex();
|
||||
preloadThumbnail(widget.memories[index].file);
|
||||
preloadFile(widget.memories[index].file);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user