This also removes commented out code.
Original by Sabin Sajeevan <ssajeevan@ics.com>.
Bug-AGL: SPEC-4971
Change-Id: I31c3b3046f6e3bdd9cc641d403467eda11144f31
Signed-off-by: Lisandro Pérez Meyer <lpmeyer@ics.com>
request.updates.add(update);
Map<String, String> metadata = {};
if (authorization.isNotEmpty) {
- metadata = {'authorization': "Bearer ${authorization}"};
+ metadata = {'authorization': "Bearer $authorization"};
}
await stub.set(request, options: CallOptions(metadata: metadata));
}
Future<KuksaConfig> readConfig() async {
String hostname = KuksaConfig.defaultHostname;
int port = KuksaConfig.defaultPort;
- bool use_tls = false;
- String ca_path = KuksaConfig.defaultCaCertPath;
- List<int> ca_cert = [];
- String tls_server_name = "";
+ bool useTls = false;
+ String caPath = KuksaConfig.defaultCaCertPath;
+ List<int> caCert = [];
+ String tlsServerName = "";
String token = "";
// Read build time configuration from bundle
if (yamlMap.containsKey('use-tls')) {
var value = yamlMap['use-tls'];
- if (value is bool) use_tls = value;
+ if (value is bool) {
+ useTls = value;
+ }
}
- if (use_tls) {
+ if (useTls) {
if (yamlMap.containsKey('ca-certificate')) {
- ca_path = yamlMap['ca-certificate'];
+ caPath = yamlMap['ca-certificate'];
}
if (yamlMap.containsKey('tls-server-name')) {
- tls_server_name = yamlMap['tls_server_name'];
+ tlsServerName = yamlMap['tls_server_name'];
}
}
if (yamlMap.containsKey('use-tls')) {
var value = yamlMap['use-tls'];
- if (value is bool) use_tls = value;
+ if (value is bool) {
+ useTls = value;
+ }
}
//debugPrint("Use TLS = $use_tls");
- if (use_tls) {
+ if (useTls) {
if (yamlMap.containsKey('ca-certificate')) {
- ca_path = yamlMap['ca-certificate'];
+ caPath = yamlMap['ca-certificate'];
}
try {
- ca_cert = File(ca_path).readAsBytesSync();
+ caCert = File(caPath).readAsBytesSync();
} on Exception catch (_) {
- print("ERROR: Could not read CA certificate file $ca_path");
- ca_cert = [];
+ print("ERROR: Could not read CA certificate file $caPath");
+ caCert = [];
}
//debugPrint("CA cert = $ca_cert");
if (yamlMap.containsKey('tls-server-name')) {
- tls_server_name = yamlMap['tls_server_name'];
+ tlsServerName = yamlMap['tls_server_name'];
}
}
hostname: hostname,
port: port,
authorization: token,
- use_tls: use_tls,
- ca_certificate: ca_cert,
- tls_server_name: tls_server_name);
+ use_tls: useTls,
+ ca_certificate: caCert,
+ tls_server_name: tlsServerName);
}
void startListen() async {
ChannelCredentials creds;
if (config.use_tls && config.ca_certificate.isNotEmpty) {
print("Using TLS");
- if (config.tls_server_name.isNotEmpty)
+ if (config.tls_server_name.isNotEmpty) {
creds = ChannelCredentials.secure(
certificates: config.ca_certificate,
authority: config.tls_server_name);
- else
+ } else {
creds = ChannelCredentials.secure(certificates: config.ca_certificate);
+ }
} else {
- creds = ChannelCredentials.insecure();
+ creds = const ChannelCredentials.insecure();
}
channel = ClientChannel(config.hostname,
port: config.port, options: ChannelOptions(credentials: creds));
// .watch(vehicleProvider.select((vehicle) => vehicle.outsideTemperature));
final tempUnit =
ref.watch(unitStateProvider.select((unit) => unit.temperatureUnit));
-
+
TextStyle temperatureTextStyle = const TextStyle(
fontFamily: 'BrunoAce',
- color: Colors.white,
+ color: Colors.white,
fontSize: 44,
);
),
//color: Colors.grey,
shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(65), // Half of the height for an oval effect
+ borderRadius: BorderRadius.circular(
+ 65), // Half of the height for an oval effect
side: const BorderSide(
color: Color.fromARGB(156, 0, 0, 0),
width: 2,
),
);
}
-
- Widget buildTemperatureRow(
+
+ Widget buildTemperatureRow(
BuildContext context,
IconData icon,
String label,
TextStyle tempTextStyle,
TextStyle unitTextStyle,
bool isOutside,
-
) {
- int temperatureAsInt = temperatureValue.toInt();
- double convertedTemperature = tempUnit == TemperatureUnit.celsius
- ? temperatureAsInt.toDouble()
- : (temperatureAsInt * 9 / 5) + 32;
+ int temperatureAsInt = temperatureValue.toInt();
+ double convertedTemperature = tempUnit == TemperatureUnit.celsius
+ ? temperatureAsInt.toDouble()
+ : (temperatureAsInt * 9 / 5) + 32;
- // Format the temperature for display.
- String temperatureDisplay = tempUnit == TemperatureUnit.celsius
- ? '$temperatureAsInt'
- : '${convertedTemperature.toStringAsFixed(0)}';
+ // Format the temperature for display.
+ String temperatureDisplay = tempUnit == TemperatureUnit.celsius
+ ? '$temperatureAsInt'
+ : convertedTemperature.toStringAsFixed(0);
return Padding(
- padding: isOutside
- ? const EdgeInsets.only(right: 22) // Padding for the outside temperature
- : const EdgeInsets.only(left: 12), // Padding for the inside temperature
+ padding: isOutside
+ ? const EdgeInsets.only(
+ right: 22) // Padding for the outside temperature
+ : const EdgeInsets.only(
+ left: 12), // Padding for the inside temperature
child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- Icon(
- icon,
- color: const Color(0xFF2962FF),
- size: 48,
- ),
- const SizedBox(width: 4), // Space between icon and text
- Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisSize: MainAxisSize.min,
- children: [
- Text(
- label,
- style: const TextStyle(
- color: Color(0xFFC1D8FF),
- fontSize: 26,
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Icon(
+ icon,
+ color: const Color(0xFF2962FF),
+ size: 48,
+ ),
+ const SizedBox(width: 4), // Space between icon and text
+ Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Text(
+ label,
+ style: const TextStyle(
+ color: Color(0xFFC1D8FF),
+ fontSize: 26,
+ ),
),
- ),
- RichText(
- text: TextSpan(
- text: temperatureDisplay,
- style: tempTextStyle,
- children: <TextSpan>[
- TextSpan(
- text: tempUnit == TemperatureUnit.celsius ? '°C' : '°F',
- style: unitTextStyle,
- ),
- ],
+ RichText(
+ text: TextSpan(
+ text: temperatureDisplay,
+ style: tempTextStyle,
+ children: <TextSpan>[
+ TextSpan(
+ text: tempUnit == TemperatureUnit.celsius ? '°C' : '°F',
+ style: unitTextStyle,
+ ),
+ ],
+ ),
),
- ),
- ],
- ),
- ],
- ),
+ ],
+ ),
+ ],
+ ),
);
}
-}
\ No newline at end of file
+}
}
class HomeScreenState extends ConsumerState<HomeScreen> {
-
-
-
@override
void initState() {
super.initState();
return Consumer(builder: (context, ref, child) {
final state = ref.read(appProvider);
if (disableBkgAnimation) {
- debugPrint('Background animation: disabled');
+ print('Background animation: disabled');
}
return Scaffold(
key: homeScaffoldKey,
double controlProgress = 0.0;
int selectedFanSpeed = 0;
late rive.RiveAnimationController _controller;
+ bool isButtonHighlighted = false;
bool _isPlaying = false;
Center(
child: Container(
margin: const EdgeInsets.only(top: 3),
- // decoration: BoxDecoration(
- // shape: BoxShape.circle,
- // gradient: LinearGradient(
- // colors: !isMainACSelected
- // ? [
- // AGLDemoColors.neonBlueColor,
- // AGLDemoColors.neonBlueColor.withOpacity(0.2)
- // ]
- // : [
- // const Color.fromARGB(255, 255, 193, 193)
- // .withOpacity(0.2),
- // const Color.fromARGB(255, 255, 193, 193)
- // ]),
- // boxShadow: isMainACSelected
- // ? [
- // BoxShadow(
- // offset: Offset(
- // isMainACSelected ? 1 : 1, isMainACSelected ? 2 : 2),
- // blurRadius: isMainACSelected ? 16 : 16,
- // spreadRadius: 0,
- // color: isMainACSelected
- // ? Colors.black.withOpacity(0.5)
- // : Colors.black)
- // ]
- // : [],
- // ),
- //border: Border.all(color: Colors.white12, width: 1)),
+ decoration: BoxDecoration(
+ shape: BoxShape.circle,
+ gradient: LinearGradient(
+ colors: !isButtonHighlighted
+ ? [
+ AGLDemoColors.neonBlueColor,
+ AGLDemoColors.neonBlueColor.withOpacity(0.2)
+ ]
+ : [
+ AGLDemoColors.resolutionBlueColor,
+ const Color(0xff141F64)
+ ]),
+ boxShadow: isButtonHighlighted
+ ? [
+ BoxShadow(
+ offset: Offset(isButtonHighlighted ? 1 : 1,
+ isButtonHighlighted ? 2 : 2),
+ blurRadius: isButtonHighlighted ? 16 : 16,
+ spreadRadius: 0,
+ color: isButtonHighlighted
+ ? Colors.black.withOpacity(0.5)
+ : Colors.black)
+ ]
+ : [],
+ ),
+ // border: Border.all(color: Colors.white12, width: 1),
//width: 90,
//height: 90,
child: Container(
image: const DecorationImage(
image: AssetImage("assets/PlusVector.png"),
),
- gradient: Gradient.lerp(gradientEnable1, gradientEnable2, 0.5),
- // border: Border.all(
- // color: isMainACSelected
- // ? AGLDemoColors.buttonFillEnabledColor
- // : Colors.white12,
- // width: isMainACSelected ? 3 : 1),
- border: const GradientBoxBorder(
- width: 2,
+ border: GradientBoxBorder(
+ width: 1,
gradient: LinearGradient(
colors: [
- Color(0x30C1D8FF),
- Color(0xFFC1D8FF),
+ isButtonHighlighted
+ ? AGLDemoColors.neonBlueColor
+ : AGLDemoColors.periwinkleColor.withOpacity(0.20),
+ isButtonHighlighted
+ ? AGLDemoColors.neonBlueColor.withOpacity(0.20)
+ : AGLDemoColors.periwinkleColor,
],
),
),
hoverColor: Colors.transparent,
highlightColor: Colors.transparent,
customBorder: const CircleBorder(),
+ onHighlightChanged: (value) {
+ setState(() {
+ isButtonHighlighted = value;
+ });
+ },
onTap: () {
setState(() {
if (controlProgress >= 0.80) {
_isPlaying = false;
animationController.reverse();
} else {
- _isPlaying ? null : _controller.isActive = true;
- isMainACSelected = true;
_controller.isActive = true;
+ isMainACSelected = true;
_isPlaying = true;
controlProgress += 0.30;
animationController.forward();
ref
.read(vehicleProvider.notifier)
.updateFanSpeed(controlProgress ~/ 0.3);
-
- // isMainACSelected = !isMainACSelected;
- // if (controlProgress != 0.0) {
- // previousProgress = controlProgress;
- // }
- // if (isMainACSelected) {
- // controlProgress = previousProgress;
- // animationController.forward();
- // } else {
- // controlProgress = 0.0;
- // animationController.reverse();
- // }
});
},
onTapDown: (details) {
- setState(() {
- gradientEnable1 = LinearGradient(colors: <Color>[
- const Color(0xFF2962FF).withOpacity(0.15),
- const Color(0x802962FF).withOpacity(0.15),
- ]);
- gradientEnable2 = const LinearGradient(colors: <Color>[
- Color(0xFF1A237E),
- Color(0xFF1C2D92),
- ]);
- });
- //change style
},
onTapUp: (details) {
- setState(() {
- gradientEnable1 = const LinearGradient(colors: <Color>[
- Color(0xFF2962FF),
- Color(0x802962FF),
- ]);
- gradientEnable2 = const LinearGradient(colors: <Color>[
- Color(0xFF1A237E),
- Color(0xFF141F64),
- ]);
- });
},
child: Container(
width: size,
width: iconSize,
height: iconSize,
)
- // : !_isPlaying && controlProgress > 0.8
- // ? SvgPicture.asset(
- // "assets/ACMainButton.svg",
- // width: iconSize,
- // height: iconSize,
- // )
: SizedBox(
width: iconSize,
height: iconSize,
onInit: (_) => setState(() {
_controller.isActive = true;
}))))
- // Container(
- // width: size,
- // height: size,
- // alignment: Alignment.center,
- // child: SvgPicture.asset(
- // "assets/ACMainButton.svg",
- // width: iconSize,
- // height: iconSize,
- // ),
- // ),
),
),
),
@override
void paint(Canvas canvas, Size size) {
// const strokeWidth = 25.0;
- const borderWidth = 2.0;
// Divide the arc into equal parts based on the number of colors
const arcAngle = math.pi;
const arcPart = arcAngle / 3;
const gapAngle = arcAngle / 150;
+ // Define drop shadow properties
+ const shadowOffset = Offset(0, 0);
+ const shadowBlur = 12.0;
+ const shadowColor = AGLDemoColors.jordyBlueColor;
+
// Calculate the current color index based on animation progress and progress value
final double normalizedProgress = progress * 3;
int currentColorIndex =
currentColor = backgroundColor;
}
+ // Create paths for drop shadow and actual color
+ final shadowPath = Path()
+ ..addArc(
+ Rect.fromCircle(
+ center: Offset(size.width / 2, size.height / 2) + shadowOffset,
+ radius: size.width / 2,
+ ),
+ startAngle,
+ arcPart - 2 * gapAngle,
+ // Draw clockwise
+ );
+ final colorPath = Path()
+ ..addArc(
+ Rect.fromCircle(
+ center: Offset(size.width / 2, size.height / 2),
+ radius: size.width / 2,
+ ),
+ startAngle,
+ arcPart - 2 * gapAngle,
+ // Draw clockwise
+ );
+
+ // Draw drop shadow using offset and blur
+ final shadowPaint = Paint()
+ ..color = shadowColor
+ ..style = PaintingStyle.fill
+ ..maskFilter = const MaskFilter.blur(BlurStyle.normal, shadowBlur);
+ if (currentColor == progressColor) {
+ canvas.drawPath(shadowPath, shadowPaint);
+ }
+
// Draw border
final borderPaint = Paint()
- ..strokeWidth = strokeWidth + borderWidth
+ ..strokeWidth = strokeWidth + 2.0 // Add border width
..style = PaintingStyle.stroke
..color = Colors.white12;
- canvas.drawArc(
- Rect.fromCircle(
- center: Offset(size.width / 2, size.height / 2),
- radius: size.width / 2,
- ),
- startAngle,
- arcPart - 2 * gapAngle,
- false, // Draw clockwise
- borderPaint,
- );
+ canvas.drawPath(colorPath, borderPaint);
// Draw inner color
final colorPaint = Paint()
..strokeWidth = strokeWidth
..style = PaintingStyle.stroke
- ..shader = _createColorShader(currentColor, size);
- canvas.drawArc(
- Rect.fromCircle(
- center: Offset(size.width / 2, size.height / 2),
- radius: size.width / 2,
- ),
- startAngle,
- arcPart - 2 * gapAngle,
- false, // Draw clockwise
- colorPaint,
- );
+ ..shader = _createColorShader(currentColor, size, i);
+ canvas.drawPath(colorPath, colorPaint);
startAngle += arcPart + gapAngle;
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) => true;
- Shader _createColorShader(Color color, Size size) {
+ Shader _createColorShader(Color color, Size size, int index) {
+ Alignment alignment = index == 0
+ ? const Alignment(-0.78, -0.38)
+ : index == 1
+ ? const Alignment(0, -1)
+ : const Alignment(0.78, -0.38);
if (color == progressColor) {
- return const RadialGradient(
- center: Alignment.center,
- radius: 2,
- tileMode: TileMode.repeated,
- focal: Alignment.center,
- focalRadius: 8,
- colors: [
+ return RadialGradient(
+ center: alignment,
+ radius: 0.35,
+ focal: alignment,
+ focalRadius: 0.02,
+ colors: const [
AGLDemoColors.blueGlowFillColor,
AGLDemoColors.jordyBlueColor,
AGLDemoColors.neonBlueColor
),
),
),
-
Padding(
padding: const EdgeInsets.only(
right: 40,