Adding starting price, maybe more people buy doing that.
This commit is contained in:
parent
aec8d719dd
commit
f1867c4e14
@ -128,7 +128,6 @@ sub start($self) {
|
||||
$self->_activate(undef);
|
||||
}
|
||||
);
|
||||
print Data::Dumper::Dumper $app;
|
||||
$app->run( [ $0, @ARGV ] );
|
||||
}
|
||||
|
||||
@ -231,7 +230,8 @@ sub _on_get_price( $self, $instance_id ) {
|
||||
warn 'Server error retrieving price';
|
||||
exit;
|
||||
}
|
||||
my ( $price, $discount ) = $price_json->@{ 'price', 'discount' };
|
||||
my ( $price, $discount, $starting_price ) =
|
||||
$price_json->@{ 'price', 'discount', 'starting_price' };
|
||||
$self->send_packet_to_window(
|
||||
$instance_id,
|
||||
{
|
||||
@ -239,6 +239,7 @@ sub _on_get_price( $self, $instance_id ) {
|
||||
data => {
|
||||
price => $price,
|
||||
discount => $discount,
|
||||
starting_price => $starting_price,
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -31,6 +31,7 @@ has _last_valid_preview_file => ( is => 'rw' );
|
||||
has _is_showing_paywall => ( is => 'rw' );
|
||||
has _price => ( is => 'rw' );
|
||||
has _discount => ( is => 'rw' );
|
||||
has _starting_price => ( is => 'rw' );
|
||||
has file_format => (
|
||||
is => 'rw',
|
||||
default => sub {
|
||||
@ -332,15 +333,17 @@ sub _show_paywall( $self, $overlay ) {
|
||||
my $debug_message = Gtk4::Label->new(
|
||||
'This is debug compilation, do not use your real payment data but a Stripe test card'
|
||||
);
|
||||
# $inner_paywall_box->append($debug_message);
|
||||
|
||||
# $inner_paywall_box->append($debug_message);
|
||||
}
|
||||
my $window_price_discount = Gtk4::ScrolledWindow->new;
|
||||
$window_price_discount->set_hexpand(1);
|
||||
$window_price_discount->set_property('width-request', 600);
|
||||
$window_price_discount->set_property( 'width-request', 600 );
|
||||
$self->_window_price_discount($window_price_discount);
|
||||
if ( defined $self->_price ) {
|
||||
$self->_on_receive_price;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$self->_send_get_price;
|
||||
}
|
||||
$inner_paywall_box->append($window_price_discount);
|
||||
@ -696,6 +699,7 @@ sub _run_script( $self, $device = undef, $verbose = 1 ) {
|
||||
sub _on_receive_price($self) {
|
||||
my $price = $self->_price;
|
||||
my $discount = $self->_discount;
|
||||
my $starting_price = $self->_starting_price;
|
||||
if ( !$self->_is_showing_paywall ) {
|
||||
return;
|
||||
}
|
||||
@ -706,16 +710,24 @@ sub _on_receive_price($self) {
|
||||
my $box = Gtk4::Box->new( 'horizontal', 10 );
|
||||
$box->set_halign('center');
|
||||
my $discount_label = Gtk4::Label->new(undef);
|
||||
$discount_label->set_markup("<big>-$discount% Cheaper than usual</big>");
|
||||
$discount_label->set_markup("-$discount%");
|
||||
$starting_price =~ s/^(.)$/0$1/;
|
||||
$starting_price =~ s/(..)$/.$1/;
|
||||
$starting_price =~ s/^\./0./;
|
||||
$price =~ s/^(.)$/0$1/;
|
||||
$price =~ s/(..)$/.$1/;
|
||||
$price =~ s/^\./0./;
|
||||
my $starting_price_label = Gtk4::Label->new;
|
||||
$starting_price_label->set_markup("<small><s>$starting_price€</s></small>");
|
||||
$discount_label->add_css_class('discount');
|
||||
|
||||
if ( !defined $price ) {
|
||||
return;
|
||||
}
|
||||
$price =~ s/(..)$/.$1/;
|
||||
$price =~ s/^\./0./;
|
||||
my $price_label = Gtk4::Label->new(undef);
|
||||
$price_label->set_markup("<big>Activate now for: $price€</big>");
|
||||
$price_label->set_markup("<big>$price€</big>");
|
||||
$box->append($price_label);
|
||||
$box->append($starting_price_label);
|
||||
if ( $discount > 2 ) {
|
||||
$box->append($discount_label);
|
||||
}
|
||||
@ -725,9 +737,11 @@ sub _on_receive_price($self) {
|
||||
sub receive_packet( $self, $packet ) {
|
||||
if ( $packet->{type} eq 'price' ) {
|
||||
my $data = $packet->{data};
|
||||
my ( $price, $discount ) = $data->@{ 'price', 'discount' };
|
||||
my ( $price, $discount, $starting_price ) =
|
||||
$data->@{ 'price', 'discount', 'starting_price' };
|
||||
$self->_price($price);
|
||||
$self->_discount($discount);
|
||||
$self->_starting_price($starting_price);
|
||||
$self->_on_receive_price;
|
||||
return;
|
||||
}
|
||||
@ -1034,7 +1048,7 @@ sub _save_action($self) {
|
||||
);
|
||||
}
|
||||
|
||||
sub _send_get_price( $self ) {
|
||||
sub _send_get_price($self) {
|
||||
$self->app->send_packet_to_daemon(
|
||||
$self,
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user