Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into independent
Browse files Browse the repository at this point in the history
  • Loading branch information
vishnukvmd committed Jan 19, 2024
2 parents e09be34 + cb0b12d commit 67c693d
Show file tree
Hide file tree
Showing 10 changed files with 136 additions and 50 deletions.
21 changes: 21 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,21 @@ PODS:
- sqflite (0.0.3):
- Flutter
- FMDB (>= 2.7.5)
- sqlite3 (3.45.0):
- sqlite3/common (= 3.45.0)
- sqlite3/common (3.45.0)
- sqlite3/fts5 (3.45.0):
- sqlite3/common
- sqlite3/perf-threadsafe (3.45.0):
- sqlite3/common
- sqlite3/rtree (3.45.0):
- sqlite3/common
- sqlite3_flutter_libs (0.0.1):
- Flutter
- sqlite3 (~> 3.45.0)
- sqlite3/fts5
- sqlite3/perf-threadsafe
- sqlite3/rtree
- Toast (4.0.0)
- uni_links (0.0.1):
- Flutter
Expand Down Expand Up @@ -235,6 +250,7 @@ DEPENDENCIES:
- share_plus (from `.symlinks/plugins/share_plus/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- sqflite (from `.symlinks/plugins/sqflite/ios`)
- sqlite3_flutter_libs (from `.symlinks/plugins/sqlite3_flutter_libs/ios`)
- uni_links (from `.symlinks/plugins/uni_links/ios`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
- video_player_avfoundation (from `.symlinks/plugins/video_player_avfoundation/ios`)
Expand Down Expand Up @@ -264,6 +280,7 @@ SPEC REPOS:
- SDWebImageWebPCoder
- Sentry
- SentryPrivate
- sqlite3
- Toast

EXTERNAL SOURCES:
Expand Down Expand Up @@ -343,6 +360,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
sqflite:
:path: ".symlinks/plugins/sqflite/ios"
sqlite3_flutter_libs:
:path: ".symlinks/plugins/sqlite3_flutter_libs/ios"
uni_links:
:path: ".symlinks/plugins/uni_links/ios"
url_launcher_ios:
Expand Down Expand Up @@ -415,6 +434,8 @@ SPEC CHECKSUMS:
share_plus: 056a1e8ac890df3e33cb503afffaf1e9b4fbae68
shared_preferences_foundation: e2dae3258e06f44cc55f49d42024fd8dd03c590c
sqflite: 31f7eba61e3074736dff8807a9b41581e4f7f15a
sqlite3: f307b6291c4db7b5086c38d6237446b98a738581
sqlite3_flutter_libs: aeb4d37509853dfa79d9b59386a2dac5dd079428
Toast: 91b396c56ee72a5790816f40d3a94dd357abc196
uni_links: d97da20c7701486ba192624d99bffaaffcfc298a
url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4
Expand Down
4 changes: 4 additions & 0 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@
"${BUILT_PRODUCTS_DIR}/share_plus/share_plus.framework",
"${BUILT_PRODUCTS_DIR}/shared_preferences_foundation/shared_preferences_foundation.framework",
"${BUILT_PRODUCTS_DIR}/sqflite/sqflite.framework",
"${BUILT_PRODUCTS_DIR}/sqlite3/sqlite3.framework",
"${BUILT_PRODUCTS_DIR}/sqlite3_flutter_libs/sqlite3_flutter_libs.framework",
"${BUILT_PRODUCTS_DIR}/uni_links/uni_links.framework",
"${BUILT_PRODUCTS_DIR}/url_launcher_ios/url_launcher_ios.framework",
"${BUILT_PRODUCTS_DIR}/video_player_avfoundation/video_player_avfoundation.framework",
Expand Down Expand Up @@ -390,6 +392,8 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/share_plus.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences_foundation.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sqflite.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sqlite3.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sqlite3_flutter_libs.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/uni_links.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher_ios.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/video_player_avfoundation.framework",
Expand Down
49 changes: 49 additions & 0 deletions lib/db/files_db.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import "package:photos/services/filter/db_filters.dart";
import 'package:photos/utils/file_uploader_util.dart';
import 'package:sqflite/sqflite.dart';
import 'package:sqflite_migration/sqflite_migration.dart';
import 'package:sqlite3/sqlite3.dart' as sqlite3;

class FilesDB {
/*
Expand Down Expand Up @@ -100,13 +101,19 @@ class FilesDB {

// only have a single app-wide reference to the database
static Future<Database>? _dbFuture;
static Future<sqlite3.Database>? _ffiDBFuture;

Future<Database> get database async {
// lazily instantiate the db the first time it is accessed
_dbFuture ??= _initDatabase();
return _dbFuture!;
}

Future<sqlite3.Database> get ffiDB async {
_ffiDBFuture ??= _initFFIDatabase();
return _ffiDBFuture!;
}

// this opens the database (and creates it if it doesn't exist)
Future<Database> _initDatabase() async {
final Directory documentsDirectory =
Expand All @@ -116,6 +123,14 @@ class FilesDB {
return await openDatabaseWithMigration(path, dbConfig);
}

Future<sqlite3.Database> _initFFIDatabase() async {
final Directory documentsDirectory =
await getApplicationDocumentsDirectory();
final String path = join(documentsDirectory.path, _databaseName);
_logger.info("DB path " + path);
return sqlite3.sqlite3.open(path);
}

// SQL code to create the database table
static List<String> createTable(String tableName) {
return [
Expand Down Expand Up @@ -749,6 +764,40 @@ class FilesDB {
);
}

Future<List<EnteFile>> getFilesCreatedWithinDurationsSync(
List<List<int>> durations,
Set<int> ignoredCollectionIDs, {
int? visibility,
String order = 'ASC',
}) async {
if (durations.isEmpty) {
return <EnteFile>[];
}
final db = await instance.ffiDB;
String whereClause = "( ";
for (int index = 0; index < durations.length; index++) {
whereClause += "($columnCreationTime >= " +
durations[index][0].toString() +
" AND $columnCreationTime < " +
durations[index][1].toString() +
")";
if (index != durations.length - 1) {
whereClause += " OR ";
} else if (visibility != null) {
whereClause += ' AND $columnMMdVisibility = $visibility';
}
}
whereClause += ")";
final results = db.select(
'select * from $filesTable where $whereClause order by $columnCreationTime $order',
);
final files = convertToFiles(results);
return applyDBFilters(
files,
DBFilterOptions(ignoredCollectionIDs: ignoredCollectionIDs),
);
}

// Files which user added to a collection manually but they are not
// uploaded yet or files belonging to a collection which is marked for backup
Future<List<EnteFile>> getFilesPendingForUpload() async {
Expand Down
2 changes: 1 addition & 1 deletion lib/services/memories_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class MemoriesService extends ChangeNotifier {
}
final ignoredCollections =
CollectionsService.instance.archivedOrHiddenCollectionIds();
final files = await _filesDB.getFilesCreatedWithinDurations(
final files = await _filesDB.getFilesCreatedWithinDurationsSync(
durations,
ignoredCollections,
visibility: visibleVisibility,
Expand Down
14 changes: 5 additions & 9 deletions lib/ui/home/header_widget.dart
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
import 'package:flutter/widgets.dart';
import 'package:logging/logging.dart';
import 'package:photos/ui/home/memories/memories_widget.dart';
import "package:photos/ui/home/memories/memories_widget.dart";
import 'package:photos/ui/home/status_bar_widget.dart';

class HeaderWidget extends StatelessWidget {
static const _memoriesWidget = MemoriesWidget();
static const _statusBarWidget = StatusBarWidget();

const HeaderWidget({
Key? key,
}) : super(key: key);

@override
Widget build(BuildContext context) {
Logger("Header").info("Building header widget");
const list = [
_statusBarWidget,
_memoriesWidget,
];
return const Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: list,
children: [
StatusBarWidget(),
MemoriesWidget(),
],
);
}
}
16 changes: 8 additions & 8 deletions lib/ui/home/memories/full_screen_memory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,13 @@ class _FullScreenMemoryState extends State<FullScreenMemory> {
automaticallyImplyLeading: false,
title: ValueListenableBuilder(
valueListenable: inheritedData.indexNotifier,
child: Padding(
padding: const EdgeInsets.only(right: 16),
child: InkWell(
onTap: () {
Navigator.pop(context);
},
child: const Icon(
child: InkWell(
onTap: () {
Navigator.pop(context);
},
child: const Padding(
padding: EdgeInsets.fromLTRB(4, 8, 8, 8),
child: Icon(
Icons.close,
color: Colors.white, //same for both themes
),
Expand All @@ -180,7 +180,7 @@ class _FullScreenMemoryState extends State<FullScreenMemory> {
)
: const SizedBox.shrink(),
const SizedBox(
height: 18,
height: 10,
),
Row(
children: [
Expand Down
18 changes: 9 additions & 9 deletions lib/ui/home/memories/memories_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ class _MemoriesWidgetState extends State<MemoriesWidget> {
return FutureBuilder<List<Memory>>(
future: MemoriesService.instance.getMemories(),
builder: (context, snapshot) {
if (snapshot.hasError || !snapshot.hasData || snapshot.data!.isEmpty) {
if (snapshot.hasData && snapshot.data!.isEmpty) {
return const SizedBox.shrink();
}
if (snapshot.hasError || !snapshot.hasData) {
return SizedBox(
height: _maxHeight + 12 + 10,
child: const EnteLoadingWidget(),
Expand All @@ -73,7 +76,10 @@ class _MemoriesWidgetState extends State<MemoriesWidget> {
_buildMemories(snapshot.data!),
const SizedBox(height: 10),
],
);
).animate().fadeIn(
duration: const Duration(milliseconds: 250),
curve: Curves.easeInOutCirc,
);
}
},
);
Expand All @@ -97,13 +103,7 @@ class _MemoriesWidgetState extends State<MemoriesWidget> {
offsetOfItem: offsetOfItem,
maxHeight: _maxHeight,
maxWidth: _maxWidth,
)
.animate(delay: Duration(milliseconds: 75 * itemIndex))
.fadeIn(
duration: const Duration(milliseconds: 250),
curve: Curves.easeInOutCubic,
)
.slideX(begin: 0.04, end: 0);
);
},
),
);
Expand Down
18 changes: 8 additions & 10 deletions lib/ui/huge_listview/draggable_scrollbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,14 @@ class DraggableScrollbarState extends State<DraggableScrollbar>

@override
Widget build(BuildContext context) {
if (widget.isEnabled) {
return Stack(
children: [
RepaintBoundary(child: widget.child),
RepaintBoundary(child: buildThumb()),
],
);
} else {
return widget.child;
}
return Stack(
children: [
RepaintBoundary(child: widget.child),
widget.isEnabled
? RepaintBoundary(child: buildThumb())
: const SizedBox.shrink(),
],
);
}

Widget buildThumb() => Padding(
Expand Down
40 changes: 28 additions & 12 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ packages:
dependency: "direct main"
description:
name: archive
sha256: "7b875fd4a20b165a3084bd2d210439b22ebc653f21cea4842729c0c30c82596b"
sha256: "20071638cbe4e5964a427cfa0e86dce55d060bc7d82d56f3554095d7239a8765"
url: "https://pub.dev"
source: hosted
version: "3.4.9"
version: "3.4.2"
args:
dependency: transitive
description:
Expand Down Expand Up @@ -133,10 +133,10 @@ packages:
dependency: transitive
description:
name: build_daemon
sha256: "0343061a33da9c5810b2d6cee51945127d8f4c060b7fbdd9d54917f0a3feaaa1"
sha256: "5f02d73eb2ba16483e693f80bee4f088563a820e47d1027d4cdfe62b5bb43e65"
url: "https://pub.dev"
source: hosted
version: "4.0.1"
version: "4.0.0"
build_resolvers:
dependency: transitive
description:
Expand Down Expand Up @@ -319,10 +319,10 @@ packages:
dependency: "direct main"
description:
name: crypto
sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab
sha256: aa274aa7774f8964e4f4f38cc994db7b6158dd36e9187aaceaddc994b35c6c67
url: "https://pub.dev"
source: hosted
version: "3.0.3"
version: "3.0.2"
csslib:
dependency: transitive
description:
Expand All @@ -343,10 +343,10 @@ packages:
dependency: transitive
description:
name: dart_style
sha256: "1efa911ca7086affd35f463ca2fc1799584fb6aa89883cf0af8e3664d6a02d55"
sha256: f4f1f73ab3fd2afcbcca165ee601fe980d966af6a21b5970c6c9376955c528ad
url: "https://pub.dev"
source: hosted
version: "2.3.2"
version: "2.3.1"
dartx:
dependency: transitive
description:
Expand Down Expand Up @@ -1478,10 +1478,10 @@ packages:
dependency: transitive
description:
name: path_provider_android
sha256: e595b98692943b4881b219f0a9e3945118d3c16bd7e2813f98ec6e532d905f72
sha256: "477184d672607c0a3bf68fbbf601805f92ef79c82b64b4d6eb318cbca4c48668"
url: "https://pub.dev"
source: hosted
version: "2.2.1"
version: "2.2.2"
path_provider_foundation:
dependency: transitive
description:
Expand Down Expand Up @@ -1951,6 +1951,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.3.0"
sqlite3:
dependency: "direct main"
description:
name: sqlite3
sha256: db65233e6b99e99b2548932f55a987961bc06d82a31a0665451fa0b4fff4c3fb
url: "https://pub.dev"
source: hosted
version: "2.1.0"
sqlite3_flutter_libs:
dependency: "direct main"
description:
name: sqlite3_flutter_libs
sha256: "90963b515721d6a71e96f438175cf43c979493ed14822860a300b69694c74eb6"
url: "https://pub.dev"
source: hosted
version: "0.5.19+1"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -2436,10 +2452,10 @@ packages:
dependency: transitive
description:
name: xmlstream
sha256: cfc14e3f256997897df9481ae630d94c2d85ada5187ebeb868bb1aabc2c977b4
sha256: "2d10c69a9d5fc46f71798b80ee6db15bc0d5bf560fdbdd264776cbeee0c83631"
url: "https://pub.dev"
source: hosted
version: "1.1.1"
version: "1.0.0"
xxh3:
dependency: transitive
description:
Expand Down
Loading

0 comments on commit 67c693d

Please sign in to comment.