Skip to content

Commit 985beb6

Browse files
authored
Merge pull request #60 from Piwigo/Translation/Crowdin
Improved uploaded images quality from 0.8 to 1.0. Fixed appbar title
2 parents 748c2d9 + 897d8d5 commit 985beb6

4 files changed

Lines changed: 52 additions & 51 deletions

File tree

lib/views/CategoryViewPage.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ class _CategoryViewPageState extends State<CategoryViewPage> with SingleTickerPr
426426
List<Media> mediaList = await ImagesPicker.pick(
427427
count: 100,
428428
pickType: PickType.all,
429-
quality: 0.8,
429+
quality: 1.0,
430430
);
431431
print(mediaList[0].path);
432432
if(mediaList.isNotEmpty) {
@@ -454,7 +454,7 @@ class _CategoryViewPageState extends State<CategoryViewPage> with SingleTickerPr
454454
try {
455455
List<Media> mediaList = await ImagesPicker.openCamera(
456456
pickType: PickType.image,
457-
quality: 0.8,
457+
quality: 1.0,
458458
);
459459
print(mediaList[0].path);
460460
if(mediaList.isNotEmpty) {

lib/views/RootCategoryViewPage.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class RootCategoryViewPage extends StatefulWidget {
2323
class _RootCategoryViewPageState extends State<RootCategoryViewPage> with SingleTickerProviderStateMixin {
2424
String _rootCategory;
2525
TextEditingController _searchController = TextEditingController();
26+
ScrollController _scrollController = ScrollController();
2627

2728
@override
2829
void initState() {
@@ -43,8 +44,10 @@ class _RootCategoryViewPageState extends State<RootCategoryViewPage> with Single
4344
return Scaffold(
4445
resizeToAvoidBottomInset: true,
4546
body: NestedScrollView(
47+
controller: _scrollController,
4648
headerSliverBuilder: (context, innerBoxScrolled) => [
4749
AppBarExpandable(
50+
scrollController: _scrollController,
4851
leading: IconButton(
4952
onPressed: () {
5053
Navigator.of(context).push(

lib/views/SettingsViewPage.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class _SettingsPageState extends State<SettingsPage> {
2424
String _thumbnailDerivative;
2525
String _fsDerivative;
2626
double kExpandedHeight = 100.0;
27+
ScrollController _scrollController = ScrollController();
2728

2829
@override
2930
void initState() {
@@ -37,8 +38,10 @@ class _SettingsPageState extends State<SettingsPage> {
3738
ThemeData _theme = Theme.of(context);
3839
return Scaffold(
3940
body: CustomScrollView(
41+
controller: _scrollController,
4042
slivers: <Widget>[
4143
AppBarExpandable(
44+
scrollController: _scrollController,
4245
leading: IconButton(
4346
onPressed: Navigator.of(context).pop,
4447
icon: Icon(Icons.check, color: _theme.iconTheme.color),

lib/views/components/appbars.dart

Lines changed: 44 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,65 @@
11
import 'package:flutter/material.dart';
22

3-
class FlexibleSpaceCustom extends StatelessWidget {
4-
const FlexibleSpaceCustom({Key key, this.title}) : super(key: key);
53

4+
class AppBarExpandable extends StatefulWidget {
5+
const AppBarExpandable({Key key, this.leading, this.title = '', this.actions, this.scrollController}) : super(key: key);
6+
7+
final ScrollController scrollController;
8+
final Widget leading;
69
final String title;
10+
final List<Widget> actions;
711

812
@override
9-
Widget build(BuildContext context) {
10-
var _theme = Theme.of(context);
13+
_AppBarExpandableState createState() => _AppBarExpandableState();
14+
}
1115

12-
return LayoutBuilder(
13-
builder: (BuildContext context, BoxConstraints constraints) {
14-
double percent = (constraints.maxHeight - kToolbarHeight);
15-
double dx = 0;
16+
class _AppBarExpandableState extends State<AppBarExpandable> {
1617

17-
dx = 80 - percent;
18-
if (constraints.maxHeight == 100) {
19-
dx = 0;
20-
}
21-
return Stack(
22-
alignment: Alignment.centerLeft,
23-
children: <Widget>[
24-
Padding(
25-
padding: const EdgeInsets.only(top: kToolbarHeight / 4, left: 0.0),
26-
child: Transform.translate(
27-
child: Text(title,
28-
style: _theme.textTheme.headline1,
29-
),
30-
offset: Offset(
31-
dx, constraints.maxHeight - kToolbarHeight),
32-
),
33-
),
34-
],
35-
);
36-
}
37-
);
18+
19+
@override
20+
initState() {
21+
widget.scrollController.addListener(() => refresh());
22+
super.initState();
3823
}
39-
}
4024

25+
void refresh() {
26+
setState(() {
4127

42-
class AppBarExpandable extends StatelessWidget {
43-
const AppBarExpandable({Key key, this.leading, this.title = '', this.actions}) : super(key: key);
28+
});
29+
}
4430

45-
final Widget leading;
46-
final String title;
47-
final List<Widget> actions;
31+
double get _horizontalTitlePadding {
32+
const kBasePadding = 15.0;
33+
const kMultiplier = 0.7;
34+
const kExpandedHeight = 120;
35+
36+
if (widget.scrollController.hasClients) {
37+
38+
if (widget.scrollController.offset > (kExpandedHeight - kToolbarHeight)) {
39+
return (kExpandedHeight - kToolbarHeight) * kMultiplier +
40+
kBasePadding;
41+
}
42+
43+
return (widget.scrollController.offset) * kMultiplier + kBasePadding;
44+
}
45+
46+
return kBasePadding;
47+
}
4848

4949
@override
5050
Widget build(BuildContext context) {
51-
var _theme = Theme.of(context);
52-
5351
return SliverAppBar(
5452
pinned: true,
55-
snap: false,
56-
floating: false,
57-
expandedHeight: 100.0,
58-
centerTitle: true,
59-
backgroundColor: _theme.appBarTheme.backgroundColor,
60-
leading: leading ?? IconButton(
61-
onPressed: () {
62-
Navigator.of(context).pop();
63-
},
64-
icon: Icon(Icons.chevron_left, color: _theme.iconTheme.color),
53+
expandedHeight: 120,
54+
backgroundColor: Theme.of(context).appBarTheme.backgroundColor,
55+
leading: widget.leading ?? SizedBox(),
56+
actions: widget.actions ?? [],
57+
flexibleSpace: FlexibleSpaceBar(
58+
title: Text(widget.title),
59+
titlePadding: EdgeInsets.symmetric(
60+
vertical: 16.0, horizontal: _horizontalTitlePadding,
61+
),
6562
),
66-
flexibleSpace: FlexibleSpaceCustom(title: title),
67-
actions: actions ?? [],
6863
);
6964
}
7065
}

0 commit comments

Comments
 (0)