feat: 新增 AppLoadingIndicator 和 AppPressable 组件
- 新增 AppLoadingIndicator 加载指示器组件 - 新增 AppPressable 按压反馈组件 - 新增 AppSheetInputField 输入框组件 - 更新 AppButton 和其他共享组件
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../core/theme/design_tokens.dart';
|
||||
|
||||
class AppPressable extends StatefulWidget {
|
||||
const AppPressable({
|
||||
super.key,
|
||||
required this.child,
|
||||
this.onTap,
|
||||
this.borderRadius,
|
||||
this.pressedScale = 0.97,
|
||||
});
|
||||
|
||||
final Widget child;
|
||||
final VoidCallback? onTap;
|
||||
final BorderRadius? borderRadius;
|
||||
final double pressedScale;
|
||||
|
||||
@override
|
||||
State<AppPressable> createState() => _AppPressableState();
|
||||
}
|
||||
|
||||
class _AppPressableState extends State<AppPressable> {
|
||||
bool _isPressed = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AnimatedScale(
|
||||
scale: _isPressed ? widget.pressedScale : 1,
|
||||
duration: const Duration(milliseconds: 110),
|
||||
curve: Curves.easeOut,
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
borderRadius: widget.borderRadius,
|
||||
onTap: widget.onTap,
|
||||
onHighlightChanged: (pressed) {
|
||||
if (_isPressed == pressed) {
|
||||
return;
|
||||
}
|
||||
setState(() {
|
||||
_isPressed = pressed;
|
||||
});
|
||||
},
|
||||
splashColor: AppColors.blue100.withValues(alpha: 0.32),
|
||||
highlightColor: AppColors.blue50.withValues(alpha: 0.28),
|
||||
child: widget.child,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user