Skip to content

Commit d67f06b

Browse files
committed
Ui improvement
1 parent f12fe78 commit d67f06b

10 files changed

+287
-56
lines changed

lib/l10n/app_en.arb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,5 +314,8 @@
314314
"gyroscopeHighLimitHint" : "Please provide the maximum limit of lux value to be recorded (0 rad/s to 1000 rad/s)",
315315
"accelerometerConfigurations" : "Accelerometer Configurations",
316316
"accelerometerUpdatePeriodHint" : "Please provide time interval at which data will be updated",
317-
"accelerometerHighLimitHint" : "Please provide the maximum limit of lux value to be recorded"
317+
"accelerometerHighLimitHint" : "Please provide the maximum limit of lux value to be recorded",
318+
"documentationLink" : "https://docs.pslab.io/",
319+
"documentationError" : "Could not open the documentation link",
320+
"tapToEdit" : "Tap to edit"
318321
}

lib/l10n/app_localizations.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1983,6 +1983,24 @@ abstract class AppLocalizations {
19831983
/// In en, this message translates to:
19841984
/// **'Please provide the maximum limit of lux value to be recorded'**
19851985
String get accelerometerHighLimitHint;
1986+
1987+
/// No description provided for @documentationLink.
1988+
///
1989+
/// In en, this message translates to:
1990+
/// **'https://docs.pslab.io/'**
1991+
String get documentationLink;
1992+
1993+
/// No description provided for @documentationError.
1994+
///
1995+
/// In en, this message translates to:
1996+
/// **'Could not open the documentation link'**
1997+
String get documentationError;
1998+
1999+
/// No description provided for @tapToEdit.
2000+
///
2001+
/// In en, this message translates to:
2002+
/// **'Tap to edit'**
2003+
String get tapToEdit;
19862004
}
19872005

19882006
class _AppLocalizationsDelegate

lib/l10n/app_localizations_en.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,4 +1017,13 @@ class AppLocalizationsEn extends AppLocalizations {
10171017
@override
10181018
String get accelerometerHighLimitHint =>
10191019
'Please provide the maximum limit of lux value to be recorded';
1020+
1021+
@override
1022+
String get documentationLink => 'https://docs.pslab.io/';
1023+
1024+
@override
1025+
String get documentationError => 'Could not open the documentation link';
1026+
1027+
@override
1028+
String get tapToEdit => 'Tap to edit';
10201029
}

