浏览代码

Fix some issues.

/main
Yuncong Zhang 6 年前
当前提交
9871138b
共有 6 个文件被更改,包括 12 次插入25 次删除
  1. 2
      Runtime/material/outline_button.cs
  2. 3
      Runtime/material/tabs.cs
  3. 10
      Samples/UIWidgetsGallery/gallery/demo.cs
  4. 15
      Samples/UIWidgetsGallery/gallery/example_code_parser.cs
  5. 2
      Samples/UIWidgetsGallery/gallery/home.cs
  6. 5
      Samples/UIWidgetsGallery/gallery/syntax_highlighter.cs

2
Runtime/material/outline_button.cs


}
)
) {
D.assert(onPressed != null);
D.assert(highlightElevation == null || highlightElevation >= 0.0f);
D.assert(icon != null);
D.assert(label != null);

) : base(key: key) {
D.assert(highlightElevation != null && highlightElevation >= 0.0f);
D.assert(highlightedBorderColor != null);
D.assert(this.onPressed != null);
this.onPressed = onPressed;
this.brightness = brightness;
this.textTheme = textTheme;

3
Runtime/material/tabs.cs


int tabCount = this.widget.tabs.Count;
for (int index = 0; index < tabCount; index++) {
int tabIndex = index;
onTap: () => { this._handleTap(index); },
onTap: () => { this._handleTap(tabIndex); },
child: new Padding(
padding: EdgeInsets.only(bottom: this.widget.indicatorWeight),
child: wrappedTabs[index]

10
Samples/UIWidgetsGallery/gallery/demo.cs


string _exampleCode;
public override void didChangeDependencies() {
new ExampleCodeParser().getExampleCode(this.widget.exampleCodeTag, DefaultAssetBundle.of(this.context)).Then(
(string code) => {
if (this.mounted) {
this.setState(() => { this._exampleCode = code ?? "Example code not found"; });
}
});
string code = new ExampleCodeParser().getExampleCode(this.widget.exampleCodeTag, DefaultAssetBundle.of(this.context));
if (this.mounted) {
this.setState(() => { this._exampleCode = code; });
}
}
public override Widget build(BuildContext context) {

15
Samples/UIWidgetsGallery/gallery/example_code_parser.cs


using System.Linq;
using System.Threading.Tasks;
using RSG;
using Unity.UIWidgets.foundation;
using UnityEngine;
namespace UIWidgetsGallery.gallery {

Dictionary<string, string> _exampleCode;
public IPromise<string> getExampleCode(string tag, AssetBundle bundle) {
public string getExampleCode(string tag, AssetBundle bundle) {
return Promise<string>.Resolved(this._exampleCode[tag]);
return this._exampleCode.getOrDefault(tag);
async Task _parseExampleCode(AssetBundle bundle) {
void _parseExampleCode(AssetBundle bundle) {
string code = Resources.Load<TextAsset>("example_code.cs")?.text ??
"// example_code.cs not found\n";
this._exampleCode = new Dictionary<string, string>{};

foreach (string line in lines) {
if (codeBlock == null) {
// Outside a block.
// Starting a new code block.
// Just skipping the line.
// Inside a block.
// Add the block.
// Add to the current block
// trimRight() to remove any \r on Windows
// without removing any useful indentation
codeBlock.Add(line.TrimEnd());
}
}

2
Samples/UIWidgetsGallery/gallery/home.cs


}
class _GalleryHomeState : SingleTickerProviderStateMixin<GalleryHome> {
static readonly GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>.key();
readonly GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>.key();
AnimationController _controller;
GalleryDemoCategory _category;

5
Samples/UIWidgetsGallery/gallery/syntax_highlighter.cs


public class DartSyntaxHighlighter : SyntaxHighlighter {
public DartSyntaxHighlighter(SyntaxHighlighterStyle _style = null) {
this._spans = new List<_HighlightSpan> { };
this._style = this._style ?? SyntaxHighlighterStyle.darkThemeStyle();
this._style = _style ?? SyntaxHighlighterStyle.darkThemeStyle();
}
SyntaxHighlighterStyle _style;

this._scanner = new StringScanner(this._src);
if (this._generateSpans()) {
// Successfully parsed the code
List<TextSpan> formattedText = new List<TextSpan> { };
int currentPosition = 0;

return new TextSpan(style: this._style.baseStyle, children: formattedText);
}
else {
// Parsing failed, return with only basic formatting
return new TextSpan(style: this._style.baseStyle, text: src);
}
}

while (!this._scanner.isDone) {
// Skip White space
this._scanner.scan(new Regex(@"\s+"));
// Block comments

正在加载...
取消
保存