Skip to content

Commit

Permalink
pull to refresh 애니메이션 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
devunt committed Jul 11, 2024
1 parent ed78945 commit a082e8e
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions apps/mobile/lib/components/pull_to_refresh.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:assorted_layout_widgets/assorted_layout_widgets.dart';
import 'package:custom_refresh_indicator/custom_refresh_indicator.dart';
import 'package:flutter/material.dart';
import 'package:glyph/themes/colors.dart';
import 'package:flutter/cupertino.dart';

class PullToRefresh extends StatelessWidget {
const PullToRefresh({
Expand All @@ -21,31 +21,32 @@ class PullToRefresh extends StatelessWidget {
Future.delayed(const Duration(seconds: 1)),
]);
},
offsetToArmed: 60,
triggerMode: IndicatorTriggerMode.anywhere,
// ignore: deprecated_member_use
indicatorFinalizeDuration: const Duration(milliseconds: 200),
child: child,
builder: (context, child, controller) {
return Stack(
children: [
child,
Positioned(
top: 0,
left: 0,
right: 0,
child: AnimatedBuilder(
animation: controller,
builder: (context, child) {
return Opacity(
opacity: controller.value.clamp(0, 1),
child: LinearProgressIndicator(
value: controller.isDragging || controller.isArmed ? controller.value.clamp(0, 1) : null,
backgroundColor: BrandColors.gray_150,
color: BrandColors.gray_900,
),
);
},
child: Container(
width: double.infinity,
height: controller.value * 60,
clipBehavior: Clip.hardEdge,
alignment: Alignment.bottomCenter,
padding: const Pad(bottom: 20),
decoration: const BoxDecoration(),
child: FadeTransition(
opacity: controller.clamp(0, 1),
child: const CupertinoActivityIndicator(),
),
),
),
Transform.translate(offset: Offset(0, controller.value * 60), child: child),
],
);
},
Expand Down Expand Up @@ -94,7 +95,7 @@ class PullToRefreshListView extends StatelessWidget {
child: itemCount == 0
? SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(
parent: BouncingScrollPhysics(),
parent: ClampingScrollPhysics(),
),
child: SizedBox(
height: constraints.maxHeight,
Expand All @@ -103,7 +104,7 @@ class PullToRefreshListView extends StatelessWidget {
)
: ListView.separated(
physics: const AlwaysScrollableScrollPhysics(
parent: BouncingScrollPhysics(),
parent: ClampingScrollPhysics(),
),
itemCount: itemCount,
itemBuilder: itemBuilder,
Expand Down

0 comments on commit a082e8e

Please sign in to comment.