Support
Quality
Security
License
Reuse
kandi has reviewed StepView and discovered the below as its top functions. This is intended to give you an instant insight into StepView implemented functionality, and help decide if they suit your requirements.
Step by step,just use HorizontalStepView,VerticalStepView. step indicator,flow indicator,timeline,order process,express status
how to use
repositories {
...
maven { url "https://jitpack.io" }
}
use HorizontalStepView
<com.baoyachi.stepview.HorizontalStepView
android:id="@+id/step_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
/>
use VerticalStepView
/**
* is reverse draw 是否倒序画
*
* @param isReverSe default is true
* @return
*/
public VerticalStepView reverseDraw(boolean isReverSe)
{
this.mStepsViewIndicator.reverseDraw(isReverSe);
return this;
}
How to make currentindex the correct number instead of 0 on appearing of the page C# Xamarin
myImage.Source = ($"{protocolName}{content?.Contentid}.jpg");
Buttons don't count chapter ids correctly from json using linq in c#
public StepView(Protocol protocol, string title, string chapterTitle, int stepIndex)
{
_protocol = protocol;
InitializeComponent();
Title = title + " - " + chapterTitle;
// get label text
lblText.Text = protocol.Contents.FirstOrDefault(x => x.ChapterTitle == chapterTitle).Text;
// Set the "index" property here. You need to make sure that the "stepIndex"
// constructor parameter has the appropriate value.
index = stepIndex;
}
What to use instead of FirstOrDefault to get the json text associated with the chosen chapter in C# using linq?
x => x.Text != null
Navigation.PushAsync(new StepView(_protocol, nextTitle));
Navigation.PushAsync(new StepView(_protocol, Title, tappedStep.ChapterTitle));
public StepView(Protocol protocol, string title, string chapterTitle)
{
_protocol = protocol;
InitializeComponent();
Title = title + " - " + chapterTitle;
// get label text
lblText.Text = protocol.Contents.FirstOrDefault(x => x.ChapterTitle == chapterTitle).Text;
}
x => x.ChapterTitle == chapterTitle
-----------------------
x => x.Text != null
Navigation.PushAsync(new StepView(_protocol, nextTitle));
Navigation.PushAsync(new StepView(_protocol, Title, tappedStep.ChapterTitle));
public StepView(Protocol protocol, string title, string chapterTitle)
{
_protocol = protocol;
InitializeComponent();
Title = title + " - " + chapterTitle;
// get label text
lblText.Text = protocol.Contents.FirstOrDefault(x => x.ChapterTitle == chapterTitle).Text;
}
x => x.ChapterTitle == chapterTitle
-----------------------
x => x.Text != null
Navigation.PushAsync(new StepView(_protocol, nextTitle));
Navigation.PushAsync(new StepView(_protocol, Title, tappedStep.ChapterTitle));
public StepView(Protocol protocol, string title, string chapterTitle)
{
_protocol = protocol;
InitializeComponent();
Title = title + " - " + chapterTitle;
// get label text
lblText.Text = protocol.Contents.FirstOrDefault(x => x.ChapterTitle == chapterTitle).Text;
}
x => x.ChapterTitle == chapterTitle
-----------------------
x => x.Text != null
Navigation.PushAsync(new StepView(_protocol, nextTitle));
Navigation.PushAsync(new StepView(_protocol, Title, tappedStep.ChapterTitle));
public StepView(Protocol protocol, string title, string chapterTitle)
{
_protocol = protocol;
InitializeComponent();
Title = title + " - " + chapterTitle;
// get label text
lblText.Text = protocol.Contents.FirstOrDefault(x => x.ChapterTitle == chapterTitle).Text;
}
x => x.ChapterTitle == chapterTitle
-----------------------
x => x.Text != null
Navigation.PushAsync(new StepView(_protocol, nextTitle));
Navigation.PushAsync(new StepView(_protocol, Title, tappedStep.ChapterTitle));
public StepView(Protocol protocol, string title, string chapterTitle)
{
_protocol = protocol;
InitializeComponent();
Title = title + " - " + chapterTitle;
// get label text
lblText.Text = protocol.Contents.FirstOrDefault(x => x.ChapterTitle == chapterTitle).Text;
}
x => x.ChapterTitle == chapterTitle
Change Tabbar Icon Image SwiftUI
var body: some View {
ZStack {
TabView(selection:$selection) {
OffersView()
.tabItem ({
Image(systemName: selection == 1 ? "bag" : "bag2").renderingMode(.template)
Text("Offers")
})
.tag(1)
StepView()
.tabItem ({
Image(systemName: selection == 2 ? "figure.walk.circle" : "figure.walk.circle2").renderingMode(.template)
Text("Steps")
})
.tag(2)
// -----Other Code-----
-----------------------
var body: some View {
@State var isTapped = false
ZStack {
TabView(selection:$isTapped) {
OffersView()
.tabItem ({
Image(systemName: selection == 1 ? "bag" : "bag2").renderingMode(.template)
Text("Offers")
})
.tag(1)
StepView()
.tabItem ({
Image(systemName: selection == 2 ? "figure.walk.circle" : "figure.walk.circle2").renderingMode(.template)
Text("Steps")
})
.tag(2)
ProfileView()
.tabItem {
Image(systemName: "person")
Text("Profile")
}
.tag(3)
}
.accentColor(Color("ColorOnboarding"))
.navigationBarBackButtonHidden(true)
}
Clear View Data When Tab is Changed SwiftUI
private func updateUIFromStatistics(_ statisticsCollection: HKStatisticsCollection) {
steps = [] // remove previous values
let now = Date()
let startOfDay = Calendar.current.startOfDay(for: now)
statisticsCollection.enumerateStatistics(from: startOfDay, to: now) { (statistics, stop) in
let count = statistics.sumQuantity()?.doubleValue(for: .count())
let step = Step(count: Int(count ?? 0), date: statistics.startDate, wc: Double(count ?? 0 / 1000 ))
steps.append(step)
}
}
Cannot convert value of type 'Int?' to expected argument type 'Binding<Int>' SwiftUI
struct CircularProgress: View {
var steps: Int
struct Outline: View {
var steps: Int
-----------------------
struct CircularProgress: View {
var steps: Int
struct Outline: View {
var steps: Int
QUESTION
How to make currentindex the correct number instead of 0 on appearing of the page C# Xamarin
Asked 2021-Dec-16 at 12:37I have a class called stepview that based on btnBack (1 number back) or btnNext (1 number ahead) changes the text based on the contentid from json. This works, but not on the appearing because then i don't see a image because the index is 0 then.
the currentindex should be equal to the contentid of my json file, and now only works correctly with my label text, showing the correct text already based on the id.
The only thing that works with the photos is that if you click on next or back you will see the photo, but this is not the case with the page where the user ends up first. How do I solve this?
This are my btnNext and btnBack for showing text + image based on his index from the contentid from json
public void BtnBack_Clicked(object sender, EventArgs e)
{
BtnNext.IsEnabled = true;
int currentIndex = getCurrentIndex();
//if its the first item disable back button
if (currentIndex.Equals(1))
{
BtnBack.IsEnabled = false;
}
var content = _protocol.Contents[currentIndex - 1];
_contentId = content.Contentid;
lblText.Text = content?.Text;
string protocolName = _protocol.Name;
//replace space with underscore to get correct picture name
protocolName = protocolName.Replace(" ", "_");
myImage.Source = ($"{protocolName}{content?.Contentid}.jpg");
//get current navTitle on button click
setNewNavTitle();
}
public void BtnNext_Clicked(object sender, EventArgs e)
{
BtnBack.IsEnabled = true;
int currentIndex = getCurrentIndex();
var content = _protocol.Contents[currentIndex + 1];
//do something after second last
if (currentIndex == _protocol.Contents.Count - 2)
{
BtnNext.IsEnabled = false;
}
_contentId = content.Contentid;
lblText.Text = content?.Text;
string protocolName = _protocol.Name;
//replace space with underscore to get correct picture name
protocolName = protocolName.Replace(" ", "_");
myImage.Source = ($"{protocolName}{content?.Contentid}.jpg");
//get current navTitle on button click
setNewNavTitle();
}
when the user enters the page for the first time, it does not show an associated photo, only the text he puts in the label
this is for showing the photo on the 2 button clicks
myImage.Source = ($"{protocolName}{content?.Contentid}.jpg");
the contentid appears to be 0 on beginning
This is my Json file
"protocols": [
{
"id": "1",
"name": "Pols tellen",
"contents": [
{
"chapterTitle": "Voorzorg",
"contentid": "1",
"text": "test1"
},
{
"contentid": "2",
"text": "test2"
},
{
"chapterTitle": "Handeling",
"contentid": "3",
"text": "test3"
},
{
"contentid": "4",
"test1": "test4"
},
{
"chapterTitle": "Nazorg",
"contentid": "10",
"text": "test5"
},
{
"contentid": "11",
"text": "test6"
}
]
},
}
And this is my class for recieving text and image based on his contentid (what only works now for the text in the label)
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class StepView : ContentPage
{
//get index
private long _contentId;
//get step
private Protocol _protocol;
//go to selected step
public StepView(Protocol protocol, string title, string chapterTitle, long contentId)
{
_protocol = protocol;
InitializeComponent();
Title = title + " - " + chapterTitle;
// get label text
lblText.Text = protocol.Contents.FirstOrDefault(x => x.ChapterTitle == chapterTitle).Text;
_contentId = contentId;
}
public void BtnBack_Clicked(object sender, EventArgs e)
{
BtnNext.IsEnabled = true;
int currentIndex = getCurrentIndex();
//if its the first item disable back button
if (currentIndex.Equals(1))
{
BtnBack.IsEnabled = false;
}
var content = _protocol.Contents[currentIndex - 1];
_contentId = content.Contentid;
lblText.Text = content?.Text;
string protocolName = _protocol.Name;
//replace space with underscore to get correct picture name
protocolName = protocolName.Replace(" ", "_");
myImage.Source = ($"{protocolName}{content?.Contentid}.jpg");
//get current navTitle on button click
setNewNavTitle();
}
//go back to home
public async void btnHome_Clicked(object sender, EventArgs e)
{
//go to mainpage
await Navigation.PushAsync(new MainPage());
}
public void BtnNext_Clicked(object sender, EventArgs e)
{
BtnBack.IsEnabled = true;
int currentIndex = getCurrentIndex();
var content = _protocol.Contents[currentIndex + 1];
//do something after second last
if (currentIndex == _protocol.Contents.Count - 2)
{
BtnNext.IsEnabled = false;
}
_contentId = content.Contentid;
lblText.Text = content?.Text;
string protocolName = _protocol.Name;
//replace space with underscore to get correct picture name
protocolName = protocolName.Replace(" ", "_");
myImage.Source = ($"{protocolName}{content?.Contentid}.jpg");
//get current navTitle on button click
setNewNavTitle();
}
private string getChapterTitle()
{
var currentIndex = getCurrentIndex();
string chapterTitle = _protocol.Contents[currentIndex].ChapterTitle;
//get the previous or next chapter based on where you clicked on
while (currentIndex > 0 && string.IsNullOrWhiteSpace(chapterTitle))
{
currentIndex -= 1;
chapterTitle = _protocol.Contents[currentIndex].ChapterTitle;
}
return chapterTitle;
}
private int getCurrentIndex()
{
var currentContent = _protocol.Contents.FirstOrDefault(x => x.Contentid == _contentId);
var currentIndex = _protocol.Contents.IndexOf(currentContent);
return currentIndex;
}
//get new protocol + chapter based on btnBack and btnNext
private void setNewNavTitle()
{
string nextTitile = _protocol.Name + " - " + getChapterTitle();
Title = nextTitile;
}
how do I get the same effect for my label text for my photos? Thanks in advance
ANSWER
Answered 2021-Dec-16 at 12:37just add this to the end of the page constructor
myImage.Source = ($"{protocolName}{content?.Contentid}.jpg");
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
No vulnerabilities reported
Save this library and start creating your kit
Explore Related Topics
Save this library and start creating your kit