SDK Props Reference
VoteNowButton Props
| Prop | Type | Required | Description |
|---|---|---|---|
URL | string | Yes | The voting URL obtained from the VOTR API |
label | string | No | Button text (default: "Vote Now") |
buttonStyle | ViewStyle | No | Custom styling for the button |
textStyle | TextStyle | No | Custom styling for the button text |
isDisabled | boolean | No | Whether the button is disabled |
onPress | () => void | No | Called when the button is pressed |
onSuccess | () => void | No | Called when voting completes successfully |
onError | (error: string) => void | No | Called when an error occurs |
onBack | () => void | No | Called when the user closes the voting modal |
Example with All Props
<VoteNowButton
URL={votingUrl}
label="Submit Your Vote"
buttonStyle={{
backgroundColor: "#28a745",
borderRadius: 12,
paddingVertical: 16,
paddingHorizontal: 32,
elevation: 3,
shadowColor: "#000",
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.25,
shadowRadius: 3.84,
}}
textStyle={{
color: "#ffffff",
fontSize: 18,
fontWeight: "600",
textAlign: "center",
}}
isDisabled={!votingUrl}
onPress={() => console.log("Vote button pressed")}
onSuccess={() => {
Alert.alert("Success", "Vote submitted successfully!");
navigation.goBack();
}}
onError={(error) => {
console.error("Voting error:", error);
Alert.alert("Error", "Failed to submit vote. Please try again.");
}}
onBack={() => {
console.log("User cancelled voting");
}}
/>
Advanced Usage with Custom Styling
<VoteNowButton
URL={votingUrl}
label="Cast Your Vote"
buttonStyle={{
backgroundColor: "#007AFF",
borderRadius: 8,
paddingVertical: 12,
paddingHorizontal: 24,
shadowColor: "#000",
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.25,
shadowRadius: 3.84,
elevation: 5,
}}
textStyle={{
color: "white",
fontSize: 16,
fontWeight: "bold",
}}
onSuccess={() => {
Alert.alert("Success", "Your vote has been recorded!");
}}
onError={(error) => {
Alert.alert("Error", `Voting failed: ${error}`);
}}
/>