Merge branch 'main' into cities

This commit is contained in:
Vishnu Mohandas 2024-01-24 09:49:01 +05:30 committed by GitHub
commit 2c0069ff6e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 19 additions and 9 deletions

View file

@ -23,7 +23,7 @@ class EmbeddingsDB {
}
Future<void> clearTable() async {
await _isar.clear();
await _isar.writeTxn(() => _isar.clear());
}
Future<List<Embedding>> getAll(Model model) async {

View file

@ -91,18 +91,24 @@ class _MemoriesWidgetState extends State<MemoriesWidget> {
return SizedBox(
height: _maxHeight,
child: ListView.builder(
physics: const BouncingScrollPhysics(),
physics: const AlwaysScrollableScrollPhysics(
parent: BouncingScrollPhysics(),
),
scrollDirection: Axis.horizontal,
controller: _controller,
itemCount: collatedMemories.length,
itemBuilder: (context, itemIndex) {
final offsetOfItem = _maxWidth * itemIndex;
final maxScaleOffsetX =
_maxWidth + MemoryCoverWidget.horizontalPadding * 2;
final offsetOfItem =
(_maxWidth + MemoryCoverWidget.horizontalPadding * 2) * itemIndex;
return MemoryCoverWidget(
memories: collatedMemories[itemIndex],
controller: _controller,
offsetOfItem: offsetOfItem,
maxHeight: _maxHeight,
maxWidth: _maxWidth,
maxScaleOffsetX: maxScaleOffsetX,
);
},
),

View file

@ -14,6 +14,8 @@ class MemoryCoverWidget extends StatefulWidget {
final double maxWidth;
static const centerStrokeWidth = 1.0;
static const aspectRatio = 0.68;
static const horizontalPadding = 2.5;
final double maxScaleOffsetX;
const MemoryCoverWidget({
required this.memories,
@ -21,6 +23,7 @@ class MemoryCoverWidget extends StatefulWidget {
required this.offsetOfItem,
required this.maxHeight,
required this.maxWidth,
required this.maxScaleOffsetX,
super.key,
});
@ -48,13 +51,12 @@ class _MemoryCoverWidgetState extends State<MemoryCoverWidget> {
animation: widget.controller,
builder: (context, child) {
final diff = (widget.controller.offset - widget.offsetOfItem) +
widthOfScreen / 7;
widget.maxScaleOffsetX;
final scale = 1 - (diff / widthOfScreen).abs() / 3.7;
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 2.5),
//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].
padding: const EdgeInsets.symmetric(
horizontal: MemoryCoverWidget.horizontalPadding,
),
child: GestureDetector(
onTap: () async {
await routeToPage(
@ -67,7 +69,9 @@ class _MemoryCoverWidgetState extends State<MemoryCoverWidget> {
forceCustomPageRoute: true,
);
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(