Skip to content

Commit

Permalink
💄 Update webapp's icon size consistence.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexV525 committed Feb 13, 2020
1 parent 00e0261 commit 02b19a4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/pages/post/publish_post_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class PublishPostPageState extends State<PublishPostPage> {
selectionLimitReachedText: '已达到最大张数限制',
),
).catchError((e) {
debugPrint(e.toString());
debugPrint('Error when picking images: $e');
});
if (results != null) resultList = results;
if (_focusNode.canRequestFocus) _focusNode.requestFocus();
Expand Down
1 change: 0 additions & 1 deletion lib/providers/settings_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class SettingsProvider extends ChangeNotifier {
/// For test page.
/// TODO: Set this to false before release.
bool _debug = !kReleaseMode && false;
// bool _debug = true;
bool get debug => _debug;
set debug(bool value) {
_debug = value;
Expand Down
30 changes: 19 additions & 11 deletions lib/widgets/webapp_icon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ class WebAppIcon extends StatelessWidget {
debugPrint('Error when load webapp icon: $e.\nLoading fallback icon...');
return ExtendedImage.network(
oldIconUrl,
width: suSetWidth(size),
height: suSetWidth(size),
width: suSetWidth(oldIconSize),
height: suSetWidth(oldIconSize),
fit: BoxFit.fill,
);
}
}

double get oldIconSize => size / 1.5;

String get iconPath => 'assets/icons/appCenter/${app.code}-${app.name}.svg';

String get oldIconUrl => '${API.webAppIcons}appid=${app.appId}&code=${app.code}';
Expand All @@ -39,20 +41,26 @@ class WebAppIcon extends StatelessWidget {
return Selector<SettingsProvider, bool>(
selector: (_, provider) => provider.newAppCenterIcon,
builder: (_, newAppCenterIcon, __) {
return !(currentUser?.isTeacher ?? false) || newAppCenterIcon
final shouldUseNew = !(currentUser?.isTeacher ?? false) || newAppCenterIcon;
return shouldUseNew
? FutureBuilder(
initialData: SizedBox(),
initialData: SizedBox.shrink(),
future: loadAsset(),
builder: (_, snapshot) => SizedBox(
width: suSetWidth(size),
height: suSetHeight(size),
builder: (_, snapshot) => SizedBox.fromSize(
size: Size.square(suSetWidth(size)),
child: Center(child: snapshot.data),
),
)
: SizedBox(
width: suSetWidth(size / 1.2),
height: suSetHeight(size / 1.2),
child: Center(child: ExtendedImage.network(oldIconUrl, fit: BoxFit.fill)),
: SizedBox.fromSize(
size: Size.square(suSetWidth(size)),
child: Center(
child: ExtendedImage.network(
oldIconUrl,
fit: BoxFit.fill,
width: suSetWidth(oldIconSize),
height: suSetWidth(oldIconSize),
),
),
);
},
);
Expand Down

0 comments on commit 02b19a4

Please sign in to comment.