Optimize android's Gradle settings and clean up mobile source code (#240)

* optimize android side gradle settings

* android minsdk back to 21

* remove unused package, update linter and fix lint error
This commit is contained in:
xpwmaosldk
2022-06-22 14:23:35 +09:00
committed by GitHub
parent 63bebd92e0
commit caaa474c23
34 changed files with 524 additions and 333 deletions

View File

@@ -28,8 +28,9 @@ class AlbumViewerPage extends HookConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
FocusNode titleFocusNode = useFocusNode();
ScrollController _scrollController = useScrollController();
AsyncValue<SharedAlbum> _albumInfo = ref.watch(sharedAlbumDetailProvider(albumId));
ScrollController scrollController = useScrollController();
AsyncValue<SharedAlbum> albumInfo =
ref.watch(sharedAlbumDetailProvider(albumId));
final userId = ref.watch(authenticationProvider).userId;
@@ -44,16 +45,16 @@ class AlbumViewerPage extends HookConsumerWidget {
ref.watch(assetSelectionProvider.notifier).setIsAlbumExist(true);
AssetSelectionPageResult? returnPayload =
await AutoRouter.of(context).push<AssetSelectionPageResult?>(const AssetSelectionRoute());
AssetSelectionPageResult? returnPayload = await AutoRouter.of(context)
.push<AssetSelectionPageResult?>(const AssetSelectionRoute());
if (returnPayload != null) {
// Check if there is new assets add
if (returnPayload.selectedAdditionalAsset.isNotEmpty) {
ImmichLoadingOverlayController.appLoader.show();
var isSuccess =
await SharedAlbumService().addAdditionalAssetToAlbum(returnPayload.selectedAdditionalAsset, albumId);
var isSuccess = await SharedAlbumService().addAdditionalAssetToAlbum(
returnPayload.selectedAdditionalAsset, albumId);
if (isSuccess) {
ref.refresh(sharedAlbumDetailProvider(albumId));
@@ -69,13 +70,15 @@ class AlbumViewerPage extends HookConsumerWidget {
}
void _onAddUsersPressed(SharedAlbum albumInfo) async {
List<String>? sharedUserIds =
await AutoRouter.of(context).push<List<String>?>(SelectAdditionalUserForSharingRoute(albumInfo: albumInfo));
List<String>? sharedUserIds = await AutoRouter.of(context)
.push<List<String>?>(
SelectAdditionalUserForSharingRoute(albumInfo: albumInfo));
if (sharedUserIds != null) {
ImmichLoadingOverlayController.appLoader.show();
var isSuccess = await SharedAlbumService().addAdditionalUserToAlbum(sharedUserIds, albumId);
var isSuccess = await SharedAlbumService()
.addAdditionalUserToAlbum(sharedUserIds, albumId);
if (isSuccess) {
ref.refresh(sharedAlbumDetailProvider(albumId));
@@ -95,7 +98,9 @@ class AlbumViewerPage extends HookConsumerWidget {
)
: Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text(albumInfo.albumName, style: const TextStyle(fontSize: 24, fontWeight: FontWeight.bold)),
child: Text(albumInfo.albumName,
style: const TextStyle(
fontSize: 24, fontWeight: FontWeight.bold)),
),
);
}
@@ -103,8 +108,10 @@ class AlbumViewerPage extends HookConsumerWidget {
Widget _buildAlbumDateRange(SharedAlbum albumInfo) {
if (albumInfo.assets != null && albumInfo.assets!.isNotEmpty) {
String startDate = "";
DateTime parsedStartDate = DateTime.parse(albumInfo.assets!.first.createdAt);
DateTime parsedEndDate = DateTime.parse(albumInfo.assets!.last.createdAt);
DateTime parsedStartDate =
DateTime.parse(albumInfo.assets!.first.createdAt);
DateTime parsedEndDate =
DateTime.parse(albumInfo.assets!.last.createdAt);
if (parsedStartDate.year == parsedEndDate.year) {
startDate = DateFormat('LLL d').format(parsedStartDate);
@@ -118,7 +125,8 @@ class AlbumViewerPage extends HookConsumerWidget {
padding: const EdgeInsets.only(left: 16.0, top: 8),
child: Text(
"$startDate-$endDate",
style: const TextStyle(fontSize: 14, fontWeight: FontWeight.bold, color: Colors.grey),
style: const TextStyle(
fontSize: 14, fontWeight: FontWeight.bold, color: Colors.grey),
),
);
} else {
@@ -147,8 +155,9 @@ class AlbumViewerPage extends HookConsumerWidget {
child: Padding(
padding: const EdgeInsets.all(2.0),
child: ClipRRect(
child: Image.asset('assets/immich-logo-no-outline.png'),
borderRadius: BorderRadius.circular(50.0),
child:
Image.asset('assets/immich-logo-no-outline.png'),
),
),
),
@@ -217,10 +226,10 @@ class AlbumViewerPage extends HookConsumerWidget {
},
child: DraggableScrollbar.semicircle(
backgroundColor: Theme.of(context).primaryColor,
controller: _scrollController,
controller: scrollController,
heightScrollThumb: 48.0,
child: CustomScrollView(
controller: _scrollController,
controller: scrollController,
slivers: [
_buildHeader(albumInfo),
SliverPersistentHeader(
@@ -242,8 +251,9 @@ class AlbumViewerPage extends HookConsumerWidget {
}
return Scaffold(
appBar: AlbumViewerAppbar(albumInfo: _albumInfo, userId: userId, albumId: albumId),
body: _albumInfo.when(
appBar: AlbumViewerAppbar(
albumInfo: albumInfo, userId: userId, albumId: albumId),
body: albumInfo.when(
data: (albumInfo) => _buildBody(albumInfo),
error: (e, _) => Center(child: Text("Error loading album info $e")),
loading: () => const Center(

View File

@@ -13,13 +13,15 @@ class AssetSelectionPage extends HookConsumerWidget {
const AssetSelectionPage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context, WidgetRef ref) {
ScrollController _scrollController = useScrollController();
ScrollController scrollController = useScrollController();
var assetGroupMonthYear = ref.watch(assetGroupByMonthYearProvider);
final selectedAssets = ref.watch(assetSelectionProvider).selectedNewAssetsForAlbum;
final newAssetsForAlbum = ref.watch(assetSelectionProvider).selectedAdditionalAssetsForAlbum;
final selectedAssets =
ref.watch(assetSelectionProvider).selectedNewAssetsForAlbum;
final newAssetsForAlbum =
ref.watch(assetSelectionProvider).selectedAdditionalAssetsForAlbum;
final isAlbumExist = ref.watch(assetSelectionProvider).isAlbumExist;
List<Widget> _imageGridGroup = [];
List<Widget> imageGridGroup = [];
String _buildAssetCountText() {
if (isAlbumExist) {
@@ -31,19 +33,20 @@ class AssetSelectionPage extends HookConsumerWidget {
Widget _buildBody() {
assetGroupMonthYear.forEach((monthYear, assetGroup) {
_imageGridGroup.add(MonthGroupTitle(month: monthYear, assetGroup: assetGroup));
_imageGridGroup.add(AssetGridByMonth(assetGroup: assetGroup));
imageGridGroup
.add(MonthGroupTitle(month: monthYear, assetGroup: assetGroup));
imageGridGroup.add(AssetGridByMonth(assetGroup: assetGroup));
});
return Stack(
children: [
DraggableScrollbar.semicircle(
backgroundColor: Theme.of(context).primaryColor,
controller: _scrollController,
controller: scrollController,
heightScrollThumb: 48.0,
child: CustomScrollView(
controller: _scrollController,
slivers: [..._imageGridGroup],
controller: scrollController,
slivers: [...imageGridGroup],
),
),
],
@@ -71,7 +74,8 @@ class AssetSelectionPage extends HookConsumerWidget {
),
centerTitle: false,
actions: [
(!isAlbumExist && selectedAssets.isNotEmpty) || (isAlbumExist && newAssetsForAlbum.isNotEmpty)
(!isAlbumExist && selectedAssets.isNotEmpty) ||
(isAlbumExist && newAssetsForAlbum.isNotEmpty)
? TextButton(
onPressed: () {
var payload = AssetSelectionPageResult(

View File

@@ -15,11 +15,13 @@ class CreateSharedAlbumPage extends HookConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final albumTitleController = useTextEditingController.fromValue(TextEditingValue.empty);
final albumTitleController =
useTextEditingController.fromValue(TextEditingValue.empty);
final albumTitleTextFieldFocusNode = useFocusNode();
final isAlbumTitleTextFieldFocus = useState(false);
final isAlbumTitleEmpty = useState(true);
final selectedAssets = ref.watch(assetSelectionProvider).selectedNewAssetsForAlbum;
final selectedAssets =
ref.watch(assetSelectionProvider).selectedNewAssetsForAlbum;
_showSelectUserPage() {
AutoRouter.of(context).push(const SelectUserForSharingRoute());
@@ -38,8 +40,8 @@ class CreateSharedAlbumPage extends HookConsumerWidget {
_onSelectPhotosButtonPressed() async {
ref.watch(assetSelectionProvider.notifier).setIsAlbumExist(false);
AssetSelectionPageResult? selectedAsset =
await AutoRouter.of(context).push<AssetSelectionPageResult?>(const AssetSelectionRoute());
AssetSelectionPageResult? selectedAsset = await AutoRouter.of(context)
.push<AssetSelectionPageResult?>(const AssetSelectionRoute());
if (selectedAsset == null) {
ref.watch(assetSelectionProvider.notifier).removeAll();
@@ -84,16 +86,22 @@ class CreateSharedAlbumPage extends HookConsumerWidget {
child: OutlinedButton.icon(
style: OutlinedButton.styleFrom(
alignment: Alignment.centerLeft,
padding: const EdgeInsets.symmetric(vertical: 22, horizontal: 16),
side: const BorderSide(color: Color.fromARGB(255, 206, 206, 206)),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5))),
padding:
const EdgeInsets.symmetric(vertical: 22, horizontal: 16),
side: const BorderSide(
color: Color.fromARGB(255, 206, 206, 206)),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5))),
onPressed: _onSelectPhotosButtonPressed,
icon: const Icon(Icons.add_rounded),
label: Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text(
'Select Photos',
style: TextStyle(fontSize: 16, color: Colors.grey[700], fontWeight: FontWeight.bold),
style: TextStyle(
fontSize: 16,
color: Colors.grey[700],
fontWeight: FontWeight.bold),
),
),
),
@@ -141,7 +149,8 @@ class CreateSharedAlbumPage extends HookConsumerWidget {
(BuildContext context, int index) {
return GestureDetector(
onTap: _onBackgroundTapped,
child: SharedAlbumThumbnailImage(asset: selectedAssets.toList()[index]),
child: SharedAlbumThumbnailImage(
asset: selectedAssets.toList()[index]),
);
},
childCount: selectedAssets.length,
@@ -169,7 +178,9 @@ class CreateSharedAlbumPage extends HookConsumerWidget {
),
actions: [
TextButton(
onPressed: albumTitleController.text.isNotEmpty ? _showSelectUserPage : null,
onPressed: albumTitleController.text.isNotEmpty
? _showSelectUserPage
: null,
child: const Text(
'Share',
style: TextStyle(
@@ -189,13 +200,13 @@ class CreateSharedAlbumPage extends HookConsumerWidget {
pinned: true,
floating: false,
bottom: PreferredSize(
preferredSize: const Size.fromHeight(66.0),
child: Column(
children: [
_buildTitleInputField(),
_buildControlButton(),
],
),
preferredSize: const Size.fromHeight(66.0),
),
),
_buildTitle(),