opt: image view

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-01-15 18:45:58 +08:00
parent dff4d27736
commit 12e299a5d8
10 changed files with 44 additions and 47 deletions

View File

@@ -1,5 +1,6 @@
import 'dart:math';
import 'package:PiliPlus/common/constants.dart';
import 'package:PiliPlus/common/widgets/badge.dart';
import 'package:PiliPlus/common/widgets/network_img_layer.dart';
import 'package:PiliPlus/common/widgets/nine_grid_view.dart';
@@ -49,7 +50,7 @@ Widget imageview(
}
BorderRadius borderRadius(index) {
if (picArr.length == 1) {
return BorderRadius.circular(12);
return StyleString.mdRadius;
}
final int row = picArr.length == 4 ? 2 : 3;
return BorderRadius.only(
@@ -57,27 +58,27 @@ Widget imageview(
(index - row >= 0 ||
((index - 1) >= 0 && (index - 1) % row < index % row))
? 0
: 12,
: 10,
),
topRight: Radius.circular(
(index - row >= 0 ||
((index + 1) < picArr.length &&
(index + 1) % row > index % row))
? 0
: 12,
: 10,
),
bottomLeft: Radius.circular(
(index + row < picArr.length ||
((index - 1) >= 0 && (index - 1) % row < index % row))
? 0
: 12,
: 10,
),
bottomRight: Radius.circular(
(index + row < picArr.length ||
((index + 1) < picArr.length &&
(index + 1) % row > index % row))
? 0
: 12,
: 10,
),
);
}

View File

@@ -41,20 +41,17 @@ class NetworkImgLayer extends StatelessWidget {
@override
Widget build(BuildContext context) {
double radius = this.radius != null
? this.radius!
: type == 'avatar'
? 50
: type == 'emote'
? 0
: StyleString.imgRadius.x;
return src.isNullOrEmpty.not
? radius != 0
? ClipRRect(
borderRadius: BorderRadius.circular(radius),
child: _buildImage(context),
)
: _buildImage(context)
? type == 'avatar'
? ClipOval(child: _buildImage(context))
: radius == 0 || type == 'emote'
? _buildImage(context)
: ClipRRect(
borderRadius: BorderRadius.circular(
radius ?? StyleString.imgRadius.x,
),
child: _buildImage(context),
)
: getPlaceHolder?.call() ?? placeholder(context);
}
@@ -99,15 +96,15 @@ class NetworkImgLayer extends StatelessWidget {
return Container(
width: width,
height: height,
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
shape: type == 'avatar' ? BoxShape.circle : BoxShape.rectangle,
color: Theme.of(context).colorScheme.onInverseSurface.withOpacity(0.4),
borderRadius: BorderRadius.circular(
type == 'avatar'
? 50
: type == 'emote'
? 0
: StyleString.imgRadius.x,
),
borderRadius: type == 'avatar' || type == 'emote' || radius == 0
? null
: BorderRadius.circular(
radius ?? StyleString.imgRadius.x,
),
),
child: type == 'bg'
? const SizedBox()