Skip to content

Commit

Permalink
Added expandedCountry to the Location model. (#589)
Browse files Browse the repository at this point in the history
updated new card form and Pledge screen to use those values
  • Loading branch information
eoji authored Aug 19, 2019
1 parent 72d9624 commit 900eaad
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ private LocationFactory() {}
.name("Berlin")
.state("Berlin")
.country("DE")
.expandedCountry("Germany")
.build();
}

Expand All @@ -24,6 +25,7 @@ private LocationFactory() {}
.name("Mexico City")
.state("Mexico")
.country("MX")
.expandedCountry("Mexico")
.build();
}

Expand All @@ -35,6 +37,7 @@ private LocationFactory() {}
.country("AU")
.state("NSW")
.projectsCount(33)
.expandedCountry("Australia")
.build();
}

Expand All @@ -45,6 +48,7 @@ private LocationFactory() {}
.name("Brooklyn")
.state("NY")
.country("US")
.expandedCountry("United States")
.build();
}
}
12 changes: 7 additions & 5 deletions app/src/main/java/com/kickstarter/models/Location.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,23 @@
@AutoParcel
public abstract class Location implements Parcelable {
public abstract long id();
public abstract String displayableName();
public abstract String name();
public abstract @Nullable String city();
public abstract @Nullable String state();
public abstract String country();
public abstract String displayableName();
public abstract @Nullable String expandedCountry();
public abstract String name();
public abstract @Nullable Integer projectsCount();
public abstract @Nullable String state();

@AutoParcel.Builder
public abstract static class Builder {
public abstract Builder displayableName(String __);
public abstract Builder id(long __);
public abstract Builder name(String __);
public abstract Builder city(String __);
public abstract Builder state(String __);
public abstract Builder country(String __);
public abstract Builder expandedCountry(String __);
public abstract Builder name(String __);
public abstract Builder state(String __);
public abstract Builder projectsCount(Integer __);
public abstract Location build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ class NewCardFragment : BaseFragment<NewCardFragmentViewModel.ViewModel>() {
allowed_card_warning.setText(it)
} else {
val ksString = this.viewModel.environment.ksString()
val projectLocation = project.location()?.displayableName()
allowed_card_warning.text = ksString.format(getString(it), "project_country", projectLocation)
val country = project.location()?.expandedCountry()
allowed_card_warning.text = ksString.format(getString(it), "project_country", country)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ interface RewardCardViewHolderViewModel : BaseRewardCardViewHolderViewModel {
.filter { !it }
.compose<Pair<Boolean, Project>>(combineLatestPair(project))
.map { it.second }
.map { it.location()?.displayableName() }
.map { it.location()?.expandedCountry()?: "" }
.compose(bindToLifecycle())
.subscribe(this.projectCountry)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class RewardCardViewHolderViewModelTest : KSRobolectricTestCase() {

this.vm.inputs.configureWith(Pair(creditCard, ProjectFactory.mxProject()))

this.projectCountry.assertValue("Mexico City, Mexico")
this.projectCountry.assertValue("Mexico")
}

}

0 comments on commit 900eaad

Please sign in to comment.