Today 요약
[✅] 프로그래머스 코딩테스트 2문제
[✅] flutter 코드챌린지
[✅] flutter 강의 1개
배운 점
1. js array reduce
array.reduce((a,v)=> a+v);
- a는 누적값, v는 배열의 각 요소
- array 모든 배열의 요소를 더해 하나의 값을 반환
- array = [1,2,3,4,5] 이면 1+2+3+4+5 가 되어 15 반환
2. flutter GestureDetector
GestureDetector class - widgets library - Dart API
A widget that detects gestures. Attempts to recognize gestures that correspond to its non-null callbacks. If this widget has a child, it defers to that child for its sizing behavior. If it does not have a child, it grows to fit the parent instead. By defau
api.flutter.dev
- onTapDown : 기본 버튼으로 탭을 누르고 있는 것
- onTapUp : 기본 버튼 탭을 누르다 뗀 것
- onTap : 기본 버튼 탭 클릭
2-1 onTapDawn과 onLongPressDown 차이
onTapDawn
- 사용자가 화면에서 손가락을 터치 다운했을 때 호출
- 이벤트는 사용자가 손가락을 화면에 누르는 순간 발생한다
- 일반적으로 사용자가 화면을 누르는 순간 반응해야 하는 상호작용 요소에 사용, 버튼 누르거나, 드래그 시작, 특정 지점에 대한 터치를 감지
onLongPressDown
- 사용자가 화면에서 손가락을 길게 누른 경우 호출
- 일정시간동안 화면을 길게 누르고 있는 동안에만 발생, 시간은 플랫폼 및 기본 설정에 따라 다를 수 있다. 길게 누르는 것이 감지될 때 호출
- 길게 누르고 있는 동안 어떤 동작을 수행할 때 사용, 길게 눌러 메뉴를 열거나, 길게 누른 동안 특정 동작 시 유용
3. flutter 동영상 버튼 애니메이션 (촬영 버튼 꾹 누르고 있는 상태)
3-1 촬영 버튼
Container(
width:80,
height:80,
decoration:BoxDecoration(
shape : BoxShape.circle,
color:Colors.orange,
)
)
3-2 클릭시 버튼 크기 변경 애니메이션
GestureDetector(
onTapDowwn : _onTapDown,
onTapUp: _onTapUp,
child : ScaleTransition (
scale : _buttonAnimation
child : Container(
width:80,
height:80,
decoration:BoxDecoration(
shape : BoxShape.circle,
color:Colors.orange,
)
)
),
)
late final AnimationController _animationController =
AnimationController(
vsync: this,
duration: const Duration(
milliseconds: 150,
),
);
late final Animation<double> _buttonAnimation =
Tween(begin: 1.0, end: 1.5).animate(_animationController);
void _onTapDown (TapDownDetails _) {
_animationController.forwword();
}
void _onTapUp (TapUpDetails _) {
_animationController.reverse();
}
3-3 동영상 총 길이 10초로 지정하고 얼마나 찍었는지 테두리 라운드? 애니메이션
late final AnimationController _buttonAnimationController =
AnimationController(
vsync: this,
duration: const Duration(
milliseconds: 150,
),
);
late final Animation<double> _buttonAnimation =
Tween(begin: 1.0, end: 1.3).animate(_buttonAnimationController);
late final AnimationController _progressAnimationController =
AnimationController(
vsync: this,
duration: const Duration(
seconds: 10,
),
lowerBound: 0.0,
upperBound: 1.0,
);
@override
void initState() {
super.initState();
initPermissions();
_progressAnimationController.addListener(() {
setState(() {});
});
_progressAnimationController.addStatusListener((status) {
if (status == AnimationStatus.completed) {
_stopRecording();
}
}); // 애니메이션이 끝난 것을 알려줌
}
void _startRecording(TapDownDetails _) {
_buttonAnimationController.forward();
_progressAnimationController.forward();
}
void _stopRecording() {
_buttonAnimationController.reverse();
_progressAnimationController.reset();
}
GestureDetector(
onTapDown: _startRecording,
onTapUp: (details) => _stopRecording(),
child: ScaleTransition(
scale: _buttonAnimation,
child: Stack(
alignment: Alignment.center,
children: [
SizedBox(
width:100,
height: 100,
child: CircularProgressIndicator(
color: Colors.orange,
strokeWidth: 12,
value: _progressAnimationController.value,
),
),
Container(
width: 80,
height:80,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.orange,
),
),
],
),
),
),
야근과 ... 코로나를 핑계로 거의 일주일을 쉬었다
후회스러운 한주 ㅠㅠㅠㅠ
'TIL' 카테고리의 다른 글
20230925 TIL (0) | 2023.09.25 |
---|---|
20230919 TIL (0) | 2023.09.19 |
20230912 TIL :: 아무생각없이 공부만 한 날 (0) | 2023.09.12 |
20230911 TIL : 업보빔 맞는 중 (0) | 2023.09.11 |
20230905 : 오늘도 해낸 나 아주 칭찬 (0) | 2023.09.05 |