maui-linux/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issu.../GitHub1700.cs

252 строки
4.9 KiB
C#
Исходник Обычный вид История

using System.Collections.Generic;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 1700, "Desktop: TabStop/TabIndex support (for multiple Views)", PlatformAffected.All)]
public class GitHub1700 : TestContentPage
{
IList<View> listViews;
void IndexDesc()
{
int index = 100500;
foreach (var item in listViews)
{
if (item is Button but && but.Text.StartsWith("TabIndex"))
continue;
item.TabIndex = index--;
}
}
void IndexNegative()
{
int index = -100;
foreach (var item in listViews)
{
if (item is Button but && but.Text.StartsWith("TabIndex"))
continue;
item.TabIndex = index++;
}
}
protected override void Init()
{
var actionGrid = new Grid()
{
Padding = new Thickness(10),
BackgroundColor = Color.Aquamarine
};
actionGrid.AddChild(new Button()
{
Text = "Index desc",
Command = new Command(() => IndexDesc())
}, 0, 0);
actionGrid.AddChild(new Button()
{
Text = "All indexes equal 0",
Command = new Command(() => listViews.ForEach(c => c.TabIndex = 0))
}, 1, 0);
actionGrid.AddChild(new Button()
{
Text = "Negative indexes",
Command = new Command(() => IndexNegative())
}, 2, 0);
actionGrid.AddChild(new Button()
{
Text = "TabStops = True",
Command = new Command(() => listViews.ForEach(c => c.IsTabStop = true))
}, 0, 1);
actionGrid.AddChild(new Button()
{
Text = "TabStops = False",
Command = new Command(() => listViews.ForEach(c => c.IsTabStop = false))
}, 1, 1);
actionGrid.AddChild(new Button()
{
Text = "TabStops every second",
Command = new Command(() =>
{
for (int i = 0; i < listViews.Count; i++)
listViews[i].IsTabStop = i % 2 == 0;
})
}, 2, 1);
var pickerStopped = new Picker
{
Title = $"[+] Picker - Tab stop enable",
IsTabStop = true
};
var pickerNotStopped = new Picker
{
Title = "[-] Picker - Tab stop disable",
IsTabStop = false
};
for (var i = 1; i < 3; i++) {
pickerNotStopped.Items.Add("Sample Option " + i);
pickerStopped.Items.Add("Sample Option " + i);
}
var stack = new StackLayout
{
Children =
{
actionGrid,
pickerStopped,
pickerNotStopped,
new Button
{
Text = $"TabIndex 90",
IsTabStop = true,
TabIndex = 90
},
new Button
{
Text = $"TabIndex 100",
IsTabStop = true,
TabIndex = 100
},
new Button
{
Text = $"TabIndex 100",
IsTabStop = true,
TabIndex = 100
},
new Button
{
Text = $"TabIndex 90",
IsTabStop = true,
TabIndex = 90
},
new Button
{
Text = $"[+] Button - TabStop enable",
IsTabStop = true
},
new Button
{
Text = "Button - Non stop",
IsTabStop = false
},
Checkbox (#6232) * Add CheckBox class and Renderer * Add CheckBoxCell class * Add Control Gallery for CheckBox and CheckBoxCell. Add stubs only for Android for now. * Update to fast renderer for Android, Implement Checked and Unchecked Colors! * Initial UWP implementation, no colors yet. * Add iOS implementation for checkbox. It's not pretty, but it is a start! * Updates from Frank * Code cleanup with frank * Finalize iOS checkbox!!! it is a circle! * Fix WPF build and Add a checkbox!!! * Cell Renderers and macOS * UWP switchcell * Update CheckBox Cell on ios/android with colors * Remove all instances of CheckBoxCell per demand * Added UITests and UnitTests * Changed colors to TintColor which makes sense. Added a IsChecked visual state property and a sample! * checkbox cleanup, tint color fixes, and material * uwp fix when changing TintBrush * add checkbox to visual controls page * formatting fix * formatting fix * formatting fix * convert to tabs * formatting * checkbox tabs * roll back formatting changes to WPFResources * android renderer overrides * uwp fix and sizing fix ios * mask checkbox * use a single image for ios inatead of always drawing new ones * wpf fix * rename to color and add css interfaces * missing wpf file * designer hack * fix wpf for ios builds * assembly info * fix default tint color and infinite crash * [iOS] fixes change checked state from control simplification added to dynamic galery * [iOS material] fix crash when dispose * [UWP, WPF] fix vertical alignment * [Android] fixes does not change size when the reduction HeightRequest * Update Xamarin.Forms.Material.iOS/MaterialCheckboxRenderer.cs Co-Authored-By: Samantha Houts <samhouts@users.noreply.github.com> * [Android] TabStop support * alphabetize gallery, fix color update when disabled, unsubscribe from event in dispose * cleanup assembly info * fix assembly attributes * remove assembly info * pr comments * couple of more dispose fixes * One Last Dispose * fix api 19 call to ClipToOutline
2019-05-30 19:32:28 +03:00
new CheckBox
{
IsTabStop = true
},
new CheckBox
{
IsTabStop = false
},
new DatePicker
{
IsTabStop = true
},
new DatePicker
{
IsTabStop = false
},
new Editor
{
Text = $"[+] Editor - Tab stop enable",
IsTabStop = true
},
new Editor
{
Text = "Editor - Non stop",
IsTabStop = false
},
new Entry
{
Text = $"[+] Entry - Tab stop enable",
IsTabStop = true
},
new Entry
{
Text = "Entry - Non stop",
IsTabStop = false
},
new ProgressBar
{
IsTabStop = true,
HeightRequest = 40,
Progress = 80
},
new ProgressBar
{
IsTabStop = false,
HeightRequest = 40,
Progress = 40
},
new SearchBar
{
Text = $"[+] SearchBar - TabStop enable",
IsTabStop = true
},
new SearchBar
{
Text = "SearchBar - TabStop disable",
IsTabStop = false
},
new Slider
{
IsTabStop = true
},
new Slider
{
IsTabStop = false
},
new Stepper
{
IsTabStop = true
},
new Stepper
{
IsTabStop = false
},
new Switch
{
IsTabStop = true
},
new Switch
{
IsTabStop = false
},
new TimePicker
{
IsTabStop = true
},
new TimePicker
{
IsTabStop = false
},
}
};
listViews = stack.Children;
foreach (var item in listViews)
{
item.Focused += (_, e) =>
{
BackgroundColor = e.VisualElement.IsTabStop ? Color.Transparent : Color.OrangeRed;
Title = $"{e.VisualElement.TabIndex} - " + (e.VisualElement.IsTabStop ? "[+]" : "WRONG");
e.VisualElement.Scale = 0.7;
};
item.Unfocused += (_, e) =>
{
BackgroundColor = Color.Transparent;
Title = string.Empty;
e.VisualElement.Scale = 1;
};
}
IndexDesc();
Content = new ScrollView()
{
Content = stack
};
}
}
}