lib/providers/robotic_arm_state_provider.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ class RoboticArmStateProvider extends ChangeNotifier {
4545
VoidCallback? onPlaybackEnd;
4646

4747
RoboticArmStateProvider() {
48-
_initTimelineDegrees();
4948
_selectedFrequency = appLocalizations.frequency50Hz;
5049
_selectedMaxAngle = appLocalizations.angle180;
5150
_selectedDuration = appLocalizations.duration1Min;
51+
_initTimelineDegrees();
5252
}
5353

5454
void _initTimelineDegrees() {

lib/view/faq_screen.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class FAQScreen extends StatelessWidget {
124124
child: Row(
125125
children: [
126126
const SizedBox(
127-
width: 25,
127+
width: 15,
128128
),
129129
Text(
130130
faq.linkText!,

lib/view/robotic_arm_screen.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class _RoboticArmScreenState extends State<RoboticArmScreen> {
8383
final screenWidth = MediaQuery.of(context).size.width;
8484
final scrollAmount = (screenWidth / 6);
8585
return CommonScaffold(
86-
title: appLocalizations.roboticArm,
86+
title: appLocalizations.roboticArmTitle,
8787
actions: [
8888
IconButton(
8989
icon: Icon(

lib/view/widgets/navigation_drawer.dart

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,15 @@ class _NavDrawerState extends State<NavDrawer> {
253253
fontSize: 14,
254254
),
255255
),
256-
onTap: () {
257-
/**/
256+
onTap: () async {
257+
final launched = await launchUrl(
258+
Uri.parse(appLocalizations.documentationLink));
259+
if (!launched && context.mounted) {
260+
ScaffoldMessenger.of(context).showSnackBar(
261+
SnackBar(
262+
content: Text(appLocalizations.documentationError)),
263+
);
264+
}
258265
},
259266
),
260267
ListTile(

lib/view/widgets/servo_card.dart

Lines changed: 63 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import 'package:flutter/material.dart';
22
import 'package:provider/provider.dart';
3-
import 'package:pslab/theme/colors.dart';
4-
import 'package:sleek_circular_slider/sleek_circular_slider.dart';
5-
3+
import 'package:pslab/view/widgets/servo_slider.dart';
4+
import '../../l10n/app_localizations.dart';
5+
import '../../providers/locator.dart';
66
import '../../providers/robotic_arm_state_provider.dart';
77

8-
class ServoCard extends StatelessWidget {
8+
class ServoCard extends StatefulWidget {
99
final double value;
1010
final Function(double) onChanged;
1111
final VoidCallback onTap;
@@ -23,12 +23,26 @@ class ServoCard extends StatelessWidget {
2323
required this.cardHeight,
2424
});
2525

26+
@override
27+
State<ServoCard> createState() => _ServoCardState();
28+
}
29+
30+
class _ServoCardState extends State<ServoCard> {
31+
late double currentValue;
32+
33+
@override
34+
void initState() {
35+
super.initState();
36+
currentValue = widget.value;
37+
}
38+
2639
@override
2740
Widget build(BuildContext context) {
2841
final provider = Provider.of<RoboticArmStateProvider>(context);
29-
final sliderSize =
30-
provider.maxAngle == 180 ? cardHeight * 0.95 : cardHeight * 0.72;
31-
42+
final sliderSize = provider.maxAngle == 180
43+
? widget.cardHeight * 0.95
44+
: widget.cardHeight * 0.85;
45+
AppLocalizations appLocalizations = getIt.get<AppLocalizations>();
3246
return Container(
3347
decoration: BoxDecoration(
3448
color: Colors.white,
@@ -41,7 +55,7 @@ class ServoCard extends StatelessWidget {
4155
top: 0,
4256
left: 2,
4357
child: Text(
44-
label,
58+
widget.label,
4559
style: const TextStyle(
4660
fontSize: 10,
4761
fontWeight: FontWeight.w500,
@@ -54,19 +68,19 @@ class ServoCard extends StatelessWidget {
5468
right: 0,
5569
child: Draggable<Map<String, dynamic>>(
5670
data: {
57-
'servoId': servoId,
58-
'degree': value,
71+
'servoId': widget.servoId,
72+
'degree': provider.maxAngle == 180
73+
? widget.value.clamp(0, 180).round()
74+
: widget.value.clamp(0, 360).round(),
5975
},
6076
feedback: Material(
6177
color: Colors.transparent,
6278
child: Container(
6379
padding:
6480
const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
65-
decoration: BoxDecoration(
66-
color: Colors.black,
67-
),
81+
decoration: const BoxDecoration(color: Colors.black),
6882
child: Text(
69-
'${value.floor()} °',
83+
'${provider.maxAngle == 180 ? widget.value.clamp(0, 180).round() : widget.value.clamp(0, 360).round()} ',
7084
style: const TextStyle(
7185
color: Colors.white,
7286
fontSize: 24,
@@ -84,44 +98,44 @@ class ServoCard extends StatelessWidget {
8498
Positioned.fill(
8599
top: provider.maxAngle == 180 ? 25 : 0,
86100
child: GestureDetector(
87-
onTap: onTap,
101+
onTap: widget.onTap,
88102
child: Center(
89-
child: SleekCircularSlider(
90-
initialValue: value.clamp(0, provider.maxAngle.toDouble()),
91-
key: ValueKey(provider.maxAngle),
92-
min: 0,
93-
max: provider.maxAngle.toDouble(),
94-
onChange: onChanged,
95-
appearance: CircularSliderAppearance(
96-
size: sliderSize,
97-
startAngle: provider.maxAngle == 180 ? 180 : 270,
98-
angleRange: provider.maxAngle.toDouble(),
99-
customWidths: CustomSliderWidths(
100-
trackWidth: 8,
101-
progressBarWidth: 8,
102-
handlerSize: 14,
103-
),
104-
customColors: CustomSliderColors(
105-
trackColor: Colors.grey.shade300,
106-
progressBarColor: primaryRed,
107-
dotColor: Colors.black38,
108-
),
109-
infoProperties: InfoProperties(
110-
mainLabelStyle: TextStyle(
111-
fontSize: 22,
112-
color: Colors.black,
113-
fontWeight: FontWeight.normal,
114-
shadows: [
115-
Shadow(
116-
blurRadius: 10,
117-
color: Colors.black.withAlpha((0.3 * 255).round()),
118-
offset: const Offset(0, 0),
103+
child: Stack(
104+
alignment: Alignment.center,
105+
children: [
106+
ServoSlider(
107+
progress: widget.value,
108+
maxProgress: provider.maxAngle.toDouble(),
109+
size: sliderSize,
110+
trackWidth: 5,
111+
thumbRadius: 9,
112+
sweepAngle: provider.maxAngle.toDouble(),
113+
startAngle:
114+
provider.maxAngle.toDouble() == 180 ? 180 : 270,
115+
clockwise: true,
116+
trackColor: Colors.grey.shade300,
117+
progressColor: Colors.red,
118+
thumbColor: Colors.cyan,
119+
onChanged: widget.onChanged),
120+
Column(
121+
mainAxisSize: MainAxisSize.min,
122+
children: [
123+
Text(
124+
' ${provider.maxAngle == 180 ? widget.value.clamp(0, 180).round() : widget.value.clamp(0, 360).round()}${appLocalizations.degreeSymbol}',
125+
style: TextStyle(
126+
fontSize: 16,
127+
color: Colors.black,
128+
fontWeight: FontWeight.normal,
129+
decoration: TextDecoration.underline,
119130
),
120-
],
121-
),
122-
modifier: (val) => '${val.round()}°',
131+
),
132+
Text(
133+
appLocalizations.tapToEdit,
134+
style: TextStyle(fontSize: 8, color: Colors.grey),
135+
),
136+
],
123137
),
124-
),
138+
],
125139
),
126140
),
127141
),

0 commit comments

Comments
 (0)