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

Commit

Permalink
Merge branch 'update_dialog' into independent
Browse files Browse the repository at this point in the history
  • Loading branch information
ua741 committed Nov 9, 2022
2 parents c8122ea + 198ad98 commit 12662bd
Show file tree
Hide file tree
Showing 19 changed files with 504 additions and 62 deletions.
6 changes: 6 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ PODS:
- nanopb/encode (= 2.30909.0)
- nanopb/decode (2.30909.0)
- nanopb/encode (2.30909.0)
- open_file (0.0.1):
- Flutter
- open_mail_app (0.0.1):
- Flutter
- OrderedSet (5.0.0)
Expand Down Expand Up @@ -197,6 +199,7 @@ DEPENDENCIES:
- media_extension (from `.symlinks/plugins/media_extension/ios`)
- motionphoto (from `.symlinks/plugins/motionphoto/ios`)
- move_to_background (from `.symlinks/plugins/move_to_background/ios`)
- open_file (from `.symlinks/plugins/open_file/ios`)
- open_mail_app (from `.symlinks/plugins/open_mail_app/ios`)
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- path_provider_ios (from `.symlinks/plugins/path_provider_ios/ios`)
Expand Down Expand Up @@ -279,6 +282,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/motionphoto/ios"
move_to_background:
:path: ".symlinks/plugins/move_to_background/ios"
open_file:
:path: ".symlinks/plugins/open_file/ios"
open_mail_app:
:path: ".symlinks/plugins/open_mail_app/ios"
package_info_plus:
Expand Down Expand Up @@ -343,6 +348,7 @@ SPEC CHECKSUMS:
motionphoto: d4a432b8c8f22fb3ad966258597c0103c9c5ff16
move_to_background: 39a5b79b26d577b0372cbe8a8c55e7aa9fcd3a2d
nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431
open_file: 02eb5cb6b21264bd3a696876f5afbfb7ca4f4b7d
open_mail_app: 794172f6a22cd16319d3ddaf45e945b2f74952b0
OrderedSet: aaeb196f7fef5a9edf55d89760da9176ad40b93c
package_info_plus: 6c92f08e1f853dc01228d6f553146438dafcd14e
Expand Down
2 changes: 2 additions & 0 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@
"${BUILT_PRODUCTS_DIR}/motionphoto/motionphoto.framework",
"${BUILT_PRODUCTS_DIR}/move_to_background/move_to_background.framework",
"${BUILT_PRODUCTS_DIR}/nanopb/nanopb.framework",
"${BUILT_PRODUCTS_DIR}/open_file/open_file.framework",
"${BUILT_PRODUCTS_DIR}/open_mail_app/open_mail_app.framework",
"${BUILT_PRODUCTS_DIR}/package_info_plus/package_info_plus.framework",
"${BUILT_PRODUCTS_DIR}/path_provider_ios/path_provider_ios.framework",
Expand Down Expand Up @@ -347,6 +348,7 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/motionphoto.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/move_to_background.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/nanopb.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/open_file.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/open_mail_app.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/package_info_plus.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider_ios.framework",
Expand Down
1 change: 1 addition & 0 deletions lib/db/device_files_db.dart
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ extension DeviceFiles on FilesDB {
"cover_id": localID,
"should_backup": shouldBackup ? _sqlBoolTrue : _sqlBoolFalse
},
conflictAlgorithm: ConflictAlgorithm.ignore,
);
}
}
Expand Down
6 changes: 4 additions & 2 deletions lib/services/remote_sync_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,8 @@ class RemoteSyncService {
File existingFile;
if (remoteDiff.generatedID != null) {
// Case [1] Check and clear local cache when uploadedFile already exist
// Note: Existing file can be null here if it's replaced by the time we
// reach here
existingFile = await _db.getFile(remoteDiff.generatedID);
if (_shouldClearCache(remoteDiff, existingFile)) {
needsGalleryReload = true;
Expand Down Expand Up @@ -692,10 +694,10 @@ class RemoteSyncService {
}

bool _shouldClearCache(File remoteFile, File existingFile) {
if (remoteFile.hash != null && existingFile.hash != null) {
if (remoteFile.hash != null && existingFile?.hash != null) {
return remoteFile.hash != existingFile.hash;
}
return remoteFile.updationTime != (existingFile.updationTime ?? 0);
return remoteFile.updationTime != (existingFile?.updationTime ?? 0);
}

bool _shouldReloadHomeGallery(File remoteFile, File existingFile) {
Expand Down
16 changes: 16 additions & 0 deletions lib/services/update_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class UpdateService {

static final UpdateService instance = UpdateService._privateConstructor();
static const kUpdateAvailableShownTimeKey = "update_available_shown_time_key";
static const changeLogVersionKey = "update_change_log_key";
static const currentChangeLogVersion = 1;

LatestVersionInfo _latestVersion;
final _logger = Logger("UpdateService");
Expand All @@ -26,6 +28,20 @@ class UpdateService {
_prefs = await SharedPreferences.getInstance();
}

Future<bool> showChangeLog() async {
// fetch the change log version which was last shown to user.
final lastShownAtVersion = _prefs.getInt(changeLogVersionKey) ?? 0;
return lastShownAtVersion < currentChangeLogVersion;
}

Future<bool> hideChangeLog() async {
return _prefs.setInt(changeLogVersionKey, currentChangeLogVersion);
}

Future<bool> resetChangeLog() {
return _prefs.remove(changeLogVersionKey);
}

Future<bool> shouldUpdate() async {
if (!isIndependent()) {
return false;
Expand Down
6 changes: 3 additions & 3 deletions lib/theme/colors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ const Color strokeBaseDark = Color.fromRGBO(255, 255, 255, 1);
const Color strokeMutedDark = Color.fromRGBO(255, 255, 255, 0.24);
const Color strokeFaintDark = Color.fromRGBO(255, 255, 255, 0.16);
const Color strokeFainterDark = Color.fromRGBO(255, 255, 255, 0.08);
const Color blurStrokeBaseDark = Color.fromRGBO(0, 0, 0, 0.90);
const Color blurStrokeFaintDark = Color.fromRGBO(0, 0, 0, 0.08);
const Color blurStrokePressedDark = Color.fromRGBO(0, 0, 0, 0.50);
const Color blurStrokeBaseDark = Color.fromRGBO(255, 255, 255, 0.90);
const Color blurStrokeFaintDark = Color.fromRGBO(255, 255, 255, 0.08);
const Color blurStrokePressedDark = Color.fromRGBO(255, 255, 255, 0.50);

// Other colors
const Color tabIconLight = Color.fromRGBO(0, 0, 0, 0.85);
Expand Down
37 changes: 20 additions & 17 deletions lib/ui/components/divider_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class DividerWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final dividerColor = getEnteColorScheme(context).blurStrokeFaint;

if (dividerType == DividerType.solid) {
return Container(
color: getEnteColorScheme(context).strokeFaint,
Expand All @@ -35,25 +36,27 @@ class DividerWidget extends StatelessWidget {
);
}

return Row(
children: [
Container(
color: bgColor,
width: dividerType == DividerType.menu
? 48
: dividerType == DividerType.menuNoIcon
? 16
: 0,
height: 1,
),
Expanded(
child: Container(
color: dividerColor,
return Container(
color: bgColor,
child: Row(
children: [
SizedBox(
width: dividerType == DividerType.menu
? 48
: dividerType == DividerType.menuNoIcon
? 16
: 0,
height: 1,
width: double.infinity,
),
),
],
Expanded(
child: Container(
color: dividerColor,
height: 1,
width: double.infinity,
),
),
],
),
);
}
}
3 changes: 3 additions & 0 deletions lib/ui/components/title_bar_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class TitleBarWidget extends StatelessWidget {
final bool isTitleH2WithoutLeading;
final bool isFlexibleSpaceDisabled;
final bool isOnTopOfScreen;
final Color? backgroundColor;
const TitleBarWidget({
this.leading,
this.title,
Expand All @@ -22,6 +23,7 @@ class TitleBarWidget extends StatelessWidget {
this.isTitleH2WithoutLeading = false,
this.isFlexibleSpaceDisabled = false,
this.isOnTopOfScreen = true,
this.backgroundColor,
super.key,
});

Expand All @@ -31,6 +33,7 @@ class TitleBarWidget extends StatelessWidget {
final textTheme = getEnteTextTheme(context);
final colorTheme = getEnteColorScheme(context);
return SliverAppBar(
backgroundColor: backgroundColor,
primary: isOnTopOfScreen ? true : false,
toolbarHeight: toolbarHeight,
leadingWidth: 48,
Expand Down
3 changes: 3 additions & 0 deletions lib/ui/home/landing_page_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:dots_indicator/dots_indicator.dart';
import 'package:flutter/material.dart';
import 'package:photos/core/configuration.dart';
import 'package:photos/ente_theme_data.dart';
import 'package:photos/services/update_service.dart';
import 'package:photos/ui/account/email_entry_page.dart';
import 'package:photos/ui/account/login_page.dart';
import 'package:photos/ui/account/password_entry_page.dart';
Expand Down Expand Up @@ -152,6 +153,7 @@ class _LandingPageWidgetState extends State<LandingPageWidget> {
}

void _navigateToSignUpPage() {
UpdateService.instance.hideChangeLog().ignore();
Widget page;
if (Configuration.instance.getEncryptedToken() == null) {
page = const EmailEntryPage();
Expand All @@ -178,6 +180,7 @@ class _LandingPageWidgetState extends State<LandingPageWidget> {
}

void _navigateToSignInPage() {
UpdateService.instance.hideChangeLog().ignore();
Widget page;
if (Configuration.instance.getEncryptedToken() == null) {
page = const LoginPage();
Expand Down
41 changes: 41 additions & 0 deletions lib/ui/home_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart';
import 'package:logging/logging.dart';
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
import 'package:move_to_background/move_to_background.dart';
import 'package:photos/core/configuration.dart';
import 'package:photos/core/event_bus.dart';
Expand All @@ -26,6 +27,7 @@ import 'package:photos/services/local_sync_service.dart';
import 'package:photos/services/update_service.dart';
import 'package:photos/services/user_service.dart';
import 'package:photos/states/user_details_state.dart';
import 'package:photos/theme/colors.dart';
import 'package:photos/theme/ente_theme.dart';
import 'package:photos/ui/collections_gallery_widget.dart';
import 'package:photos/ui/common/bottom_shadow.dart';
Expand All @@ -39,6 +41,7 @@ import 'package:photos/ui/home/landing_page_widget.dart';
import 'package:photos/ui/home/preserve_footer_widget.dart';
import 'package:photos/ui/home/start_backup_hook_widget.dart';
import 'package:photos/ui/loading_photos_widget.dart';
import 'package:photos/ui/notification/update/change_log_page.dart';
import 'package:photos/ui/settings/app_update_dialog.dart';
import 'package:photos/ui/settings_page.dart';
import 'package:photos/ui/shared_collections_gallery.dart';
Expand Down Expand Up @@ -172,6 +175,15 @@ class _HomeWidgetState extends State<HomeWidget> {
});
// For sharing images coming from outside the app while the app is in the memory
_initMediaShareSubscription();
WidgetsBinding.instance.addPostFrameCallback(
(_) => Future.delayed(
const Duration(seconds: 1),
() => {
if (mounted) {showChangeLog(context)}
},
),
);

super.initState();
}

Expand Down Expand Up @@ -414,4 +426,33 @@ class _HomeWidgetState extends State<HomeWidget> {
final ott = Uri.parse(link).queryParameters["ott"];
UserService.instance.verifyEmail(context, ott);
}

showChangeLog(BuildContext context) async {
final bool show = await UpdateService.instance.showChangeLog();
if (!show || !Configuration.instance.isLoggedIn()) {
return;
}
final colorScheme = getEnteColorScheme(context);
await showBarModalBottomSheet(
topControl: const SizedBox.shrink(),
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(5),
topRight: Radius.circular(5),
),
),
backgroundColor: colorScheme.backgroundElevated,
barrierColor: backdropMutedDark,
context: context,
builder: (BuildContext context) {
return Padding(
padding:
EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
child: const ChangeLogPage(),
);
},
);
// Do not show change dialog again
UpdateService.instance.hideChangeLog().ignore();
}
}
52 changes: 52 additions & 0 deletions lib/ui/notification/update/change_log_entry.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import 'package:flutter/widgets.dart';
import 'package:photos/theme/ente_theme.dart';

class ChangeLogEntry {
final bool isFeature;
final String title;
final String description;

ChangeLogEntry(this.title, this.description, {this.isFeature = true});
}

class ChangeLogEntryWidget extends StatelessWidget {
final ChangeLogEntry entry;

const ChangeLogEntryWidget({
super.key,
required this.entry,
});

@override
Widget build(BuildContext context) {
final enteTheme = getEnteTextTheme(context);
final colorScheme = getEnteColorScheme(context);
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
entry.title,
textAlign: TextAlign.left,
style: enteTheme.largeBold.copyWith(
color: entry.isFeature
? colorScheme.primary700
: colorScheme.textMuted,
),
),
const SizedBox(
height: 18,
),
Text(
entry.description,
textAlign: TextAlign.left,
style: enteTheme.body.copyWith(
color: colorScheme.textMuted,
),
),
const SizedBox(
height: 18,
),
],
);
}
}
Loading

0 comments on commit 12662bd

Please sign in to comment.