Animation was updated, button does work now
This commit is contained in:
parent
b1e49ee70d
commit
6a615f8234
|
@ -44,9 +44,10 @@ class FetchResults{
|
||||||
List<TetraLeague> states;
|
List<TetraLeague> states;
|
||||||
Summaries? summaries;
|
Summaries? summaries;
|
||||||
Cutoffs? cutoffs;
|
Cutoffs? cutoffs;
|
||||||
|
bool isTracked;
|
||||||
Exception? exception;
|
Exception? exception;
|
||||||
|
|
||||||
FetchResults(this.success, this.player, this.states, this.summaries, this.cutoffs, this.exception);
|
FetchResults(this.success, this.player, this.states, this.summaries, this.cutoffs, this.isTracked, this.exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
class RecordSummary extends StatelessWidget{
|
class RecordSummary extends StatelessWidget{
|
||||||
|
@ -1006,7 +1007,7 @@ class _DestinationHomeState extends State<DestinationHome> with SingleTickerProv
|
||||||
width: 450,
|
width: 450,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
NewUserThingy(player: snapshot.data!.player!, showStateTimestamp: false, setState: setState),
|
NewUserThingy(player: snapshot.data!.player!, initIsTracking: snapshot.data!.isTracked, showStateTimestamp: false, setState: setState),
|
||||||
if (snapshot.data!.player!.badges.isNotEmpty) BadgesThingy(badges: snapshot.data!.player!.badges),
|
if (snapshot.data!.player!.badges.isNotEmpty) BadgesThingy(badges: snapshot.data!.player!.badges),
|
||||||
if (snapshot.data!.player!.distinguishment != null) DistinguishmentThingy(snapshot.data!.player!.distinguishment!),
|
if (snapshot.data!.player!.distinguishment != null) DistinguishmentThingy(snapshot.data!.player!.distinguishment!),
|
||||||
if (snapshot.data!.player!.role == "bot") FakeDistinguishmentThingy(bot: true, botMaintainers: snapshot.data!.player!.botmaster),
|
if (snapshot.data!.player!.role == "bot") FakeDistinguishmentThingy(bot: true, botMaintainers: snapshot.data!.player!.botmaster),
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
import 'dart:math';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart' hide Badge;
|
import 'package:flutter/material.dart' hide Badge;
|
||||||
|
@ -45,6 +46,7 @@ import 'package:tetra_stats/main.dart';
|
||||||
import 'package:tetra_stats/widgets/tl_progress_bar.dart';
|
import 'package:tetra_stats/widgets/tl_progress_bar.dart';
|
||||||
import 'package:tetra_stats/widgets/user_thingy.dart';
|
import 'package:tetra_stats/widgets/user_thingy.dart';
|
||||||
import 'package:transparent_image/transparent_image.dart';
|
import 'package:transparent_image/transparent_image.dart';
|
||||||
|
import 'package:vector_math/vector_math_64.dart' hide Colors;
|
||||||
|
|
||||||
// TODO: Refactor it
|
// TODO: Refactor it
|
||||||
|
|
||||||
|
@ -61,7 +63,7 @@ Future<FetchResults> getData(String searchFor) async {
|
||||||
player = await teto.fetchPlayer(searchFor); // Otherwise it's probably a user id or username
|
player = await teto.fetchPlayer(searchFor); // Otherwise it's probably a user id or username
|
||||||
}
|
}
|
||||||
}on TetrioPlayerNotExist{
|
}on TetrioPlayerNotExist{
|
||||||
return FetchResults(false, null, [], null, null, TetrioPlayerNotExist());
|
return FetchResults(false, null, [], null, null, false, TetrioPlayerNotExist());
|
||||||
}
|
}
|
||||||
late Summaries summaries;
|
late Summaries summaries;
|
||||||
late Cutoffs cutoffs;
|
late Cutoffs cutoffs;
|
||||||
|
@ -78,7 +80,7 @@ Future<FetchResults> getData(String searchFor) async {
|
||||||
await teto.storeState(summaries.league);
|
await teto.storeState(summaries.league);
|
||||||
}
|
}
|
||||||
|
|
||||||
return FetchResults(true, player, states, summaries, cutoffs, null);
|
return FetchResults(true, player, states, summaries, cutoffs, isTracking, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
class MainView extends StatefulWidget {
|
class MainView extends StatefulWidget {
|
||||||
|
@ -1095,9 +1097,10 @@ class BadgesThingy extends StatelessWidget{
|
||||||
class NewUserThingy extends StatefulWidget {
|
class NewUserThingy extends StatefulWidget {
|
||||||
final TetrioPlayer player;
|
final TetrioPlayer player;
|
||||||
final bool showStateTimestamp;
|
final bool showStateTimestamp;
|
||||||
|
final bool initIsTracking;
|
||||||
final Function setState;
|
final Function setState;
|
||||||
|
|
||||||
const NewUserThingy({super.key, required this.player, required this.showStateTimestamp, required this.setState});
|
const NewUserThingy({super.key, required this.player, required this.initIsTracking, required this.showStateTimestamp, required this.setState});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<NewUserThingy> createState() => _NewUserThingyState();
|
State<NewUserThingy> createState() => _NewUserThingyState();
|
||||||
|
@ -1110,7 +1113,8 @@ class _NewUserThingyState extends State<NewUserThingy> with SingleTickerProvider
|
||||||
@override
|
@override
|
||||||
void initState(){
|
void initState(){
|
||||||
_addToTrackAnimController = AnimationController(
|
_addToTrackAnimController = AnimationController(
|
||||||
duration: Durations.medium3,
|
value: widget.initIsTracking ? 1.0 : 0.0,
|
||||||
|
duration: Durations.extralong4,
|
||||||
vsync: this,
|
vsync: this,
|
||||||
);
|
);
|
||||||
_addToTrackAnim = new Tween(
|
_addToTrackAnim = new Tween(
|
||||||
|
@ -1118,9 +1122,10 @@ class _NewUserThingyState extends State<NewUserThingy> with SingleTickerProvider
|
||||||
end: 1.0,
|
end: 1.0,
|
||||||
).animate(new CurvedAnimation(
|
).animate(new CurvedAnimation(
|
||||||
parent: _addToTrackAnimController,
|
parent: _addToTrackAnimController,
|
||||||
curve: Easing.standardDecelerate,
|
curve: Cubic(.15,-0.40,.86,-0.39),
|
||||||
reverseCurve: Easing.standardAccelerate
|
reverseCurve: Cubic(0,.99,.99,1.01)
|
||||||
));
|
));
|
||||||
|
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1352,38 +1357,42 @@ class _NewUserThingyState extends State<NewUserThingy> with SingleTickerProvider
|
||||||
child: AnimatedBuilder(
|
child: AnimatedBuilder(
|
||||||
animation: _addToTrackAnim,
|
animation: _addToTrackAnim,
|
||||||
builder: (context, child) {
|
builder: (context, child) {
|
||||||
double firstButtonPosition = 0-(_addToTrackAnim.value as double)*25;
|
double firstButtonPosition = 0+(_addToTrackAnim.value as double)*25;
|
||||||
double secondButtonPosition = 25-(_addToTrackAnim.value as double)*25;
|
double secondButtonPosition = -25+(_addToTrackAnim.value as double)*25;
|
||||||
double firstButtonOpacity = 1-(_addToTrackAnim.value as double)*2;
|
double firstButtonOpacity = 1-(_addToTrackAnim.value as double)*2;
|
||||||
double secondButtonOpacity = _addToTrackAnim.value*2-1;
|
double secondButtonOpacity = _addToTrackAnim.value*2-1;
|
||||||
return ElevatedButton.icon(
|
return ElevatedButton.icon(
|
||||||
onPressed: (){
|
onPressed: (){
|
||||||
|
_addToTrackAnimController.value == 1 ? teto.deletePlayerToTrack(widget.player.userId) : teto.addPlayerToTrack(widget.player);
|
||||||
_addToTrackAnim.isCompleted ? _addToTrackAnimController.reverse() : _addToTrackAnimController.forward();
|
_addToTrackAnim.isCompleted ? _addToTrackAnimController.reverse() : _addToTrackAnimController.forward();
|
||||||
},
|
},
|
||||||
icon: _addToTrackAnim.value < 0.5 ? Container(
|
icon: _addToTrackAnim.value < 0.5 ? Opacity(
|
||||||
transform: Matrix4.translationValues(0, firstButtonPosition, 0),
|
opacity: min(1, firstButtonOpacity),
|
||||||
child: Opacity(
|
child: Transform.translate(
|
||||||
opacity: firstButtonOpacity,
|
offset: Offset(0, _addToTrackAnim.status == AnimationStatus.forward ? firstButtonPosition*4 : firstButtonPosition),
|
||||||
child: const Icon(Icons.person_add)
|
child: Transform.rotate(
|
||||||
)
|
angle:_addToTrackAnim.status == AnimationStatus.forward ? (_addToTrackAnim.value as double)*2 : 0,
|
||||||
|
child: const Icon(Icons.person_add),
|
||||||
|
),
|
||||||
|
),
|
||||||
) : Container(
|
) : Container(
|
||||||
transform: Matrix4.translationValues(0, secondButtonPosition, 0),
|
transform: Matrix4.translationValues(0, secondButtonPosition, 0),
|
||||||
child: Opacity(
|
child: Opacity(
|
||||||
opacity: secondButtonOpacity,
|
opacity: max(0, secondButtonOpacity),
|
||||||
child: const Icon(Icons.person_remove)
|
child: const Icon(Icons.person_remove)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
label: _addToTrackAnim.value < 0.5 ? Container(
|
label: _addToTrackAnim.value < 0.5 ? Container(
|
||||||
transform: Matrix4.translationValues(0, firstButtonPosition, 0),
|
transform: Matrix4.translationValues(0, firstButtonPosition, 0),
|
||||||
child: Opacity(
|
child: Opacity(
|
||||||
opacity: firstButtonOpacity,
|
opacity: min(1, firstButtonOpacity),
|
||||||
child: Text(t.track)
|
child: Text(_addToTrackAnimController.isAnimating && _addToTrackAnim.status == AnimationStatus.forward ? "Done!" : "Track")
|
||||||
)
|
)
|
||||||
) : Container(
|
) : Container(
|
||||||
transform: Matrix4.translationValues(0, secondButtonPosition, 0),
|
transform: Matrix4.translationValues(0, secondButtonPosition, 0),
|
||||||
child: Opacity(
|
child: Opacity(
|
||||||
opacity: secondButtonOpacity,
|
opacity: max(0, secondButtonOpacity),
|
||||||
child: Text(t.stopTracking)
|
child: Text("Stop tracking")
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
style: const ButtonStyle(shape: WidgetStatePropertyAll(RoundedRectangleBorder(borderRadius: BorderRadius.only(bottomLeft: Radius.circular(12.0))))));
|
style: const ButtonStyle(shape: WidgetStatePropertyAll(RoundedRectangleBorder(borderRadius: BorderRadius.only(bottomLeft: Radius.circular(12.0))))));
|
||||||
|
|
Loading…
Reference in New Issue