main.qml Example File
batterysample/assets/main.qml
import bb.cascades 1.0
import bb.device 1.0
Page {
Container {
layout: DockLayout {}
ImageView {
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill
imageSource: "asset:///images/background.png"
}
Battery {
horizontalAlignment: HorizontalAlignment.Center
verticalAlignment: VerticalAlignment.Center
}
Container {
horizontalAlignment: HorizontalAlignment.Center
verticalAlignment: VerticalAlignment.Bottom
bottomPadding: 50
Label {
id: stateLabel
horizontalAlignment: HorizontalAlignment.Center
text: {
switch (_battery.chargingState) {
case BatteryChargingState.Unknown:
return qsTr ("Unknown");
break;
case BatteryChargingState.NotCharging:
return qsTr ("Not Charging");
break;
case BatteryChargingState.Charging:
return qsTr ("Charging");
break;
case BatteryChargingState.Discharging:
return qsTr ("Discharging");
break;
case BatteryChargingState.Full:
return qsTr ("Full");
break;
}
}
textStyle {
color: Color.White
fontSize: FontSize.XLarge
}
}
Label {
id: descriptionLabel
horizontalAlignment: HorizontalAlignment.Center
bottomMargin: 100
text: {
switch (_battery.chargingState) {
case BatteryChargingState.Unknown:
return qsTr ("Something is up with the battery");
break;
case BatteryChargingState.NotCharging:
return qsTr ("Plugged in, just no charge");
break;
case BatteryChargingState.Charging:
return qsTr ("Plugged in");
break;
case BatteryChargingState.Discharging:
return qsTr ("Unplugged and discharging");
break;
case BatteryChargingState.Full:
return qsTr ("Plugged in, full");
break;
}
}
textStyle {
color: Color.Gray
fontSize: FontSize.Large
}
}
}
}
}