在 Xamarin.Forms 应用程序(直接连接到 Play 商店或 App Store 的默认星形表格)上添加应用评级的最佳/最简单选项是哪个?
我有一个类似于以下内容的小部件测试:
testWidgets('Widget test', (WidgetTester tester) async {
provideMockedNetworkImages(() async {
final widget = MyWidget();
await WidgetTestFunctions.pumpWidgetTest(
tester,
widget,
);
// ....
await tester.tap(find.byType(MyWidget));
await tester.pump(new Duration(milliseconds: 3000));
// ....
expect(widget.value, myValue);
});
});
Run Code Online (Sandbox Code Playgroud)
以及小部件 on-tap 方法的以下实现:
_onButtonPressed() async {
await animationController.forward();
setState(() {
// ...
// Calls method that changes the widget value.
});
}
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是,animationController.forward()
在测试中调用该方法后,该setState
部分未执行。我应该如何等待这个方法正确完成?在应用程序运行时,这部分代码被正确调用。
似乎await tester.pump(new Duration(milliseconds: 3000));
工作不正常,动画的持续时间为 1500 毫秒,并且您可以看到泵持续时间是双倍的。
大家好,我正在做一个 Xamarin.Forms 应用程序,你可以看到这是我的应用程序:
在此屏幕截图中,您可以看到我的 App.xaml.cs,我在其中上传了一个底部栏页 StartPage()。
public App()
{
InitializeComponent();
//MainPage = new Login();
NavigationPage nav = new NavigationPage(new StartPage());
Image img = new Image();
img.Source = "about_us.png";
Label label = new Label();
label.Text = "My App";
label.VerticalTextAlignment = TextAlignment.Center;
label.TextColor = Color.Black;
StackLayout stack = new StackLayout();
stack.Children.Add(img);
stack.Children.Add(label);
nav.SetValue(NavigationPage.TitleViewProperty, stack);
//nav.SetValue(NavigationPage.TitleProperty, stack);
nav.SetValue(NavigationPage.BarBackgroundColorProperty, Color.FromHex("#D60000"));
MainPage = nav;
}
Run Code Online (Sandbox Code Playgroud)
正如您在我的第一个屏幕中看到的,在 App() 中,我试图将标题和应用程序图标添加到导航栏,但不起作用,我该怎么做才能添加它?
我应该如何创造这个设计的优秀部分?我正在使用 DialogFragment 在弹出窗口中执行此操作,但我无法实现顶部透明的效果。
按钮设计不过background_circle:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid
android:color="#fff"/>
</shape>
Run Code Online (Sandbox Code Playgroud)
使用以下 XML 文件 my_dialog:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="30dp"
android:padding="10dp"
android:orientation="vertical"
android:background="#fff"
android:gravity="center">
<TextView
android:layout_marginTop="50dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="text long text"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button"/>
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:background="@drawable/background_circle"
android:padding="3dp"
android:src="@drawable/ic_empty_star"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
结果:
星形必须位于布局之外的上部部分。
我正在 Flutter 中使用ListView.builder。现在一切正常,我在回调方法中有以下代码行:
@override
void initState(){
items = new List();
for(int index = 0; index < dataList.length; index++){
items.add(...creating widget ..);
}
}
@override
Widget build(BuildContext context) {
return Container(
child: ListView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: dataList.length,
itemBuilder: (BuildContext context, int index) {
return Container(
width: width,
height: 160 ,
key: UniqueKey(),
padding: EdgeInsets.all(10),
child: items[index],
);
},
),
);
}
Run Code Online (Sandbox Code Playgroud)
问题是当 dataList 的数据更新时,如果数据值更新、删除或位置更改,我应该如何实现此列表以使列表更新 UI 。StreamBuilder 是解决方案吗?
flutter ×2
android ×1
animation ×1
auto-update ×1
circleimage ×1
icons ×1
image ×1
ios ×1
listview ×1
overlapping ×1
tabbedpage ×1
widget ×1
xamarin ×1
xamarin.ios ×1