-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathspeaker.dart
137 lines (129 loc) · 4.74 KB
/
speaker.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import 'package:ecellapp/widgets/ecell_animation.dart';
import 'package:ecellapp/widgets/reload_on_error.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:ecellapp/core/res/colors.dart';
import 'package:ecellapp/core/res/dimens.dart';
import 'package:ecellapp/models/speaker.dart';
import 'package:ecellapp/screens/speaker/cubit/speaker_cubit.dart';
import 'package:ecellapp/screens/speaker/speaker_card.dart';
import 'package:ecellapp/widgets/stateful_wrapper.dart';
import '../../core/res/strings.dart';
class SpeakerScreen extends StatelessWidget {
SpeakerScreen({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return StatefulWrapper(
onInit: () => _getAllSpeakers(context),
child: Scaffold(
extendBodyBehindAppBar: true,
backgroundColor: Colors.transparent,
appBar: AppBar(
elevation: 0,
backgroundColor: Colors.transparent,
leading: Container(
padding: EdgeInsets.only(left: D.horizontalPadding - 10),
child: IconButton(
icon: Icon(Icons.arrow_back_ios, color: Colors.white, size: 30),
onPressed: () => Navigator.of(context).pop(),
),
),
),
body: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [C.backgroundTop, C.backgroundBottom],
),
),
child: BlocBuilder<SpeakerCubit, SpeakerState>(
builder: (context, state) {
if (state is SpeakerInitial)
return _buildLoading(context);
else if (state is SpeakerSuccess)
return _buildSuccess(context, state.speakerList);
else if (state is SpeakerLoading)
return _buildLoading(context);
else
return ReloadOnErrorWidget(() => _getAllSpeakers(context));
},
),
),
),
);
}
Widget _buildSuccess(BuildContext context, List<Speaker> speakerList) {
double top = MediaQuery.of(context).viewInsets.top;
double ratio = MediaQuery.of(context).size.aspectRatio;
double height = MediaQuery.of(context).size.height;
double heightFactor = height / 1000;
double width = MediaQuery.of(context).size.width;
List<Widget> speakerContentList = [];
speakerList.forEach((element) => speakerContentList.add(SpeakerCard(speaker: element)));
return DefaultTextStyle.merge(
style: GoogleFonts.roboto().copyWith(color: C.primaryUnHighlightedColor),
child: NotificationListener<OverscrollIndicatorNotification>(
onNotification: (OverscrollIndicatorNotification overscroll) {
overscroll.disallowIndicator();
return true;
},
child: Stack(
children: [
Padding(
padding:
EdgeInsets.fromLTRB(width * 0.1, height * 0.3, 0.0, 0.0),
child: Container(
height: height * 0.4,
width: width * 0.8,
child: Image.asset(
S.assetEcellLogoWhite,
fit: BoxFit.contain,
opacity: const AlwaysStoppedAnimation<double>(0.5),
),
),
),
Column(
children: <Widget>[
SizedBox(
height: top + 40,
),
Text(
"Speakers",
style: GoogleFonts.raleway(
fontSize: 55*heightFactor,
fontWeight: FontWeight.bold,
color: Colors.white,
letterSpacing: 0.5),
),
Expanded(child: (speakerList.length!=0)?ListView(
padding: EdgeInsets.only(top: 10),
children: speakerContentList,
):Center(
child: Text(
"Will be updated Soon...",
style: GoogleFonts.raleway(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Colors.white,
letterSpacing: 0.5),
),
),
),
],
),
],
),
),
);
}
Widget _buildLoading(BuildContext context) {
double width = MediaQuery.of(context).size.width;
return Center(child: ECellLogoAnimation(size: width / 2));
}
void _getAllSpeakers(BuildContext context) {
final cubit = context.read<SpeakerCubit>();
cubit.getSpeakerList();
}
}